OneSignal-Cordova-SDK icon indicating copy to clipboard operation
OneSignal-Cordova-SDK copied to clipboard

Terminating app due to uncaught exception 'NSRangeException'

Open djbanana1 opened this issue 3 years ago • 2 comments

Description: We were using "onesignal-cordova-plugin": "2.11.4" & "@awesome-cordova-plugins/onesignal": "5.44.0" in our ionic app and we had to update it to the latest v3.1.1 because of the android api level 31.

After the update, we are not able to launch the app on an Ios device. The app starts and then gets stuck on the init and xcode throws an errror (see end for console output) and points to the OneSignalPush file marking this:

image

Environment "@ionic/angular": "6.2.2", "@angular/cdk": "14.1.2", "onesignal-cordova-plugin": "3.1.1",

Steps to Reproduce Issue:

  1. Update the onesignal-cordova-plugin from v2.11.4 to v3.1.1
  2. Remove @awesome-cordova-plugins/onesignal
  3. Deploy the app on a real Ios device, using xcode

Anything else:

2022-08-23 15:54:14.895364+0200 My App[456:31292] Apache Cordova native platform version 6.2.0 is starting.
2022-08-23 15:54:14.895511+0200 My App[456:31292] Multi-tasking -> Device: YES, App: YES
2022-08-23 15:54:14.913167+0200 My App[456:31292] CDVWKWebViewEngine: trying to inject XHR polyfill
2022-08-23 15:54:14.913777+0200 My App[456:31292] The preference key "AutoInjectCordova" is not defined and will default to "FALSE"
2022-08-23 15:54:14.913856+0200 My App[456:31292] The preference key "AudioCanMix" is not defined and will default to "FALSE"
2022-08-23 15:54:14.924655+0200 My App[456:31292] The preference key "WKSuspendInBackground" is not defined and will default to "TRUE"
2022-08-23 15:54:14.924773+0200 My App[456:31292] The preference key "MediaPlaybackAllowsAirPlay" is not defined and will default to "TRUE"
2022-08-23 15:54:15.143720+0200 My App[456:31292] The preference key "KeyboardAppearanceDark" is not defined and will default to "FALSE"
2022-08-23 15:54:15.144003+0200 My App[456:31292] The preference key "AllowLinkPreview" is not defined and will default to "FALSE"
2022-08-23 15:54:15.144099+0200 My App[456:31292] The preference key "AllowBackForwardNavigationGestures" is not defined and will default to "FALSE"
2022-08-23 15:54:15.144142+0200 My App[456:31292] CDVWKWebViewEngine will reload WKWebView if required on resume
2022-08-23 15:54:15.144220+0200 My App[456:31292] Using Ionic WKWebView
2022-08-23 15:54:15.144599+0200 My App[456:31292] [CDVTimer][console] 0.090957ms
2022-08-23 15:54:15.144730+0200 My App[456:31292] [CDVTimer][handleopenurl] 0.045061ms
2022-08-23 15:54:15.147019+0200 My App[456:31292] [CDVTimer][intentandnavigationfilter] 2.188921ms
2022-08-23 15:54:15.147215+0200 My App[456:31292] [CDVTimer][gesturehandler] 0.078917ms
2022-08-23 15:54:15.147318+0200 My App[456:31292] [CDVTimer][inappbrowser] 0.051022ms
2022-08-23 15:54:15.149265+0200 My App[456:31292] [CDVTimer][statusbar] 1.852989ms
2022-08-23 15:54:15.149437+0200 My App[456:31292] [CDVTimer][socialsharing] 0.056028ms
2022-08-23 15:54:15.151539+0200 My App[456:31292] [CDVTimer][diagnostic] 2.045035ms
2022-08-23 15:54:15.152881+0200 My App[456:31292] [CDVTimer][diagnostic_location] 1.245975ms
2022-08-23 15:54:15.153000+0200 My App[456:31292] [CDVTimer][diagnostic_bluetooth] 0.054002ms
2022-08-23 15:54:15.153070+0200 My App[456:31292] [CDVTimer][diagnostic_wifi] 0.023007ms
2022-08-23 15:54:15.153153+0200 My App[456:31292] [CDVTimer][diagnostic_camera] 0.040054ms
2022-08-23 15:54:15.153380+0200 My App[456:31292] [CDVTimer][diagnostic_notifications] 0.064969ms
2022-08-23 15:54:15.153586+0200 My App[456:31292] [CDVTimer][diagnostic_microphone] 0.043988ms
2022-08-23 15:54:15.216642+0200 My App[456:31292] [CDVTimer][diagnostic_contacts] 62.883019ms
2022-08-23 15:54:15.216849+0200 My App[456:31292] [CDVTimer][diagnostic_calendar] 0.089049ms
2022-08-23 15:54:15.216957+0200 My App[456:31292] [CDVTimer][diagnostic_reminders] 0.056982ms
2022-08-23 15:54:15.217216+0200 My App[456:31292] [CDVTimer][diagnostic_motion] 0.211000ms
2022-08-23 15:54:15.217314+0200 My App[456:31292] [CDVTimer][ionicdeeplinkplugin] 0.046968ms
2022-08-23 15:54:15.217362+0200 My App[456:31292] [CDVTimer][TotalPluginStartup] 72.939992ms
2022-08-23 15:54:15.303257+0200 My App[456:31292] WF: === Starting WebFilter logging for process My App
2022-08-23 15:54:15.303327+0200 My App[456:31292] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2022-08-23 15:54:15.303381+0200 My App[456:31292] WF: _WebFilterIsActive returning: NO
2022-08-23 15:54:15.518370+0200 My App[456:31554] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2022-08-23 15:54:15.518623+0200 My App[456:31554] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2022-08-23 15:54:15.749388+0200 My App[456:31292] IAB.close() called but it was already closed.
2022-08-23 15:54:15.813123+0200 My App[456:31555] [connection] nw_endpoint_handler_set_adaptive_read_handler [C1.1 104.18.225.52:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for read_timeout failed
2022-08-23 15:54:15.816531+0200 My App[456:31555] [connection] nw_endpoint_handler_set_adaptive_write_handler [C1.1 104.18.225.52:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
2022-08-23 15:54:15.924742+0200 My App[456:31555] Request <OSRequestRegisterUser: 0x2807f91a0> success result {
    id = "467053ca-7544-41cb-8487-03385aafc0da";
    success = 1;
}
2022-08-23 15:54:17.140687+0200 My App[456:31292] Ionic Native: deviceready event fired after 754 ms
2022-08-23 15:54:17.515414+0200 My App[456:31292] Angular is running in development mode. Call enableProdMode() to enable production mode.
2022-08-23 15:54:17.520430+0200 My App[456:31292] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x183c2325c 0x1979b8480 0x183c8eab4 0x183b1a994 0x100aa8f40 0x100b199e8 0x10098e0e8 0x10098df9c 0x10098fd04 0x18f895d04 0x18fa921e8 0x18fceda9c 0x18fced180 0x18f68fd90 0x18f9e2060 0x18f6721b4 0x18f671ac8 0x18d71b038 0x18d71be30 0x183ba28a8 0x183ba27a8 0x183ba1afc 0x183b9c018 0x183b9b7d0 0x19a2dd570 0x1864c82d0 0x1864cd84c 0x10095b698 0x18387a140)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException
(lldb)  

djbanana1 avatar Aug 23 '22 14:08 djbanana1

@djbanana1 It looks like the SDK was not updated since that is outdated code for OneSignalPush. The init method should look like this now. Does this work properly when uninstalling first before updating to the new version of the app?

- (void)init:(CDVInvokedUrlCommand*)command {
    _receivedNotificationCache = [NSMutableDictionary new];
    _notificationCompletionCache = [NSMutableDictionary new];;

    pluginCommandDelegate = self.commandDelegate;

    NSString* appId = (NSString*)command.arguments[0];
    initOneSignalObject(nil, [appId UTF8String]);

    if (actionNotification)
        processNotificationOpened(actionNotification);
}

emawby avatar Aug 25 '22 17:08 emawby

@emawby Thanks for your response. Nope, i still receive the same error. I already tried reinstalling the node_modules, clearing the platforms (for the ionic build) and clearing the xcode caches for the local build.

How can i update the SDK?

djbanana1 avatar Aug 26 '22 08:08 djbanana1

Hi @djbanana1, just checking in--is this still an issue for you?

If you have not yet been able to update to the latest SDK, you can do so by running:

cordova plugin rm onesignal-cordova-plugin
cordova plugin add onesignal-cordova-plugin --save

You may also want to clear Xcode DerivedData to prevent any issues caused by cached build files:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

Let us know if that helps and/or if you are still experiencing difficulty.

Thanks!

jennantilla avatar Mar 20 '23 20:03 jennantilla