0

I've implemented an Ionic test application using the new bms-push cordova plugin.

It works fine on Android.

However, when launching the app on iOS, it immediately fails with:

fatal error: unexpectedly found nil while unwrapping an Optional value

The error occurs in the didReceiveRemoteNotificationOnLaunch function of the CDVBMSPush class.

If I comment out the following line in the AppDelegate.m

[[CDVBMSPush sharedInstance] didReceiveRemoteNotificationOnLaunchWithLaunchOptions:launchOptions];

then the app starts properly.

Any suggestion to fix the problem please? Thx

joe
  • 2,468
  • 2
  • 12
  • 19
Johan Mereaux
  • 143
  • 11

1 Answers1

0

Just got an answer from the support team:

[[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:

  1. 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];
    }
}
  1. Completely remove that line of code.
Community
  • 1
  • 1
Johan Mereaux
  • 143
  • 11
  • I'm getting a crash that is pointing to this line of code too.. but only when launched via the TestFlight app. The BMS-Push example/setup code has been updated a bit to include a check for nil but I'm still getting the error so have gone for removal of the line. I'll let you know if it works. – TimBrighton Dec 08 '16 at 11:15