Whenever the iOS app (but not Android) receives a push notification, the app crashes.
To recreate the problem:
- Add the ios platform to ionic.
- Add the cordova push notification plugin.
- Build ios and run on device.
- Register device for push notifications. (Registration is successful.)
- Send push notification to device, with absolutely any payload. (See payload in the logs)
- Ionic logs the notification as being received.
- After notification is handled (and specifically, after the execution of method didReceiveRemoteNotification in the AppDelegate+notification.m file), the app crashes. Step debugging does not help as after that method I step through assembly code.
More details:
Initialization
(lldb) command source -s 1 â/tmp/fruitstrap-lldb-prep-cmds-9d544ad7a9d6516d40fbc0f4d2f04d7a7464fb27â
success
2015-08-11 15:34:08.660 MyApp[2299:634883] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/9AC37FBA-AC07-411D-88A1-C82AD977B3B3/Library/Cookies/Cookies.binarycookies
(lldb) 2015-08-11 15:34:09.372 MyApp[2299:634883] Apache Cordova native platform version 3.8.0 is starting.
(lldb) 2015-08-11 15:34:09.373 MyApp[2299:634883] Multi-tasking â Device: YES, App: YES
(lldb) 2015-08-11 15:34:09.388 MyApp[2299:634883] Unlimited access to network resources
(lldb) 2015-08-11 15:34:09.607 MyApp[2299:634883] [CDVTimer][keyboard] 0.727057ms
(lldb) 2015-08-11 15:34:09.954 MyApp[2299:634883] [CDVTimer][splashscreen] 346.632004ms
(lldb) 2015-08-11 15:34:10.002 MyApp[2299:634883] [CDVTimer][file] 47.894001ms
2015-08-11 15:34:10.002 MyApp[2299:634883] [CDVTimer][TotalPluginStartup] 396.166980ms
(lldb) 2015-08-11 15:34:10.247 MyApp[2299:634883] active
(lldb) 2015-08-11 15:34:10.527 MyApp[2299:634883] Resetting plugins due to page load.
(lldb) 2015-08-11 15:34:11.347 MyApp[2299:634883] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/D1C08963-0379-4CFB-B367-063BDD1F46DA/MyApp.app/www/index.html#/landing
(lldb) 2015-08-11 15:34:11.563 MyApp[2299:634883] THREAD WARNING: [âPushPluginâ] took â12.333008â ms. Plugin should use a background thread.
(lldb) 2015-08-11 15:34:11.571 MyApp[2299:634883] enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.
(lldb) 2015-08-11 15:34:11.659 MyApp[2299:634883] Register success 602⌠(deivce token)
Send my empty notification
(lldb) 2015-08-11 15:36:26.038 Swipes[2299:634883] didReceiveNotification
2015-08-11 15:36:26.039 Swipes[2299:634883] Notification received
2015-08-11 15:36:26.040 Swipes[2299:634883] Msg: {foreground:â1â}
(lldb) 2015-08-11 15:36:26.090 Swipes[2299:634883] [{âforegroundâ:â1â}]
2015-08-11 15:36:26.091 Swipes[2299:634883] {âforegroundâ:â1â}
(lldb) 2015-08-11 15:36:26.197 Swipes[2299:634883] THREAD WARNING: [âNotificationâ] took â105.516846â ms. Plugin should use a background thread.
(lldb) 2015-08-11 15:36:26.222 Swipes[2299:634883] -[__NSDictionaryI length]: unrecognized selector sent to instance 0x17dc92a0
(lldb) 2015-08-11 15:36:26.225 Swipes[2299:634883] *** Terminating app due to uncaught exception âNSInvalidArgumentExceptionâ, reason: â-[__NSDictionaryI length]: unrecognized selector sent to instance 0x17dc92a0â
*** First throw call stack:
(0x255a3fef 0x33f0d(lldb) c8b 0x255a9409 0x255a7327 0x254d6e78 0x28f59d33 0x28f59e67 0x28d0bf01 0x2625c3b5 0x2625bd83 0x2625bb1f 0x26267aa9 0x28d0d225 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28ecc5af 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df(lldb) 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0b881 0x2625b755 0x28c30d35 0x29094815 0x28ef803d 0x28c9ba41 0x28c1633f 0x25569fed 0x255676ab 0x25567ab3 0x254b4201 0x254b4013 0x2cf3f201 0x28c80a09 0xa5deb 0x344bfaaf)
(lldb) libc++abi.dylib: (lldb) terminating with uncaught exception of type NSException
(lldb) Process 2299 stopped
- thread #1: tid = 0x9b003, 0x34589df0 libsystem_kernel.dylib
__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x34589df0 libsystem_kernel.dylib
__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
â 0x34589df0 <+8>: blo 0x34589e08 ; <+32>
0x34589df4 <+12>: ldr r12, [pc, #0x4] ; <+24>
0x34589df8 <+16>: ldr r12, [pc, r12]
0x34589dfc <+20>: b 0x34589e04 ; <+28>
(lldb)
Send my notification with a body
(lldb) 2015-08-11 15:41:12.267 Swipes[2330:637508] didReceiveNotification
2015-08-11 15:41:12.268 Swipes[2330:637508] Notification received
2015-08-11 15:41:12.270 Swipes[2330:637508] Msg: {"sonhere":"yo",foreground:"1"}
(lldb) 2015-08-11 15:41:12.290 Swipes[2330:637508] [{"sonhere":"yo","foreground":"1"}]
2015-08-11 15:41:12.291 Swipes[2330:637508] {"sonhere":"yo","foreground":"1"}
(lldb) 2015-08-11 15:41:12.383 Swipes[2330:637508] THREAD WARNING: ['Notification'] took '91.395752' ms. Plugin should use a background thread.
(lldb) 2015-08-11 15:41:12.411 Swipes[2330:637508] -[__NSDictionaryI length]: unrecognized selector sent to instance 0x156be200
(lldb) 2015-08-11 15:41:12.414 Swipes[2330:637508] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0x156be200'
*** First throw call stack:
(0x255a3fef 0x33f0d(lldb) c8b 0x255a9409 0x255a7327 0x254d6e78 0x28f59d33 0x28f59e67 0x28d0bf01 0x2625c3b5 0x2625bd83 0x2625bb1f 0x26267aa9 0x28d0d225 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28ecc5af 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df(lldb) 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0d18b 0x2625b755 0x28d0d0ad 0x28c1d3df 0x28d0b881 0x2625b755 0x28c30d35 0x29094815 0x28ef803d 0x28c9ba41 0x28c1633f 0x25569fed 0x255676ab 0x25567ab3 0x254b4201 0x(lldb) 254b4013 0x2cf3f201 0x28c80a09 0xa6deb 0x344bfaaf)
(lldb) libc++abi.dylib: (lldb) terminating with uncaught exception of type NSException
(lldb) Process 2330 stopped
* thread #1: tid = 0x9ba44, 0x34589df0 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x34589df0 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x34589df0 <+8>: blo 0x34589e08 ; <+32>
0x34589df4 <+12>: ldr r12, [pc, #0x4] ; <+24>
0x34589df8 <+16>: ldr r12, [pc, r12]
0x34589dfc <+20>: b 0x34589e04 ; <+28>
(lldb)
I really dug deep in the iOS code here and could not figure out the problem. Anyone else experiencing this?