Provide a general summary of the issue.
cordova -v): 7.1.0cordova platform ls): ios 4.4.0Action always works.
Action doesn't work if app is first installed.
Actually I already know what is going on. This plugin is in conflict with cordova-plugin-firebase at least version 0.1.24. Both are trying to be delegate for UNUserNotificationCenter. But only one can be at a time. Launching with a fresh install, perhaps I let Firebase ask for permission first, and this plugin lose the delegate status for UNUserNotificationCenter. Subsequent launches do ensure this plugin is the delegate.
This is actually a tricky issue. I don't know what should really be done in this case. Maybe two plugin should actually be a single plugin?
None necessary.
This problem is also observed with phonegap push plugin
For the moment since I only uses actions for local notifications, I changed APPLocalNotification.m so that it will always reclaim as the delegate when scheduling a notification event. Obviously this is not really satisfactory but it works for my purpose.
- (void) schedule:(CDVInvokedUrlCommand*)command
{
NSArray* notifications = command.arguments;
// Add the following hack:
UNUserNotificationCenter.currentNotificationCenter.delegate = self;
. . .
}
@t2wu Your solution is working well for me. Could you explain why you think it's not satisfactory?
@awanishraj It wrestles the control away from the remote notification plugin. So actions for remote notification and local notification cannot work at the same time unless you hack some more. What I think really should happen is there should be a third plugin which handles these events and emits them to both the remote notification and the local notification plugins.
I am seeing similar things between iBeacon and Geofencing plugins. I believe these plugins are broken by design.
I also found one solution...run this once window.FirebasePlugin.grantPermission(); after installation of app but for that instance local notification wont work...after that dont run this command again and both of them will start working
I hope this change might help to improve the situation where multiple classes would like to listen for the same delegate.
https://github.com/katzer/cordova-plugin-local-notifications/commit/641ff31a67236fd1db5add911d8fae2047552925
Oh that's a clever method. I finally understand what it does. So notification.request is different between the local notification and the remote ones. It will work as long as it is this plugin that has the control.
Most helpful comment
I hope this change might help to improve the situation where multiple classes would like to listen for the same delegate.
https://github.com/katzer/cordova-plugin-local-notifications/commit/641ff31a67236fd1db5add911d8fae2047552925