7. You will receive app.pem certificate file that can be used to send VOIP notification (you can use my script bellow)
8. Recommendation NODEJS
If you want to use Node Js to send notifications, you must do it via APN, which is a direct module to send PushNotification.
npm install apn --save // In your project nodejs
Usage
To make this plugin work, you need to call .register({topic:'videocall'}) method and then you can use API bellow.
import{CapacitorVoipIos}from"capacitor-voip-ios"asyncfunctionregisterVoipNotification(){// register token CapacitorVoipIos.addListener("registration",(({token})=>console.log(`VOIP token has been received ${token}`)))// start callCapacitorVoipIos.addListener("callAnswered",(({username, connectionId, joinToken, meetingId})=>console.log(`VOIP username ${username}`);console.log(`VOIP connectionId ${connectionId}`);console.log(`VOIP meetingId ${meetingId}`);console.log(`VOIP joinToken ${joinToken}`);));// init plugin, start registration of VOIP notifications awaitCapacitorVoipIos.register({topic:'videocall'});// can be used with `.then()`console.log("Push notification has been registered")}
Once the plugin is installed, the only thing that you need to do is to push a VOIP notification with the following data payload structure:
You can use my script (bellow) to test it out:
./sendVoip.sh <connectionId> <deviceToken> <username>
sendVoip.sh:
#!/bin/bashfunctionmain {
connectionId=${1:?"connectionId should be specified"}
token=${2:?"Enter device token that you received on register listener"}
username=${3:-Anonymus"} curl -v \ -d "{\"aps\":{\"alert\":\"Incoming call\", \"content-available\":\"1\"}, \"Username\": \"${username}\", \"ConnectionId\": \"${connectionId}\"}"\ -H "apns-topic: <YOUR_BUNDLE_ID>.voip"\ -H "apns-push-type: voip"\ -H "apns-priority: 10"\ --http2 \ --cert app.pem \"https://api.development.push.apple.com/3/device/${token}"}main $@
Pay attention:
replace <YOUR_BUNDLE_ID> with your app bundle
ensure that you are using correct voip certificate (specified in --cert app.pem)
if you'll go to production version, you will need to do request to api.push.apple.com/3/device/${token} instead of
api.development.push.apple.com/3/device/${token}, otherwise you will receive BadDeviceToken issue