Skip to content

Handle Push Notifications

Kristiyan Petrov edited this page Jan 21, 2021 · 11 revisions

We highly recommend to add push notification to your app in oder to receive incoming calls even when the app is killed.

Be Aware

Server side steps required:

  • Listen server-side for webhook coming from Bandyer.

(Discover how your backend can be notified with upcoming call events registering event hook on_call_incoming here: https://docs.bandyer.com/Bandyer-RESTAPI/#webhooks).

  • Forward the data you have received via the webhook to your Android Application with a push notification framework of your choice (FCM, OneSignal or others)

Learn more about FCM
Learn more about OneSignal

Client side steps required:

  • Implement your client listener for notifications (FCM, OneSignal or any others) depends on the notification framework you have decided to use.
  • Once received the notification you will need to give the payload of the notification to our SDK. In case your application handles different types of notifications be sure to forward only the payload meant for our SDK (the one you have received from the webhook)

Client handle Payload

Incoming calls push payloads can be passed to the BandyerSDKClient object as shown below.

BandyerSDKClient.getInstance().handleNotification(getApplicationContext(), pushPayload);

Example of the notification payload

The push notification payload received by your app is just a simple json containing the information your server sent to FCM.

{
  "data": {
    "initiator": "usr_123456789",
    "options": {
      "callType": "audio_video",
      "creationDate": "2020-06-26T10:59:04.315Z",
      "duration": 0,
      "live": 1,
      "record": 0
    },
    "roomAlias": "room_58fee601fcef",
    "users": [
      {
        "status": "invited",
        "user": {
          "userAlias": "usr_987654321"
        }
      },
      {
        "status": "invited",
        "user": {
          "userAlias": "usr_123456789"
        }
      }
    ]
  },
  "event": "on_call_incoming",
  "room_id": "room_58fee601fcef"
}
Clone this wiki locally