我在 iOS 设备上使用 bluemix 上的新推送通知服务。
设备注册成功。当我检查 REST-API 时,我看到了设备 ID、 token 等。
但是,在设备上运行 iOS 应用程序会导致应用程序在首次运行和注册时崩溃。
崩溃发生在 CDVMFPPush.swift
中 func didRegisterForRemoteNotifications(deviceToken: NSData)
在第 309 行(let pushToken = response.responseJson["token"] as!String
)。
我在这个函数中做了一个print(response)
,responseJson 似乎只包含deviceId 和userId。 token 丢失。
当我再次使用 REST-Api 做同样的请求时,响应似乎是完整的。
我认为由于这个错误,推送注册没有完成,因为当我尝试在沙盒模式下运行服务时没有收到任何通知。
有什么想法吗?
(附:我检查了这个解决方案 - iOS Application crashes when trying to register the device to IBM Mobile First Push service on Bluemix - 链接器标志设置为 [-ObjC])
这是来 self 的控制台的请求(app-id/secret/device 已编辑)
Response text: {"createdTime":"2016-06-07T15:28:55Z","lastUpdatedTime":"2016-06-07T15:28:55Z","createdMode":"API","deviceId":"xxxx","userId":"","token":"xxxx","platform":"A","href":"https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx"}
httpStatus: 201
responseHeaders: {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Tue, 07 Jun 2016 15:28:55 GMT";
Location = "https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "OK OK";
"X-Global-Transaction-ID" = xxxx;
"X-Powered-By" = "Servlet/3.0";
}
responseJson: {
deviceId = "xxxxx";
userId = "";
}
最佳答案
我们更新了 MFPPush iOS 框架以解决该问题,并且更新了 MFPPush Cordova 插件以包含这些修复。我们怀疑崩溃的原因是您通过回调发送了第二个 IMFResponse
对象,而这第二个 IMFResponse 的 responseJson 没有您看到的导致崩溃的 token 。这些更改应该可以解决该问题。
更新插件的最简单方法就是删除旧插件并重新添加它,您应该使用 ibm-mfp-push
的版本 1.0.14
到查看修复程序。
也可以在相关的Github上看到截至今天上午的更新 https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-cordova-plugin-push
关于ios - 首次注册该服务时,iOS 上的 IBM-Bluemix 推送服务使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37683867/