Rate this page:

Android SDK

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:

Adding a push notification helper

Adding a push notification helper

Add certificates to the Voximplant cloud

  1. Log in to the Firebase console with your Google account you have connected earlier in this tutorial.
  2. In the Recent Projects section, click on the project you've just added to Firebase.
  3. Click on the Android application name and select Settings.
  4. Select the Cloud Messaging tab from the top navigation bar.
  5. Copy the Sender ID and Server key strings.
  6. Log in to the Voximplant control panel.
  7. Go to your application, then switch to the Push Certificates tab.
  8. Click on the Add Certificate in the upper right corner.
  9. Select GOOGLE from the Certificate for list.
  10. 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 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.
  11. 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.

Please note

If a package name is specified with a certificate, you must set the same package name when initializing the SDK.

Initialize SDK with a package name

Initialize SDK with a package name

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:

Receiving the token

Receiving the token

IClient.registerForPushNotifications API may be called in any IClient state (ClientState), however, the token will be 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 token refresh

Handle token refresh

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.

Handling push notifications (calls)

Handling push notifications (calls)

IClient.handlePushNotification API may be called in any ClientState, but to receive an ICall instance of an incoming call, it is required to connect to the Voximplant Cloud and log in. After you do that, the IClientIncomingCallListener.onIncomingCall method will be invoked to provide access to the ICall object.

Push notifications are sent automatically (calls)

Just call the callUser method in the VoxEngine scenario and push notification will be automatically sent to the app. Thus, the app will be able 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 using 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 (IP messaging)

The Voximplant Cloud can send push notifications for IP messaging when one of the following events occurs:

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.

Enable IM push notifications (IP messaging)

Enable IM push notifications (IP messaging)

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

Handling push notifications (IP messaging)

Handling push notifications (IP messaging)

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:

  1. With a username and a password
  2. With a username and a token
  3. 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. Please read this article for details.