katzer / cordova-plugin-local-notifications

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

Local Notification not working #352

Closed ramsabarish closed 9 years ago

ramsabarish commented 9 years ago

I'm using cordova 4.0.0 , ios sdk 7.1

through CLI I added cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git && cordova prepare

Then in config.xml I added gap:plugin name="de.appplant.cordova.plugin.local-notification"

Then in index.js I added

$(document).ready(function(){

              window.plugin.notification.local.hasPermission(function (granted) {
                            console.log('Permission has been granted: ' + granted);
                                                             });

             var now                  = new Date().getTime(),
            _60_seconds_from_now = new Date(now + 60*1000);

           window.plugin.notification.local.add({
            id:      1,
            title:   'Reminder',
           message: 'Dont forget to buy some flowers.',
           repeat:  'weekly',
           date:    _60_seconds_from_now
         });          

After this no error was shown on Xcode , no notification was created and all other functionalities in my app were disabled.

Kindly tell me what error I would have committed or I have missed any steps. I have used many plugins to create local notifications but none them are working..

MichelReij commented 9 years ago

Hi ramsabarish, the problem here is that you do this in the $(document).ready() event handler. The plugin only becomes available after the device ready event is dispatched. So you should move your code to the device.ready handler.

ramsabarish commented 9 years ago

Thanks a lot Michel Reij , my problem is solved .I was struck with this code for past 2 days and i was trying all other plugins . A Big relief to me , Thanks a lot....

MichelReij commented 9 years ago

Great!