Notification channels

Available only for apps targeting Android 8.0 (API level 26) and above

WebEngage SDKs 2.7.0 and above support Android push notification channels. Notification channels provide a unified system to help you manage notification behaviour depending on their type. For push notifications sent via WebEngage, you can define the behaviour of the properties mentioned below using notification channels. To do this, add the respective meta-data tags in the application element of your AndroidManifest.xml as shown below. All push notifications sent via WebEngage are bundled in a single channel.

You can modify default push channel configurations by calling specific methods of PushChannelConfiguration class and providing its instance to WebEngageConfig during SDK initialization as shown below.

PushChannelConfiguration pushChannelConfiguration = new PushChannelConfiguration.Builder()
  	.setNotificationChannelName("Offers")
  	.setNotificationChannelDescription("Product offer weekly updates")
  	.setNotificationChannelImportance(3)
  	.build();

WebEngageConfig webEngageConfig = new WebEngageConfig.Builder()
  	.setDefaultPushChannelConfiguration(pushChannelConfiguration)
  	.build();
registerActivityLifecycleCallbacks(new WebEngageActivityLifeCycleCallbacks(this, webEngageConfig));

Name

This is the channel name which is visible to the user.

pushChannelConfiguration.setNotificationChannelName("Offers")

Description

This is the channel description which is visible to the user.

pushChannelConfiguration.setNotificationChannelDescription("Product offer weekly updates")

Importance

Sets one of five importance levels that configure the amount a channel can interrupt a user, ranging from IMPORTANCE_NONE (0) to IMPORTANCE_HIGH (4). The default importance level is 3 which displays everywhere, makes noise, but doesn't visually intrude on the user.

pushChannelConfiguration.setNotificationChannelImportance(3)

Light color

Sets the notification light color for notifications posted to this channel if the device supports this feature. enableLights is automatically called by WebEngage SDK when you set this tag.

pushChannelConfiguration.setNotificationChannelLightColor(Color.parseColor("#ff0000"))

Lock screen visibility

Sets whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form. See e.g. VISIBILITY_SECRET.

pushChannelConfiguration.setNotificationChannelLockScreenVisibility(Notification.VISIBILITY_PUBLIC)

Show badge

Sets whether notifications posted to this channel can appear as application icon badges in a Launcher.

pushChannelConfiguration.setNotificationChannelShowBadge(true)

Sound

Sets the sound that should be played for notifications posted to this channel and its audio attributes. Notification channels with an importance of at least IMPORTANCE_DEFAULT (3) should have a sound. Set android:value as the name of the file without the extension. This file must be in the resources/raw folder of your app.

pushChannelConfiguration.setNotificationChannelSound("FILENAME")

Vibration

Sets whether notification posted to this channel should vibrate.

pushChannelConfiguration.setNotificationChannelVibration(true)

Group

Sets the group this channel belongs to. Group information is only used for presentation on the user's device, not for behavior. value is the group ID of the group that you want to use.

pushChannelConfiguration.setNotificationChannelGroup("GROUP_ID") //Provide a valid group ID

By default, these properties are assigned the following values.

Property
Value / Status

Name

Marketing

Description

Not assigned

Importance

Light color

Light is disabled

Lock screen visibility

Show badge

true

Sound

System default

Vibration

true

Group

Not assigned


Notification channels


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.