katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.75k forks source link

scheduling local notification causes crash #510

Closed fvdave closed 9 years ago

fvdave commented 9 years ago

Trying to schedule a local notification causes a crash with the following message:

2015-04-11 16:05:21.338 Doggy MD[1126:3183066] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x145354c0
2015-04-11 16:05:21.340 Doggy MD[1126:3183066] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x145354c0'
*** First throw call stack:
a7 0x36dc5c77 0x291e4a6d 0x291e2949 0x29113b68 0xfd2f9 0xfa903 0xfa485 0xf7997 0x37330c83 0x3733d86b 0x3733e8a3 0x374b1da9 0x374b1afc)
libc++abi.dylib: terminating with uncaught exception of type NSException
Process 1126 stopped
* thread #7: tid = 0x3091da, 0x37434df0 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
    frame #0: 0x37434df0 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill + 8:
-> 0x37434df0:  blo    0x37434e08                ; __pthread_kill + 32
   0x37434df4:  ldr    r12, [pc, #4]             ; __pthread_kill + 24
   0x37434df8:  ldr    r12, [pc, r12]
   0x37434dfc:  b      0x37434e04                ; __pthread_kill + 28

This is the code I'm using:

Scheduler.notificationPlugin.local.schedule({
            id: 1,
            title: "Notification Test",
            text: "Look at me!",
            at: new Date().getTime() + (10 * 1000)
        });

Even passing an empty object causes a crash. The version of the plugin I'm using is 0.8.1, iOS version 8.2, and cordova version 4.2.0.

katzer commented 9 years ago

Tried out your example but cannot reproduce. Maybe you can debug with xcode whats the reason.

fvdave commented 9 years ago

Ok I did some testing today. I had two notifications scheduled, these are the ids: [0,"1"] That first one being a number seems to be the issue; I altered UIApplication+APPLocalNotification.m to convert the id to a string as follows:

- (UILocalNotification*) localNotificationWithId:(NSString*)id
{
    NSArray* notifications = self.localNotifications;

    for (UILocalNotification* notification in notifications)
    {
        if ([[NSString stringWithFormat: @"%@", notification.options.id] isEqualToString:id]) {
            return notification;
        }
    }

    return NULL;
}
joeydi commented 9 years ago

This fix was never merged into master?