来自 IOS Xcode 的 Azure 推送通知错误 [英] Azure Push Notification Error from IOS Xcode

查看:24
本文介绍了来自 IOS Xcode 的 Azure 推送通知错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我是世界上第一个尝试让 iOS swift 与 Azure 一起工作的人,但没有太大帮助.我按照这个 创建一个 iOS 应用然后 添加推送通知到您的 iOS 应用.我应该能够从 iPhone 成功推送通知,但出现此错误.顺便说一句:我可以让我的 C# 代码在我的电脑中的 Visual Studio 中触发(使用这个 tutorial),所以请求似乎有效,但响应很糟糕.任何人都知道如何修复它!!

I feel I am the first one in the universe trying to get iOS swift working with Azure, not much help out there. I followed this Create an iOS app and then Add Push Notifications to your iOS App. I am supposed to be able to do a successful push notification from iPhone, but I get this error. btw: I can get my C# code to trigger in visual studio in my pc (using this tutorial), so the request seems to be working, but the response sucks. Any one knows how to fix it!!

Error registering for notifications:  Optional("Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1302 \"{\"message\":\"An error has occurred.\"}\" UserInfo={com.Microsoft.MicrosoftAzureMobile.ErrorRequestKey=<NSMutableURLRequest: 0x14cebf780> { URL: http://<mysite>.azurewebsites.net/push/installations/1E32E9B5-E976-4CCD-BD61-D026D3F4FF1C }, com.Microsoft.MicrosoftAzureMobile.ErrorResponseKey=<NSHTTPURLResponse: 0x14cec54b0> { URL: http://<mysite>.azurewebsites.net/push/installations/1E32E9B5-E976-4CCD-BD61-D026D3F4FF1C } { status code: 500, headers {\n    \"Content-Length\" = 36;\n    \"Content-Type\" = \"application/json; charset=utf-8\";\n    Date = \"Wed, 11 May 2016 21:39:39 GMT\";\n    Server = \"Microsoft-IIS/8.0\";\n    \"Set-Cookie\" = \"ARRAffinity=8d79cd782ff16b44f7f280b76e2bc5564d86e0d1b228227b8e0033f4bb1c4582;Path=/;Domain=<mysite>.azurewebsites.net\";\n    \"X-Powered-By\" = \"ASP.NET\";\n} }, NSLocalizedDescription={\"message\":\"An error has occurred.\"}}")

更新 #1我拥有的唯一网址是教程中的网址.其余代码与我在链接中提到的相同(我逐字复制):

UPDATE #1 The only url I have is the one per the tutorial. The rest of the code is identical to the ones I mentioned in the links (I copied it character by character):

class ClientManager {
    static let sharedClient = MSClient(applicationURLString: "http://<mysite>.azurewebsites.net")
}

更新 #2@Pau Senabre 根据我的问题,我正在使用 swift 而不是 Objective-C(请参阅我的问题下的标签),所以我在您的第 1 步中没有 .m 文件.我也没有你提到的 logErrorIfNotNil .我的方法(在修改前由 Azure 生成)如下所示:

UPDATE #2 @Pau Senabre I am working with swift not Objective-C per my question (see my tags under question), so I don't have an .m file per your step #1. I also don't have the logErrorIfNotNil you mentioned. My method (which is generated by Azure before modifications) looks like this:

@IBAction func addItem(sender : AnyObject) {
    self.performSegueWithIdentifier("addItem", sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)
{
    if segue.identifier == "addItem" {
        let todoController = segue.destinationViewController as! ToDoItemViewController
        todoController.delegate = self
    }
}

更新 #3@Pau Senabre 我的目标是做移动应用程序/服务,而不是移动参与.请在此处查看区别.顺便说一句:当我开始玩它并为我工作时,我遵循了天蓝色的参与示例.但我现在需要的是网络/移动应用程序.那么,你的建议是否仍然适用于我的需求?

UPDATE #3 @Pau Senabre My goal is to do mobile apps/services, not mobile engagement. See the difference here. btw: I had followed the azure engagement example when I started playing with it and had worked for me. But my need now is web/mobile apps. So, does what you suggested still apply for my need?

推荐答案

这是我之前遇到的另一个问题的正确答案,它同时解决了:注册和接收推送通知.我在这里说过:

this is the proper answer from another question I had earlier, which fixes both: Registration and Receiving push notifications. I said this in here:

昨晚终于可以收到通知了.我继续使用本教程重新完成了所有苹果端安装步骤的完整演练:使用 Azure 通知中心向 iOS 发送推送通知,然后使用此内容的 azure 方面:创建一个 iOS 应用程序并将推送通知添加到您的iOS应用程序.这完成了成功注册设备的应用程序,我能够使用此线程中 AdrianHall 的注释进行验证.但这还不够.Azure 教程没有详细说明 Xcode 中所需的步骤,我在这里找到:[如何] 在 iOS 中设置远程推送通知 - Swift 2.0 代码我不必在 Xcode 中设置任何推送通知"或类似的东西.

I finally have been able to receive notifications last night. I went ahead and redid an entire walk-through of all apple-side installation steps using this tutorial: Sending push notifications to iOS with Azure Notification Hubs then the azure-side of things using this: Create an iOS app and Add Push Notifications to your iOS App. That took care of the registering the app of the device successfully, which I was able to verify using the note of AdrianHall in this thread. But that wasn't enough. The Azure tutorials fell short detailing the steps needed in Xcode, which I found here: [How To] Setup Remote Push Notification in iOS - Swift 2.0 Code I didn't have to setup any "push notification" in Xcode or anything like that.

我希望这个详细的答案可以为您节省很多时间.

I hope this detailed answer will save you many hours of digging through.

这篇关于来自 IOS Xcode 的 Azure 推送通知错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆