【发布时间】:2016-05-11 22:27:22
【问题描述】:
我觉得我是世界上第一个尝试让 iOS swift 与 Azure 一起工作的人,但没有太多帮助。 我关注了这个Create an iOS app 然后Add Push Notifications to your iOS App。我应该能够从 iPhone 成功推送通知,但我收到此错误。顺便说一句:我可以让我的 C# 代码在我的电脑的 Visual Studio 中触发(使用这个tutorial),所以请求似乎有效,但响应很糟糕。任何人都知道如何解决它!
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 我拥有的唯一网址是每个教程中的网址。其余代码与我在链接中提到的代码相同(我一个字符一个字符地复制了它):
class ClientManager {
static let sharedClient = MSClient(applicationURLString: "http://<mysite>.azurewebsites.net")
}
更新 #2 @Pau Senabre 根据我的问题,我正在使用 swift 而不是 Objective-C(请参阅我有问题的标签),所以我在您的步骤 1 中没有 .m 文件。我也没有你提到的 logErrorIfNotNil。我的方法(由 Azure 修改前生成)如下所示:
@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 我的目标是做移动应用程序/服务,而不是移动参与。查看区别here。顺便说一句:当我开始使用它并为我工作时,我遵循了 azure 参与示例。但我现在需要的是网络/移动应用程序。那么,您的建议是否仍然适用于我的需求?
【问题讨论】:
-
完全不同,怎么相似!?