Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
110 stars 139 forks source link

Using background "remote notification" on iOS #162

Closed webdigi closed 8 years ago

webdigi commented 8 years ago

We have an app with the following

function registerPushwooshIOS() { var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification"); //set push notification callback before we initialize the plugin document.addEventListener('push-notification', function(event) { // Code to show a popup of the text in push notification is here... }

Above works fine with standard push notification and it shows a notification within the app when the notification is tapped.

There are cases where the user opens the app without tapping on the push notification and in those cases the popup does not show. What is the best workaround to show the push notification is the user opens the app instead of tapping on the notification to trigger the app?

shaders commented 8 years ago

Unfortunately that is iOS limitation. If the app was opened by tapping on the app icon and not on the notification, the notification payload is not delivered to the app, therefore push notification would not be available in the app.

You could try using background push (newsstand push) and present local notification when push notification has been delivered to your app in background.

The sample technique is outlined here, but in native code: http://docs.pushwoosh.com/docs/deletable-ios-push

webdigi commented 8 years ago

Thanks @shaders - Can you please let us know how we can use didReceiveRemoteNotification:fetchCompletionHandler OR "content-available: 1" equivalent?

So that way the app will be aware of a push notification if use opens the app directly instead of clicking the push notification?

shaders commented 8 years ago

Unfortunately there is no sample code for Cordova. I'll see what I can do.

As a general rule you don't receive notification if your app was open by tapping on the app icon. This means the user is not interested in notification. This is OS behavior by design.

The same behavior is on Android.