Closed orbitaloop closed 9 years ago
Hi Orbitaloop, I had the same problem you had. I discovered it yesterday after upgrading to Cordova 3.6 and updating all plug-ins including the local-notifications plug-in. I implemented your code above and it seems to do the trick for me too. Thanks!!!
:+1:
encountered the same problem... recommend a pull request!
Added the above PR for this ^^^
Seems to be caused by the change made in #200
OrbitalLoop your patch made this plugin usable. Thanks for sharing!!
+1 to OrbitalLoop's fix. Thanks!
Really useful fix! Thanks. Works like a charm now.
I am using this plugin and trying to trigger local notification for my Cordova iOS app with Local notifications plugin.
I dd following steps:
Installed plugin: cordova plugin add de.appplant.cordova.plugin.local-notification@0.7.7
Updated config.xml: gap:plugin name="de.appplant.cordova.plugin.local-notification"
Added the following JavaScript in head tag for
index.html
plugin.notification.local.promptForPermission(function (granted) { alert("promptForPermission: "+granted); });
plugin.notification.local.hasPermission(function (granted) { alert("hasPermission: "+granted); }); Have a button in index.html to create a local notification after 5 secs. Code for that looks like this:
function setLocalNotification() { alert("from setLocalNotification"); var t = new Date(); t.setSeconds(t.getSeconds() + 3);
window.plugin.notification.local.add({ title: 'Scheduled with delay', message: 'Test Message ', date: t });
alert("alert set"); }; I do see a prompt for user's permission and the alert from hasPermission method shows the value as true. But I am still not able to get the actual local notification I am trying to set by clicking a button. I have already updated the APPLocalNotification.m file for the this issue by copying this fix.
I don't see any more errors in the console log but I am still not able to trigger a local notification. Both of the javascript alerts in setLocalNotification method are executed and shown. Please help how can I get this working.
I have a crash when there is existing LocalNotifications (previously scheduled with a previous version?).
_[__NSCFString stringValue]: unrecognized selector sent to instance (in notificationWithId method) _
I am a newbie in Objective C, but it looks like it's because the method is calling stringValue on an object that is already a string.
So I added this changed in bold:
(UILocalNotification) notificationWithId:(NSString)id { NSArray* notifications = self.scheduledNotifications;
for (UILocalNotification* notification in notifications) {
NSString* notId = NULL; if ([[notification.userInfo objectForKey:@"id"] isKindOfClass:[NSString class]] ) { notId = [notification.userInfo objectForKey:@"id"]; } else { notId = [[notification.userInfo objectForKey:@"id"] stringValue]; }**
Is it a good change? Or am I a completely wrong? I am about to release this code to Apple.. Thanks for your feedback