For Android, managing notification urgency and categories involves using importance levels and Notification Channels, especially for Android 8.0 (API level 26) and higher.
Setting Notification Urgency (
Importance level
):- Use the
Importance level
parameter in your push payload to define the urgency. This parameter influences the notification's prominence:- For devices on Android 8.0 (API 26) and higher, it sets the "importance" of the Notification Channel.
- For devices on Android 7.1 (API 25) and lower, it sets the "priority" of the notification.
- Behavior based on
Importance level
values:1
or2
(Urgent): The notification plays a sound and appears as a heads-up notification (a small floating window).0
(High): The notification plays a sound and appears in the status bar. It may or may not appear as a heads-up notification depending on the device and other settings.- The
Importance level
parameter typically accepts values from-2
(min) to2
(urgent/max). Lower values (e.g.,-1
for Medium,-2
for Low) result in less intrusive notifications (e.g., no sound).
- Use the
Understanding Notification Channels (Android 8.0+):
- Notification Channels are mandatory for all notifications on Android 8.0 and higher.
- They allow users to group notifications from your app and customize settings (like sound, vibration, and interruption behavior) for each channel directly in their device's app notification settings.
Automatic Channel Creation (with SDK):
- If you are using a compatible SDK (e.g., Pushwoosh SDK version 5.4.0 and higher), a Notification Channel is typically created automatically on the user's device if one doesn't already exist for the specified channel name when you send a push.
- The channel's default settings (like importance, sound, vibration) are often derived from the parameters in your push payload (including
Importance level
).
Sending to a Specific Notification Channel:
- To target a specific Notification Channel, include the
pw_channel
key with your desired channel name within theandroid_root_params
of your push message payload. - Example:
{ "android_root_params": { "pw_channel": "YOUR_CHANNEL_NAME" } }
- Replace
YOUR_CHANNEL_NAME
with your chosen channel name (e.g.,alerts
,updates
,promotions
). - If the channel doesn't exist, the SDK will attempt to create it based on the push payload. To ensure a notification appears as a heads-up display on Android 8+ devices, send it to a channel configured with high importance (e.g., by also setting
Importance level
to1
or2
in the push payload).
- To target a specific Notification Channel, include the
User Permissions and Control:
- Your app must have the user's general permission to send notifications.
- Users can modify the settings for any Notification Channel (e.g., block notifications from that channel, change its sound, or disable visual interruptions like heads-up displays) via their device's app notification settings. The notification's behavior will always respect these user customizations.
Comments
0 comments
Please sign in to leave a comment.