Current behavior:
We're using cordova-plugin-local-notifications and cordova-plugin-firebasex plugins in our ionic 3 project. When iOS app is in foreground and scheduled local notification should appear it throws
error "FirebasePlugin[native]: willPresentNotification: aborting as not a supported UNNotificationTrigger" instead
I've created minimal ionic 3 project here https://github.com/AndrewBargan/firebasexAndLocalNotificationsBug
Take a look at src/pages/home/home.ts for code that causes problem.
Expected behavior:
Subscription handlers to both firebasex and local notificaitons work simultaneously.
Steps to reproduce:
When app from repository mentioned above built and installed on a real device:
In 3 seconds error is thrown to console:
"FirebasePlugin[native]: willPresentNotification: aborting as not a supported UNNotificationTrigger"
To reproduce this bug again you need to remove platform and add plugins once again and rebuild the project. For this:
Keep in mind you have to put valid GoogleService-Info.plist into the root of the project to make app work.
Environment information
Cordova platform version
ios 5.0.1
Available platforms:
android ^8.0.0
browser ^6.0.0
electron ^1.0.0
osx ^5.0.0
windows ^7.0.0
Plugins & versions installed in project
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-firebasex 7.0.1 "Google Firebase Plugin"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
Dev machine: macOS 10.15.1
Device details: iPhone SE, iOS 13.2.2
XCode v11.2.1
BTW: Found issue that looks similar: https://github.com/dpa99c/cordova-plugin-firebasex/issues/95
If it is maybe a good idea to pull from fork of this plugin with the fix that Fabricio Garcia did to the current one.
The problem is that both this plugin and cordova-plugin-local-notifications
implements the same UNUserNotificationCenterDelegate willPresentNotification
delegate and since delegates have a 1:1 relationship with their parent class, only one of the delegates is being called - in this case, the cordova-plugin-firebasex
delegate in response to the notification created by cordova-plugin-local-notifications
.
cordova-plugin-firebasex
is correctly ignoring a notification which it didn't create so doesn't know how to present (aborting as not a supported UNNotificationTrigger
) however the cordova-plugin-local-notifications
delegate is not being called because only 1 delegate was invoked, hence you don't get a notification.
This is a conflict between the two plugins (see this SO post for further info about multiple delegates) .
In a native iOS app, you'd simply combine both into a single delegate however due to the nature of Cordova plugins, this isn't a feasible solution.
The best solution would be implement a common shared delegate which broadcast an event which both plugins could add observers for, meaning both plugins would receive the notification event.
However this would require a rework of both plugins and coordination to create/use/maintain such a common component.
Therefore this isn't something that's an easy bugfix and I'm unlikely to attempt to fix this in the near future.
I deem this to be a caveat of using this plugin rather than a bug with it since it functions correctly in isolation and only encounters an issue when another plugin is introduced which makes use of the same native delegates.
FYI I see no commits in the repo in the issue you referenced but please feel free to point out if I have missed that particular piece of code.
Hey @dpa99c,
Thanks for you quick answer!
That's sad. At least good to mention this caveat in the docs that this plugin isn't working in conjunction with local notifications plugin.
Thanks!
Have a good day!
Related to this in #443: I believe to resolve this issue, both this plugin and cordova-plugin-local-notification
will need to take a different approach to register for app delegate events so they don't conflict.
A possible solution is to extend cordova-plugin-app-event to support the necessary delegates that both plugins can share which should resolve their conflict.
I will investigate the viability of this solution.
I will investigate the viability of this solution.
Hi @dpa99c !
The problem is the same with release 11.0.1-cli.
"FirebasePlugin[native]: willPresentNotification: aborting as not a supported UNNotificationTrigger"
Could you give me advice how to use it, with cordova-plugin-local-notification plugin ?
Thanks!
@golyo due to the nature of the conflict between this plugin and cordova-plugin-local-notification
(both implementing a global delegate method that must be unique) there is no easy solution.
Either you'd need to manually rewrite the native iOS implementation to merge the two implementations or implement an interstitial handler such as I've described above. This is a viable approach but will take considerable effort and also will require changes to both this plugin and cordova-plugin-local-notification
to make it work.
I am using https://github.com/katzer/cordova-plugin-local-notifications version: 0.9.0-beta.3 and https://github.com/wizpanda/cordova-plugin-firebase-lib version: 5.1.1 both are working on iOS. I can fire off background/foreground local and remote notifications.
@dpa99c
I haven't been able to figure out the difference between firebase-lib and your plugin other than the lib is using fabric still. Do you happen to know what it is?
Looking at the code in the cordova-local-notification I noticed UNUserNotificationCenter is a singleton and that in must be initialized prior to this plugin via the local notifications plugin, so i created a PR holding previous instance if exists and using it if notification not supported. This behaviour actually seems existent in that plugin (just with instances and not as static).
Forgive my obj-c :P , feel free to improve.
Most helpful comment
Related to this in #443: I believe to resolve this issue, both this plugin and
cordova-plugin-local-notification
will need to take a different approach to register for app delegate events so they don't conflict.A possible solution is to extend cordova-plugin-app-event to support the necessary delegates that both plugins can share which should resolve their conflict.
I will investigate the viability of this solution.