phonegap/phonegap-plugin-push

[IOS] [13.3.1 and 13.4.0 beta2] Push in background with content-available problem

vlodosmonkey opened this issue · 6 comments

Expected Behaviour

Send a push notification with the application in the background, with the flag content-available to true, the app knows that it has received the push (for example by displaying an alert)

Actual Behaviour

Send a push notification with the application in the background, with the flag content-available to true, the app does not know that it has received a push

Reproduce Scenario (including but not limited to)

The issue happens on IOS 13.3.1 and 13.4.0 beta2
We test with other versions like 11,12,13.3.0 and there are no problem.
We did another test for more information. We created another clean app with the same plugin version, and the issue remains.
The issue is intermittent. Sometimes the app have the right behavior and sometimes have wrong behavior. But we see more happens when you reset your device. And we observe too that the behaviour is right when you have 100% of batery and your device is charging.

Steps to Reproduce

1 - Turn off phone
2 - Turn on phone
3 - Open the app and register push notifications
4 - Put the app in background
5 - Send push notification with flag content-available=true
6 - The webview does not receive the notification push (the callback of push.on('notification', callback) is not fired)
7 - In our case when you open the app does not show an alert (we have tested with sounds, "console logs", breakpoints etc and the callback of push.on is not fired)

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

IOS 13.3.1 and 13.4.0 beta2 (Tested on Iphone 6s, Iphone 7, Iphone 11)
Angular: 5.0.3
cordova-plugin-ionic-webview: "2.5.3",

Cordova CLI version and cordova platform version

cordova version: 8.1.2
cordova platform version iOS: 4.5.5   

Plugin version

phonegap-plugin-push: 2.2.3

Sample Push Data Payload

{
    "aps":{
        "content-available":1,
        "alert":"CUSTOM_ALERT",
        "sound":"default"
    },
    "tag":"CUSTOM_PUSH_TAG",
    "title":"CUSTOM_TITLE",
    "message":"CUSTOM_MESSAGE",
    "CUSTOM_ID":1,
    "notId":1283732
}
    "aps":{
        "content-available":1,
        "data": "CUSTOM_DATA",
        "moredata": "CUSTOM_MORE_DATA"
    },
    "tag":"CUSTOM_PUSH_TAG",
    "title":"CUSTOM_TITLE",
    "message":"CUSTOM_MESSAGE",
    "CUSTOM_ID":1,
    "notId":1283732
}

Thanks @richardshergold !
No, we tested with apns-priority 5 or 10 and apns-push-type alert or background and we didn't get the behaviour expected. =( with IOS 13.0.0 we have no problem. The problem is in 13.3.1 and 13.4.0 beta2

@varreba have you checked your tokens are ok? We have the same problem and someone has just pointed me at this? https://forums.developer.apple.com/thread/117545

@varreba the above issues are fixed in 2.3.0 of the plugin (we were on 2.2.3) - now we have upgraded our iOS 13 notifications are working

@richardshergold We get the same problem with 2.3.0 version. =(

I think it may be an iOS issue, and not a plugin one. I experienced this same issue, and the only reliable "workaround" I found was moving to VoIP notifications (note that iOS13 has a new and very restrictive policy for voip notifications, so it may not be a workaround for some of you).

Testing in an iPad (iOS13.3.1) connected to a Macbook, and looking at the macOS console, I noticed that, once the push notification reaches the terminal (always reaches within a few seconds), there is a "dasd" process that seems to be in charge of launching the app in background, and it decides whether launching the app or not according to "something unkown". But all this happens before any plugin or js code is launched. After several tests, I have not found a pattern to identify the issue, and i just simply think that apple does not ensure waking an app from a push notification.

The exact trace observed was:

  • succesful case: dasd - com.apple.pushLaunch .... DeviceActivityPolicy... Decision: Can Proceed,... and then the app wakes up in background.
  • failing case: dasd - Daemon Canceling Activities [{com.apple.pushLaunch .... myapp...}]... CANCELED... and then the app doe not wake up in background.

Hope this info may be somehow useful for you guys.