Cordova-plugin-local-notifications: [iOS] Not compatible with phonegap-plugin-push

Created on 4 Jun 2017  路  30Comments  路  Source: katzer/cordova-plugin-local-notifications

Some conflict between cordova-plugin-local-notifications and phonegap-plugin-push

Your Environment

  • Plugin version: 0.8.5
  • Platform: iOS
  • OS version: 10.3
  • Device manufacturer / model: iPhone 5s
  • Cordova version: 7.0.1
  • Cordova platform version: cordova-ios 4.4.0
  • Plugin config: any

Expected Behavior

cordova-plugin-local-notifications and phonegap-plugin-push should work well together when app is on foreground, background or closed.

Actual Behavior

When I use cordova-plugin-local-notifications and phonegap-plugin-push, onNotification event from phonegap-plugin-push never is called, except if the app is closed (the event is called when app open).
Push notification not arrives when app is on foreground or background.

Steps to Reproduce

  1. Install the plugins in an app
  2. Send push notification
  3. Push only arrives when the application is closed and you open it.
bug question

All 30 comments

This appears to be a similar issue as #1049 and #1106. Since its been open for many months, I can't see it being fixed on this branch. Other people have reported they have these plugins working together.

I've done a lot of testing and when both plugins are installed, push notifications only arrive if the app is closed, when it is opened. In another case, the onNotification event is not called.

I guess when the app is open (in the foreground or background) and the local notifications plugin is loaded, push notifications stop working.

There appears to be a conflict between the two plugins competing for the same hooks AFAIK.

I am also facing the same problem. No difference in plugin and environment. We are stuck due to this bug. Anyone can provide any insights on how to resolve this?

Thanks,
Kanak

Can anyone please provide any solution?
Did you find anything? @alfonsocmm

Also, click event is also not getting fired when clicking on local notification.

Facing the same issue... Local notification not at all compatible with phonegap push plugin..
Does anyone have any solution for it?

we use this plugin for local and phonegap plugin push for push and because both are imperfect and I don't have time to fix them we had to accept a couple of truths鈥攁nd develop workarounds:

1) push notifications are never guaranteed to be delivered, particularly at any specific time. Yes, they do usually get there, but there is no guarantee. So we implemented a "backup" and our app also "pulls" the message from our server when it's in the foreground. As such, the push message may not call onNotification while we're in the foreground, but it doesn't make much difference because the next check with our servers we grab the message ourselves. Correct, we've masked the fact that the plugins may not be working鈥攁t least in the case where the app is in the foreground. But we've also covered the instance where a push message wasn't ever received (or sent, that does happen sometimes inexplicably).

2) local notifications are "supposed" to call onClick or onTrigger when clicked/triggered鈥攂ut because of various challenges with both the plugin and with the various operating systems, we decided to keep a local copy of the notifications that were supposed to fire. If our app starts up and does so without calling onClick or onTrigger, we check the "expected" list of local notifications and present the most recent one. In this way we also mask problems with the plugin... which isn't the best perhaps but since we don't have the time to fix the plugin and we can't wait until "somebody else" has the time, it does make our app function.

So what we ended up with is performance-to-expectation when you click on a notification (both push and local all show up in the notification pull down), and while a push message may not have been actually "pushed" to the foreground app, the user still saw the message because we pulled it manually. Yes, it's a a few minutes late but fortunately we're not doing anything particularly time critical... and besides, a push message can arrive a few minutes late even with all plugins working properly.

If it were me, I'd back (with money) an effort at Apache itself to build an official unified plugin for notifications in general鈥攍ike file and device and vibration and camera and blah and so on. Notifications are on every device and with the OS vendors aggressively changing their systems I understand why an individual (Katzer) and organization (phonegap) can't keep up. Perhaps Apache's larger resource pool could step in!

BTW, I haven't looked at phonegap-plugin-push in a very long time but I don't think it'll call onNotification when a push message _arrives_鈥攐nly when the user clicks the notification in the notification shade. But that's something for the phonegap-plugin-push issues board eh?

@Tawpie

Wow, we both seem to have implemented a similar architecture. We don't use the push plugin, we use PushWoosh, and we don't actually have dual running issues.

However your points on stuff not arriving on time, pulling notifications from a server, when we start up, checking the local list of notifications are all what we are doing.

Your point on Apache is interesting as well.

Rob

I have not found any solution yet. I am waiting for next plugin version.

I have the same issue in Android, using the master branch as of today

After the last update of this plugin (2.0.0), my app works ok with local and push notifications on Android and iOS.

  • cordova-plugin-local-notifications version: 2.0.0
  • cordova-plugin-local-notifications version: 0.8.5

@alfonsocmm , which version of phonegap-plugin-push are you using ?

I correct my previous post:

  • phonegap-plugin-push version: 2.0.0
  • cordova-plugin-local-notifications version: 0.8.5

Thanks @alfonsocmm. I have abandoned this approach as there is no way to keep track of the Badge count when I use both the plugins together. I have an open issue about this if you have dealt with the Badge problem.

@alfonsocmm, I have same your plugin version:
phonegap-plugin-push version: 2.0.0
cordova-plugin-local-notifications version: 0.8.5
builded into Xcode9 and only on IOS > 10 plugin-push when app is in foreground doesn't call on('notification') and the notification si displayed as native banner
All the others situation runs as expecetd..
The problem is that local-notification takes over the didReceiveNotification method.

With the newest update master the plugin will not handle delegates triggered by push notifications. That should also fix any interferences with OneSignal.

@katzer Hi, I am facing same problem when local-notification is interfering with push notification onNotification event. It's killing my job, I have to use both plugins in my app. Can you please let me know what is fix for this ?

@katzer I have installed cordova-plugin-local-notifications 0.9.0-beta.0 and now push notifications arrives only when app is closed. When App is in foreground or in background no notifications arrives.. and also
the Local notifications doesn't run.

Platform and Version
iPhone 5s iOS 10
iPhone 8p iOS 11

Cordova CLI version and cordova platform version
Cordova-iOS 4.5.1
Push-plugin 2.0.0
cordova-plugin-local-notifications 0.9.0-beta.0
APNs notification system

Have I to open a new issue?

@debe78 With v0.9-beta.1, the plugin ignores system callbacks triggered by push notifications.

If the app is running (in foreground) the plugin only fires the trigger event except you schedule notifications with foreground: true.

@katzer I tried with v0.9-beta.1 but when the App is in foreground I continue to not receive the push notifications.

With v0.9-beta, the plugin __ignores__ system callbacks triggered by __push notifications__.

@katzer I understand and belive you, but it's a fact with the local-notification plugin I not receive the push notifications when App is in foreground, without local-notification plugin I receive it.
So the two plugins are incompatible on IOS devices.

When looking to their code the reason I can imagine is that they still use the deprecated API while my plugin uses the new API. Possibly that the OS does not schedule callbacks for the old API if another part of the app has registered for callbacks for the new API.

Is there a way to quick fix this issue? I'm facing the same thing.

I can confirm that the 0.9.0-beta.1 running with [email protected] still conflict. Without cordova-plugin-local-notifications I receive notification events. When I install cordova-plugin-local-notifications I no longer receive these events.

Interestingly, I attempted to receive the notification events by registering for the cordova-plugin-local-notifications "click" event instead, but this didn't work. I assume because as @katzer mentioned, the plugin now ignores system callbacks triggered by push notifications.

@katzer: If there is some way I can help (testing different scenarios, for example), I would be willing to invest some time into solving this issue.

The blocker reason is because iOS supports 2 APIs for now. The deprecated API and the new user-notifications API since iOS 10+ however the OS does not allow to use them both together in one app.

The local-notification plugin uses the new API while the push plugin uses the deprecated API. With the result, that the OS only triggers callbacks for the new API.

The push plugin has to move to the new API for iOS 10+ otherwise the plugins cannot work side by side.

@katzer Even with the new release (2.0)? They're still using the deprecated API?

Hi,

I am faceing with same issue - phonegapp-push-plugin not fired with IOS, function on notification ( in android it does ).
Any news about this issue ?

Thank you,
Adi Damty

@adidamty I think the reason is written down already. However I dont see a away my plugin can fix it. The code now also handles the situation if multiple classes want to listen for the delegate. The rest should be done by the push plugin to upgrade to the new API. As long as its not the case I cannot help here.

Was this page helpful?
0 / 5 - 0 ratings