Question: I want to show a banner with a preview of a received push notification on top of the screen as opposed to just showing a notification in Notification center and an icon in tray.
Answer: Notifications are shown by Android OS, so Pushwoosh SDK just passes notification objects to it, and they are then shown by OS. Therefore Pushwoosh SDK does not control this behavior directly, we can only let Android know that a notification should be shown as a heads-up.
Starting with Android Lollipop, Android never shows you push notifications as a pop-up banner. According to Google documentation:
> All notifications, regardless of importance, appear in non-interruptive system UI locations, such as in the notification drawer and as a badge on the launcher icon, though you can modify the appearance of the notification badge.
However, for high priority messages, Android can show so-called Heads-up notifications. Heads-up notifications can briefly appear in a floating window. This behavior is normally for important notifications that the user should know about immediately, and it appears only if the device is unlocked:
According to Google documentation, here are the possible triggers for Heads-ups:
Example conditions that might trigger heads-up notifications include the following:
- The user's activity is in fullscreen mode (the app uses fullScreenIntent).
- The notification has high priority and uses ringtones or vibrations on devices running Android 7.1 (API level 25) and lower.
- The notification channel has high importance on devices running Android 8.0 (API level 26) and higher.
For Android 7 and prior versions you should send pushes with high priority using "android_priority" parameter when sending via remote API or Priority slider in Control Panel.
For Android 8 you should also specify a notification channel with high importance. To do that, add {"pw_channel":"anytext"} to "android_root_params" in Control Panel or in your /createMessage API request.
Comments
0 comments
Please sign in to leave a comment.