katzer / cordova-plugin-local-notifications

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

Allow to manually execute deviceready event #1444

Closed gregd closed 6 years ago

gregd commented 6 years ago

Ionic 3 has lazy loading which seems to break Cordova deviceready callback order. I posted the bug here https://github.com/ionic-team/ionic/issues/13525 It seems that Ionic platform.ready().then(() => { ... } is called after LocalNotifications deviceready callback. It would be good to have a work around to manually trigger below code from platform.ready().then(...) callback.

// Called after 'deviceready' event
channel.deviceready.subscribe(function () {
    // Device is ready now, the listeners are registered
    // and all queued events can be executed.
    exec(null, null, 'LocalNotification', 'deviceready', []);
});

I guess this can be done with plugin configuration option and with new LocalNotification method. The method should be called after event handlers like click are registered.

Your Environment

Steps to Reproduce

Described here https://github.com/ionic-team/ionic/issues/13525

katzer commented 6 years ago

In future its possible by defining skipLocalNotificationReady.

window.skipLocalNotificationReady = true

Once the app and Ionic is ready, you can fire the queued events manually.

cordova.plugins.notification.local.fireQueuedEvents();
rapoell commented 6 years ago

Hi Sebastián,

I used the version with the commit of Feb 5 (using skipLocalNotificationReady and fireQueuedEvents()) in iOS 11.2 simulator and iOS 10.3.3 on a physical device (iPhone5 ). In both cases when I start the app from a notification, the startup screen appears and then, after a second or so, the screen turns black, the app crashes apparently. After approx. 10 seconds the screen returns to one of the home/app pages of iOS from where I selected the notification. It doesn't matter if I call the related code or comment them, the behavior is identical. Reverting to 0.9.0-beta.2 solves the black-screen issue.

Any idea where this might come from?

katzer commented 6 years ago

@rapoell Yes I experienced that and its already fixed with beta.3

rapoell commented 6 years ago

@katzer Hi Sebastián, thanks, I'll test the new version in the next couple of days.