Push notifications: Android
This article will help you to set up push notification in Android applications.
VoxImplant push notifications for Android are based on FirebaseCloud Messaging (FCM) platform and implemented as "data messages". With the help of notifications, a device can be awakened to show a new message in user’s conversation(s) and an app can be started before a call arrives.
Push notifications for calls are sent with high priority and delivered without delay.
The following tutorial explains the code needed to handle push notification and describes additional steps that should be performed to have a working Push Notifications solution for your mobile applications.
Before you start, please check that your project meets FCM requirements.
Add Firebase to the Android project
To add push notifications to the Android project, it is required to add Firebase to the project.
Follow the FCM instructions and recommendations to:
The Voximplant Control Panel allows you to add only one certificate of one type. If you are developing an application and need to test push notifications in both Debug and Release modes, add the same GOOGLE certificate with your application bundle + specific suffixes, for example, “.dev”, “.prod”.
The Voximplant Cloud does not validate the bundle id, we use this parameter here only to identify the certificate needed to send a push notification. So, you don’t need to change the real bundle id, but only “mark” it for the Voximplant Cloud.
Do not forget to initialize the SDK correctly for Debug and Release configuration and set the suffix of the bundle id depending on the configuration.
Modify your VoxEngine scenario (for calls)
To let Voximplant cloud send push notifications to applications, the JavaScript scenario that initiates a call should include a push notification helper:
Add certificates to the Voximplant cloud
- Log in to the Firebase console with your Google account you have connected earlier in this tutorial.
- In the Recent Projects section, click on the project you just added to Firebase.
- Click on the Android application name and select Settings.
- Select the Cloud Messaging tab from the top navigation bar.
- Copy the Sender ID and Server key strings.
- Log in to the Voximplant control panel.
- Go to your application, then switch to the Push Certificates tab.
- Click on the Add Certificate in the upper right corner.
- Select GOOGLE from the Certificate for list.
- Upload Service account JSON file. Generate this file in the Firebase console for your project by following the steps:
10.1 Go to Project Settings.
10.2 Navigate to the Service Accounts tab.
10.3 Navigate to Google Cloud console by clicking “Manage service accounts permissions”.
10.4 Generate a key for the firebase-adminsdk account.
- Click on the Add button.
The Voximplant Platform supports sending push notifications to several Android applications with different package names within the same Voximplant application. If it is required to add several FCM certificates to the same Voximplant application, you have to set the application package name while adding the certificate.

If a package name is specified with a certificate, you must set the same package name when initializing the SDK.
Provide a token to the Voximplant cloud
The Voximplant Cloud requires a device token to send a push notification. The token should be obtained from Firebase API on the application side and registered via IClient.registerForPushNotifications API:
IClient.registerForPushNotifications API may be called in any IClient state (ClientState), however, the token is registered only after the client logs in.
Register the token in these cases:
Token has been updated by
<provider>
Some other Voximplant user has logged in on the device
Monitor token refresh
The application should also provide a token if Firebase refreshes it. Override the onNewToken method of previously extended FirebaseMessagingService and pass a new token to the Android SDK.
Handle push notifications (calls)
Push notifications as “data messages” are received by means of the service that overrides FirebaseMessagingService. You need to override the onMessageReceived method to get the push notification data.
The onMessageReceived method is invoked in any application state (foreground or background).
Once the push notification is received, call IClient.handlePushNotification API and provide the data that contains the “voximplant” signature.
IClient.handlePushNotification API may be called in any ClientState, but to receive an ICall instance of an inbound call, it is required to connect to the Voximplant Cloud and log in. After you do that, the IClientIncomingCallListener.onIncomingCall method is invoked to provide access to the ICall object.
Call push notifications are sent automatically. Call the callUser method in the VoxEngine scenario and push notification is automatically sent to the app. Thus, the app can wake up, connect to Voximplant, log in, and accept the call.
Use an analytics label to monitor push delivery status in real time inside Firebase console via FCM reporting dashboard.
Just set the CallUserRequest.analyticsLabel property for the callUser method in your VoxEngine scenario and monitor the message delivery status.

Subscribe for IM push notifications for instant messaging
The Voximplant Cloud can send push notifications for IP messaging when one of the following events occurs:
A new message has appeared in the conversation (IMessengerListener.onSendMessage event)
A message has been edited in the conversation (IMessengerListener.onEditMessage event)
By default, push notifications are not sent. To enable them for a user, it is required to call IMessenger.managePushNotifications API and indicate preferred MessengerNotification types. The client should log in to the Voximplant Cloud for the subscription to be successful.
Handle push notifications (IP messaging)
Push notifications as “data messages” are received by means of the service that overrides FirebaseMessagingService. You need to override the onMessageReceived method to get the push notification data.
The onMessageReceived method is invoked in any application state (foreground or background).
Once a push notification is received, use IMessengerPushNotificationProcessing to get an IMessageEvent and therefore all data and process it.
To ensure that this is a Voximplant IM push notification, check the “voximplant-im” signature in the push data.
A push notification payload contains the following information:
New or edited message UUID
Conversation UUID the message belongs to
Message text
Initiator’s user id
Sequential number of the event in the conversation
Please note that the IMessengerPushNotificationProcessing interface only converts data message to an IMessageEvent object with no modifications of it or updates of other Messenger objects instances.
Use tokens or keys for better security
Voximplant supports 3 ways of the authorization from SDK:
- With a username and a password
- With a username and a token
- With a one-time login key
Saving the password is not secure, so we would recommend that you use the "token" or "key" approach.
The token is received from an event after a successful login and can be saved and used later instead of the password.
The "login key" approach allows you to completely avoid the use of password on the client-side by offloading it to your backend.