katzer / cordova-plugin-local-notifications

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

Crash: [__NSCFString stringValue]: unrecognized selector sent to instance #281

Closed orbitaloop closed 9 years ago

orbitaloop commented 10 years ago

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:

Is it a good change? Or am I a completely wrong? I am about to release this code to Apple.. Thanks for your feedback

MichelReij commented 10 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!!!

mgcrea commented 10 years ago

:+1:

Tawpie commented 10 years ago

encountered the same problem... recommend a pull request!

thedumbterminal commented 10 years ago

Added the above PR for this ^^^

ewang commented 10 years ago

Seems to be caused by the change made in #200

joel-caton commented 9 years ago

OrbitalLoop your patch made this plugin usable. Thanks for sharing!!

ejensler commented 9 years ago

+1 to OrbitalLoop's fix. Thanks!

CyberFerret commented 9 years ago

Really useful fix! Thanks. Works like a charm now.

romil-choksi commented 9 years ago

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.

katzer commented 9 years ago

The new 0.8.x release is a complete rewrite. If the issue still exists please reopen it.

You may also take a look into the new wiki.

Thanks!