Notifications
The Unblu Android mobile SDK offers you ways to display notifications for incoming calls, as well as push notifications for things such as new messages in ongoing chats.
Incoming call notifications
The SDK’s call module displays a notification whenever there’s an incoming call. This provides users with a standard experience for such scenarios in Android mobile apps.
The notification is bound to a full-screen Activity
that’s displayed when the mobile device is inactive. It lets users answer or reject the call without opening the app.
The screen’s colors are configurable. See the configuration properties in the com.unblu.mobiledevice.v2.client.core.MobileCallUiConfiguration group.
Notification configuration
If the SDK is configured to use notifications, there are three possible types of notification:
-
New messages in ongoing chat conversations
-
Incoming calls
-
Missed calls
The SDK uses three different notification channels for the different types of notification, each using the default system sounds. However, this is only possible—indeed, required—for Android 8.0 Oreo or newer. Before Android 8.0 Oreo, you had to define custom sounds.
For all types of notification, you should use the system default sounds for notifications and calls to ensure the best user experience.
The names of the sound files must be configured on the Unblu server via the configuration properties com.unblu.mobile.push_notification.androidNewMessageSound and com.unblu.mobile.push_notification.androidIncomingCallSound. We recommend only changing the incoming call sound. The value has to be the name of the file without the file type ending. Within the app, the file must be located at res/raw/<file>
.
By default, the icon of the notifications matches the app icon. Only the parts of the image with an alpha value are displayed. This can lead to a completely gray icon if the app icon has no transparent area. To change the icon to a different image, you can specify a meta-data
area in the app manifest, as in this example:
AndroidManifest.xml
to change the icon image for notifications
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
For more information, refer to the Firebase configuration documentation.
Firebase
If you wish to use Firebase push notifications, Unblu SDK provides the firebasenotificationmodule
dependency to add to your project.
You can then obtain an instance of the UnbluNotificationApi
from the UnbluFirebaseNotificationService
class. For more information, refer to the description of the FirebaseNotificationService.getNotificationApi
method in the Unblu Android mobile SDK reference.
If you already have a Firebase service or other push notification source in place, you need to channel your push notifications using the UnbluNotificationApi.pushNotificationReceived()
method provided by UnbluNotificationApi
. You can obtain an instance from UnbluNotificationApi.createNotificationApi()
.
You can convert your push notification to an UnbluNotification
with the UnbluNotificationApi.fromData
method.
Push notifications sent via Firebase are encrypted by the Collaboration Server. Only the recipient of the notification holds the decryption key.
For more information, refer to the description of the UnbluNotificationApi
interface in the Unblu Android mobile SDK reference.
Push tokens
The push token is sent to the Collaboration Server once an UnbluClient
instance is initialized. If you intend to use push notifications, you should therefore give careful consideration to the question of when to initialize the SDK
If push notifications are disabled, the user’s device token is deleted from the Collaboration Server to ensure they don’t receive any push notifications. This, too, only happens if an UnbluClient
instance is initialized. If it isn’t, there’s no way of instructing the Collaboration Server to delete the push token.
Note that the mobile SDK doesn’t provide users a way to manage their devices. This must be done outside the SDK.
Notification handling in Android 12 and newer versions
If your application is targeting API level 31 (Android 12) or higher, be aware that there are restrictions on activity background starts. If your app uses notifications through Unblu, make sure your activity with the intent flag ACTION_MAIN
uses the tag launchMode
with the value singleInstance
.
You should also override its onNewIntent
method and pass in the intent’s bundle with the Unblu notification data by calling the UnbluApplicationHelper.onNewIntent
method. This prevents recreating an activity from notification clicks that aren’t flagged for this purpose, while still channeling intent data from notifications to the activity, ensuring that the user experience isn’t disrupted in the process.
See also
-
For more information push notifications in Unblu, refer to Push notifications.
-
For information on pausing notifications, refer to Pausing mobile and web push notifications.