masashi-sutou / flutter_ios_voip_kit

One-to-one video call using CallKit and PushKit with flutter iOS app.
MIT License
67 stars 45 forks source link
callkit flutter pushkit voip webrtc

flutter_ios_voip_kit

One-to-one video call using CallKit and PushKit with flutter iOS app.

Motivation

We need to use CallKit to handle incoming VoIP notifications from iOS 13. Check the WWDC2019 video for more information. So instead of using CallKit and PushKit separately, there is a growing need to use them together. However, there are still few VoIP notification samples on the net that use CallKit and PushKit (especially for Flutter). I decided to create a flutter plugin with the minimum required functions. You can use this plugin, but the actual purpose is to help you create a VoIPKit tailored to your service.

Requirement

Usage

1. install

2. setting Capability in Xcode

  1. Select Background Modes > Voice over IP and Remote notifications is ON.
  2. Select Push Notifications.
  3. Changed ios/Runner/Info.plist after selected Capability.
<key>UIBackgroundModes</key>
<array>
    <string>remote-notification</string>
    <string>voip</string>
</array>

2. edit Info.plist

<key>FIVKIconName</key>
<string>AppIcon-VoIPKit</string>
<key>FIVKLocalizedName</key>
<string>VoIP-Kit</string>
<key>FIVKSupportVideo</key>
<true/>
<key>FIVKSkipRecallScreen</key>
<true/>

3. add New Image set for CallKit

4. create VoIP Services Certificate

Create .p12 from .cer with KeyChainAccess
openssl pkcs12 -in voip_services.p12 -out voip_services.pem -nodes -clcerts

If you're running OpenSSL version 3 or later, please note that you may need to include the "-legacy" option.

openssl pkcs12 -legacy -in voip_services.p12 -out voip_services.pem -nodes -clcerts

5. request VoIP notification APNs from your server

{
    "aps": {
        "alert": {
          "uuid": <Version 4 UUID (e.g.: https://www.uuidgenerator.net/version4) >,
          "incoming_caller_id": <your service user id>,
          "incoming_caller_name": <your service user name>,
        }
    }
}
curl -v \
-d '{"aps":{"alert":{"uuid":"982cf533-7b1b-4cf6-a6e0-004aab68c503","incoming_caller_id":"0123456789","incoming_caller_name":"Tester"}}}' \
-H "apns-push-type: voip" \
-H "apns-expiration: 0" \
-H "apns-priority: 0" \
-H "apns-topic: <your app’s bundle ID>.voip" \
--http2 \
--cert ./voip_services.pem \
https://api.sandbox.push.apple.com/3/device/<VoIP device Token for your iPhone>

Try out example app

Select call role 🤙 Caller page 🔔 Callee page
🔔 Callee(incoming call) 🔔 Callee(locked) 🔔 Callee(locked) 🔔 Callee(recall)
🔔 Callee(unanswered local notification) 🔔 Callee(unanswered local notification)

Q&A

Does CallKit have a call and outgoing call screen?

Can I use remote push device token instead of VoIP device token?

Can't get VoIP token on iOS13

Don't receive VoIP notifications

No icon is displayed on the incoming call screen when locked

create icon (e.g.: sketch) Xcode Image Set

Reference