How to handle VOIP Call Notification in Flutter

How to handle VOIP Call Notification in Flutter

VOIP stands for Voice Over Internet Protocol it allow video or audio communication using internet connection.

Overview of how VOIP works:

Caller wants to call to Receiver, Caller starts a call from his/her side which then goes to app server which initiate a notification service(Firebase Cloud Messaging or Apple Push Notification Service) this will trigger a notification in receiver phone and he/she can accept or reject the call. After accepting it will again go to app server to imitate call between both parties using any VOIP SDK, then the call will get started. Voip.png Some VOIP SDK available to use in flutter:

  • Flutter WebRTC (https://pub.dev/packages/flutter_webrtc)
  • Agora Flutter SDK (https://pub.dev/packages/agora_rtc_engine)
  • Twilio (https://pub.dev/packages/twilio)
  • ConnectyCube (https://pub.dev/packages/connectycube_sdk) Prerequisite
  • Have your app server to handle call notifications
  • Firebase Account for using FCM
  • Any VOIP sdk for VOIP call

    VOIP call notification in android using Flutter

  • Caller request to start call with Receiver.
  • Server validates call request and gets caller firebase device token. Then Sends a cloud message to Receiver using this token.
  • Check State of the Receiver App, if app is in background or terminated then show caller notification, else if app is in foreground then show full screen app caller UI.
  • For showing caller notification we can use https://pub.dev/packages/connectycube_flutter_call_kit or have to write android native code
  • If call rejected, then from Receiver side app server call rejected will be send to Caller.
  • If call accepted, then using session_id created from server and this will be used to create a new call channel_id from respective VOIP SDK to start a call between both users.
  • After the call is connected app should launch ongoing call UI with caller details same for caller he should get receiver details.