Push Notifications for Android

VoxImplant push notifications for Android are based on FirebaseCloud Messaging (FCM) platform and implemented as the "data messages". Using notifications, a device can be awakened and an app started before a call arrives. Our SDK requires Android API 16 (4.1), while push notifications support also requires Play Services 10.0.1 or higher to be available on the device. Our Android SDK contains a sample application with all the code needed to handle push notification. Following tutorial explains that code and describes additional steps that should be performed to have a working Push Notifications solution for your mobile applications. Push notifications are available since Android SDK version 2.1.0

Add Firebase to the Android project

To add push notifications to the Android project, it is required to add Firebase to the project:

  • Open project in the Android Studio
  • Select Tools, then Firebase from the top menu. Assistant window will open
  • Expand the Cloud Messaging item and click on the Set up Firebase Cloud Messaging
  • Click the Connect to Firebase button. Browser windows will open where you will be asked to login into the Firebase with your Google account. After logging in, the "Connect to Firebase" window will be displayed in the Android Studio.
  • Follow the wizard to add Firebase support into the project
  • Click the Add FCM to your app button and then click on the Accept Changes button to modify your project.

Provide token to the Voximplant cloud

    • After each successful login into Voximplant cloud application should get a push notification token from Firebase and provide it to the Voximplant cloud:
      String token = FirebaseInstanceId.getInstance().getToken();
      // 'client' is an instance of IClient
    • The application should also provide a token if Firebase refreshes it. Implement Android Service that extends FirebaseInstanceIDService, override the onTokenRefresh method of that service and in that method do same token manipulation as described above. Add the service to the Android application manifest so the service is auto-started on application start

Handle push notifications

  • Implement second Android Service that extends FirebaseMessagingService. Add the service to the Android application manifest so the service is auto-started on application start
  • Override the onMessageReceived method of that service
  • Inside the onMessageReceived method call, get a message payload via getData and check, that it contains the "voximplant" signature
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map<String, String> message = remoteMessage.getData();
        if (message.containsKey("voximplant")) {
            // 'client' is an instance of IClient. This call
            // notifies Voximplant cloud that notification is successfully received.
  • After the message with "voximplant" signature is received, if the application is not connected or logged in to the Voximplant cloud, the application should login (and reconnect, if needed) in order to handle an incoming call. It is strongly recommended to disable connectivity check when using Voximplant connect while handling push notifications since it increases the connect time and application may not meet the time requirements to react on push notification.

Add certificates to the Voximplant cloud

  1. Login into the Firebase console with your Google account you have connected early in this tutorial
  2. In the Recent Projects section click on the project that was previously added to Firebase during this tutorial
  3. Click on the Android application name and select Settings
  4. Select the Cloud Messaging tab from the top navigation bar
  5. Copy Sender ID and Server key strings
  6. Login into the Voximplant control panel
  7. Select Settings, Mobile Push Certificates from the top menu
  8. Click on the Add Certificate
  9. In the Certificate for list select the GOOGLE
  10. Enter the Sender ID and Server key strings copied from the Firebase
  11. Click on the Add button
  12. Click on the Certificates List, then on the Bind app button for the certificate just added
  13. In the Bind certificate to application window select the Voximplant application that will issue the calls and click on the Save button

Modify VoxEngine scenario

In order for Voximplant cloud to send push notification to applications, the JavaScript scenario that initiates a call should include a push notification helper:


Push notifications are sent automatically

Just use a callUser method from the VoxEngine scenario and push notification will be automatically sent to the app so the app can wake up, connect to Voximplant, login and accept the call.

Use tokens or keys for better security

Voximplant support 3 ways to login from the SDK: with a username and a password, with a username and a token or with a one-time login key. Saving the password is not secure, so we would recommend to use "token" or "key" approach. The token is received from an event after the successful login, can be saved and used later instead of a password. Please refer to the tutorial for details. The "login key" approach allows to completely exclude password usage on client-side by offloading it to your backend. Please refer to the tutorial for details.

Add your comment

Please, enter valid email

Get your free developer account or talk with our sales team to learn more about Voximplant solutions
Contact sales

Please complete this field.

Please complete this field.

Please complete this field.

Choose the solution

Please complete this field.

Please complete this field.