-
Notifications
You must be signed in to change notification settings - Fork 17
Notification settings
Mobile Messaging supports configuration of Notifications provided by the library. Different Notification settings are available via NotificationSettings.Builder.
It is possible to define custom callback activity to open when user taps on notification. By default the library will use default activity for the application package.
new NotificationSettings.Builder(context)
.withCallbackActivity(MyActivity.class)
.build();
Default notification title is application name (R.string.app_name). However custom notification title can also be used in notifications.
new NotificationSettings.Builder(this)
.withDefaultTitle("MyCustomNotificationTitle")
.build();
Default notification icon is launcher icon (R.mipmap.ic_launcher). Custom icon resource id can also be supplied to overwrite default behavior. If supplied, the icon should follow guidelines described here: https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
new NotificationSettings.Builder(this)
.withDefaultIcon(R.drawable.ic_my_notification_icon)
.build();
It is possible to show multiple notifications in status bar through NotificationSettings.Builder
. By default, when new notification arrives, it shows single notification which is overwritten by the new one.
new NotificationSettings.Builder(this)
.withMultipleNotifications()
.build();
It is possible to configure notification intent flags. Provided flags are delegated to Intent.addFlags(). Default flags are Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP.
new NotificationSettings.Builder(this)
.withIntentFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.build();
It is also possible to set pending intent flags. The flags are delegated to PendingIntent.getActivity(). Default flag is PendingIntent.FLAG_CANCEL_CURRENT.
new NotificationSettings.Builder(this)
.withPendingIntentFlags(0)
.build();
Notification auto-cancel parameter can be set via Notification Settings by calling an appropriate Builder method. The default value of auto-cancel is true. This parameter is forwarded to NotificationCompat.Builder.setAutoCancel().
new NotificationSettings.Builder(this)
.withNotificationAutoCancel()
.build();
...
new NotificationSettings.Builder(this)
.withoutNotificationAutoCancel()
.build();
It is possible to configure library to not show notifications when your application is running in foreground. By default the library will show notifications always.
new NotificationSettings.Builder(this)
.withoutForegroundNotification()
.build();
By default SDK will show Heads-up notifications on devices running Android 5.0+. Such notifications will only be shown when the app is in background or killed. You can disable heads-up notifications using method described below.
new NotificationSettings.Builder(this)
.withoutHeadsUpNotifications()
.build();
Constructed Notification Settings can be applied via MobileMessaging.Builder.
MobileMessaging mobileMessaging = new MobileMessaging.Builder(application)
.withDisplayNotification(new NotificationSettings.Builder(application)
.withoutNotificationAutoCancel()
.withoutForegroundNotification()
.build())
.build();
Mobile Messaging library can also be configured to work without notifications.
MobileMessaging mobileMessaging = new MobileMessaging.Builder(application)
.withoutDisplayNotification()
.build();
If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing API- DEPRECATED- Android Manifest components
- Privacy settings
- In-app chat
- Infobip RTC calls and UI
- Backup rules