Preparing your App to receive Push Notifications

Estimated reading time: 2 minutes

Once you configure push credentials in the mesibo console, mesibo is almost ready to send push notifications to your users. However, you still need to prepare your app to receive and process push notifications. You need to ensure that your app can process push notifications quickly and can perform the following tasks.

  1. Initialize mesibo on receiving a push
  2. Use local notifications to show customized notifications
  3. Send device token to mesibo

1. Initialize mesibo on receiving a push

When your app receives a push notification, the system launches your app or wakes it from the suspended state. If you have already initialized mesibo, and when the system wakes your app from the suspended state, mesibo will connect automatically. However, if the system launches your app on receiving push, your app MUST ensure that mesibo is initialized quickly before the system suspends your app.

Refer to the Android and iOS messenger source code to learn how messenger initialized mesibo on receiving a push.

2. Use local notifications to show customized notifications

As explained earlier in the section Push Notification Types, by default mesibo sends a background push notification (recommended). Background notifications are not visible and hence you should use local notifications to show the notifications. Local notifications give you complete control over how notification will look and any localization, if requires.

Refer to the Android and iOS messenger source code to learn how messenger users local notifications to show notifications.

3. Send device token to mesibo

mesibo requires a unique token per user so that it can send push notifications to that particular user. You need to obtain that user-specific device token using Android or iOS API and then send it to mesibo using setPushToken() API.

Sending push notification token in Android

  1. To understand how to get the user push token, refer to 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, which uses setPushtoken API

Sending push notification token in iOS

Unlike Android, iOS has two separate tokens, one for push and one for VoIP (PushKit). You only need to use the push token.

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

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

Refer to the Messenger App Source code for iOS, which uses setPushtoken API

mesibo, android, ios