It is a requirement to implement notification channels for the Android SDK. Failure to do so will result in the push message not being sent.
Contents
What are Notification Channels?
Since the release of Android Oreo, Notification Channels provide you with the ability to group the notifications that your application sends into manageable groups. Once your notifications are in these channels, you no longer have input into their functionality, so it is up to the user to manage these channels.
See the following links for more detailed intro:
Notification Channel priorities
Low
- When collapsed, only the title is shown in one line with the application name and creation date of the notification.
- Small image previews are not available in collapsed mode.
- When expanded, the notification looks like a regular expanded notification.
- Does not play notification sound.
- The notification's icon is not displayed in the status bar.
Medium
- Expanded and collapsed notifications look as usual.
- Does not play notification sound.
High
- Plays notification sound.
Urgent
- Displays a heads-up notification.
Heads-up notifications are not set on a per notification basis, rather on a per channel basis. This means that if you post into a channel that has Urgent importance, then that notification will display as a heads-up notification on devices. Keep in mind that the user can lower the importance of channels, so it is not guaranteed that your channel will remain in the Urgent category.
Create a Notification Channel(s) within your app.
Create the notification channel(s) in the app by updating the Application class and assign the Channel ID and Channel Name to your channels.
Java
private void createNotificationChannel() { // Create the NotificationChannel, but only on API 26+ because // the NotificationChannel class is new and not in the support library if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = getString(R.string.channel_name); String description = getString(R.string.channel_description); int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); channel.setDescription(description); // Register the channel with the system; you can't change the importance // or other notification behaviors after this NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }
Kotlin
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Create the NotificationChannel val name = getString(R.string.channel_name) val descriptionText = getString(R.string.channel_description) val importance = NotificationManager.IMPORTANCE_DEFAULT val mChannel = NotificationChannel(CHANNEL_ID, name, importance) mChannel.description = descriptionText // Register the channel with the system; you can't change the importance // or other notification behaviors after this val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(mChannel) }
Add Notification Channels to the account
In your Emarsys account, go to Channels > Mobile Engage > Apps and select the application you want to edit.
On General Settings, under Platforms, click the edit icon to edit the Android Platform.
Set up the channel ID and channel name of your application.