Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

'push-notification' fired inconsistently #245

Closed erinwilkins closed 7 years ago

erinwilkins commented 7 years ago

http://docs.pushwoosh.com/docs/customizing-cordova-plugin#push-notifications-in-foreground

By default Pushwoosh plugin does not display notifications in the foreground and automatically triggers push-notification event.

http://docs.pushwoosh.com/docs/cordova-api-reference#section-push-notification

Push notification accept event. Is fired when user clicks on push notification.

On iOS 10.2.1 and Pushwoosh Cordova plugin 6.5 it seems that you need to click on the notification for the 'push-notification' event to be fired while the app is in the foreground. With Android 6.0.1 the 'push-notification' event is fired and there is no notification displayed while the app is in the foreground.

The documentation doesn't seem to clear anything up. Is the 'push-notification' event supposed to be fired when the app is in the foreground?

skwasjer commented 7 years ago

It depends on which setting you use.

<variable name="IOS_FOREGROUND_ALERT_TYPE" value="BANNER" />
<variable name="ANDROID_FOREGROUND_PUSH" value="true" />

With this set, you can listen for the push-received notification, which is called when the app is running and can be used to handle foreground notifications. The push-notification is still triggered, but only when clicking the banner.

You would then often implement both, push-received for updating the UI for example (or displaying an alert, confirm or other custom dialog), and optionally push-notification for the direct (inter)action.

Unfortunately this isn't a 100% clear from the documentation.

DimanAM commented 7 years ago

push-notification event is fired when user clicks on the notification. With

<variable name="IOS_FOREGROUND_ALERT_TYPE" value="NONE" />
<variable name="ANDROID_FOREGROUND_PUSH" value="false" />

settings (wich are default) foreground notifications are automatically handled as if user manually clicks on them. Therefore push-notification event will be also triggered in this case.

@erinwilkins

On iOS 10.2.1 and Pushwoosh Cordova plugin 6.5 it seems that you need to click on the notification for the 'push-notification' event to be fired while the app is in the foreground

By default foreground alerts are turned off on iOS platform. However IOS_FOREGROUND_ALERT_TYPE might appear to be undefined in config.xml and will be treated as BANNER (https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/issues/203). Please make sure your config.xml is in a consistent state.