Write your First mesibo Enabled Application

Estimated reading time: 5 minutes

In this part, we will learn about sending push notifications to your application from mesibo.

Prerequisites

You MUST go through the following prerequisites before you read further.

  • Read the Preparation Guide.
  • Read one of the Android, iOS, JS section of this tutorial.

Push notification in mesibo

In the past, apps could stay online even when running in the background. However, it’s no longer the case. Both Android and iOS will suspend the app after app moves to the background. Read more about Android and iOS background execution limits here and here.

Hence, when your app has a new message or a new incoming call, you need to wake up your app from the sleep state so that messages and calls can be delivered in real-time. This is where you need to send push notification. Push notification wakes up your app and moves it from the sleep state to the active state. Once the app moves to the active state, Mesibo will automatically connect and start receiving messages and calls. This entire process will be seamless for the user once you set up the push notifications.

There are two kinds of push notification:

  1. Background notification: This type of notifications are not visible (data type in Android and background or VoIP type in iOS).

  2. Alerts: These are visible alerts(notification type in Android and alert type in iOS).

By default, mesibo sends background notification that wakes your app in the background, and then the application can start mesibo to receive all the messages. This is a recommended way of receiving push for real-time application as it gives you the finer control. However, You can change this default behavior from the mesibo console by disabling the Background push checkbox. It will then send visible push alerts.

You may also refer to the mesibo sample app and backend source code to see how it is implemented there.

Setting up Push notification Credentials in mesibo Console

To enable mesibo to send push notification to your users, you need to configure push notification credentials in the mesibo console.

Follow the steps below to configure your push notification credentials

Configure FCM Credentials for Android Notifications

  1. Get the Firebase Sender ID and Firebase Server Key from Firebase Console of your app. Enter it in the mesibo console. Refer to the Firebase Documentation and FCM Messages for setting up your FCM Server.
  2. Go to your app settings in the mesibo console. Go to the section Push Notifications
  3. Enter the credentials that you got in the Android - Firebase Cloud Messaging (FCM) Configuration section.
  4. Under push, settings select Background Push (recommended) or set your required push notification type.

Configure APN/VoIP Credentials for iOS Notifications

  1. Get the universal Push/VoIP certificate in .p12 format from your Apple Developer Account. Refer to Obtain a Provider Certificate from Apple
  2. Go to your app settings in the mesibo console. Go to the section Push Notifications
  3. Choose the universal Push/VoIP certificate file that you downloaded earlier and upload it in the section Apple Push Notification (APN) Configuration.
  4. Under push, settings select Background Push (recommended) or set your required push notification type.

Sending push notification to your users

Once you setup the above information in the mesibo console, mesibo is almost ready to send push notification to your users. However, mesibo still requires a unique token per user so that it can send push notification to that particular user. You need to obtain that user-specific device token from using Android or iOS API and then send it to mesibo using setPushToken() API.

Obtaining push notification token in Android

  1. To understand how to get the user push token, refer Firebase Docs, Or this detailed tutorial on Android Push Notifications

  2. Use Mesibo setPushtoken() API to send push token to mesibo.

Refer to the Messenger App Source code for Android to understand how to do this.

Obtaining push notifications token in iOS

Unlike Android, iOS has two separate tokens, one for push and one for VoIP (if your app has call functionalities).

  1. Refer APN Docs or this detailed tutorial on iOS Push Notifications

  2. Use Mesibo setPushtoken() API to send push and voip tokens to mesibo.

Refer to the Messenger App Source code for iOS to understand how to do this.

Troubleshooting

if your app doesn’t get the push, check following:

  • Ensure that you have configured push-notification credentials for your app correctly on the mesibo console.
  • Keep your phone on the cellular data and see if you are receiving push notifications
  • See if other apps on your phone receive it

Another option is to send push notification yourself and see if it helps. Setup the mesibo webhook which will be invoked when the destination is offline. You can then send push notification from the webhook using your own scripts.

On to Part 9 >>

mesibo, android, ios