phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.92k forks source link

After some period of time Push Notifications just stop working (iOS) (APNS) #2341

Open joshstrange opened 6 years ago

joshstrange commented 6 years ago

Expected Behaviour

After initial register we can always send push notifications to the device

Actual Behaviour

After some period of time the notifications just stop working even though they are accepted by the APNS gateway.

Reproduce Scenario (including but not limited to)

I really wish I had more information here and we are attempting to reproduce again (we have seen it in the field a couple of times as well)

Steps to Reproduce

See above

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

11.4 (15F5049c) (beta)

Cordova CLI version and cordova platform version

Cordova version: 8.0.0 Installed platforms: android 6.4.0 ios 4.5.3

Plugin version

phonegap-plugin-push 2.1.1 "PushPlugin"

Sample Push Data Payload

{"aps":{"alert":"Test","badge":1,"sound":"default"}}

Sample Code that illustrates the problem

N/A

Logs taken while reproducing problem

N/A

macdonst commented 6 years ago

@joshstrange are you only seeing this on iOS 11.4 beta?

joshstrange commented 6 years ago

I’ve not seen it on my personal phone but I regularly reinstall the app (which in effect logs my out and back into our app) so I’m not sure if I would see it. The reports from the field are from people I am assuming are not using the beta.

macdonst commented 6 years ago

@joshstrange okay, it's just that you mentioned iOS 11.4 beta as the platform you were seeing it in so I wanted to clarify.

Without more info I'm not sure what to suggest to you at this point. iOS takes care of pretty much everything when the app is in the background or closed so I'm not sure why you aren't seeing the notifications.

vvicho commented 6 years ago

This is happening to me too on Android 8.0 and iOS 11.3. To fix it I have to call the push.on('register'..) again. Is there any other workaround/fix?

fredgalvao commented 6 years ago

@vvicho By "call ... again" do you mean on the same app lifecycle? Or sometime later when the user opens your app again?

For example, you should never have to do the following, unless you call unregister inbetween:

vvicho commented 6 years ago

@fredgalvao I currently call the register when I login to the app. So "call ... again" means logout, then login again. The register method is then called since our Notification Service pulls the email the user used to login.

fredgalvao commented 6 years ago

@vvicho And I expect you to call unregister when your user logs out in that case. I'm not entirely sure though if unregistering will be enough to guarantee a new registrationId.

vvicho commented 6 years ago

@fredgalvao yep, but the actual problem is that after some time, I still get the notification when the app is in background, but the webview is not receiving the payload or notification data, not even when the app is on foreground.

dbowmanDT commented 6 years ago

I am also having this problem. At some point rerunning the init and setting up the on('notitification'...) will allow the app to hear the push notifications again. I added some code to do this on the deviceready event (every time the app starts up) and it has been around 12 hours this time since the app stopped listening to push notifications. I am running iOS 11.4

fredgalvao commented 6 years ago

@dbowmanDT @vvicho Could you guys (help) create some reproduction scenario to that?

@vvicho On the following scenario I still get the notification when the app is in background, but the webview is not receiving the payload or notification data, are you sending data-only notification payloads to android? Or are you sending anything on the notification part of the payload?

vvicho commented 6 years ago

@fredgalvao for Android I am having some other issues with my Notification Service which sends the payloads to FCM. As for iOS, this issue is still present.

As for how to reproduce, I call the register function... If I send notifications at this point, when I tap on the notification banner, it takes me to the notifications page. Then wait for a day and try to send a notification to the user. When I tap the notification, it doesn't send me to the notifications page anymore.