iOS上的bms-push cordova插件给出:致命错误:意外地发现零,同时展开可选值
问题描述:
我已经使用新的bms-push cordova插件实施了Ionic测试应用程序。iOS上的bms-push cordova插件给出:致命错误:意外地发现零,同时展开可选值
它在Android上正常工作。
然而,在推出iOS版应用程序时,它会立即失败:
fatal error: unexpectedly found nil while unwrapping an Optional value
在CDVBMSPush
类的didReceiveRemoteNotificationOnLaunch
功能时发生错误。
如果我在AppDelegate.m
[[CDVBMSPush sharedInstance] didReceiveRemoteNotificationOnLaunchWithLaunchOptions:launchOptions];
注释掉以下行然后应用程序正常启动。
有什么建议可以解决这个问题吗? THX
答
单从支持团队得到了一个answer:
[[CDVBMSPush sharedInstance] didReceiveRemoteNotificationOnLaunchWithLaunchOptions:launchOptions];
This is only used when app is opened by clicking push notifications.
At the first time launchOptions will be nil. That why its failing.
Solutions:
- you can add a check there whether the launchOptions is of type remoteNotificationKey, If yes then add the
[[CDVBMSPush sharedInstance] didReceiveRemoteNotificationOnLaunchWithLaunchOptions:launchOptions];
Example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
[[CDVBMSPush sharedInstance] didReceiveRemoteNotificationOnLaunchWithLaunchOptions:launchOptions];
}
}
- Completely remove that line of code.
我收到指向这行代码太崩溃..但只有在通过推出TestFlight应用程序。 BMS-Push示例/设置代码已经更新了一点,包括一个检查为零,但我仍然得到错误,所以去除了该行。我会让你知道它是否有效。 – TimBrighton