VoIP notifications
Sending VoIP Notifications with OneSignal.
OneSignal does allow sending VoIP notifications for Android and iOS. However, our SDK does not support registration of a VoIP token at this time. This guide will share exact steps you need to take to get setup.
Android VoIP setup
Android does not have the concept of "VoIP Push" the same as iOS. Notifications will just work, including data-only messages where you can start an Activity instead of showing a push.
If you need to call custom class for showing native UI, for example, you would use the Android NotificationExtenderService
so you can override the notification and show your custom UI or start your custom Activity.
Visit our Service Extensions docs for more on setting up the NotificationExtenderService
.
Also, see Android's documentation for setting up a calling app and this Medium post by Lloyd Dcosta to Show incoming voip call notification and open activity for android OS>10.
iOS VoIP setup
iOS 13 Update!
Please review this thread by an Apple Employee which talks about the iOS 13 requirements for VoIP needed to be implement in your app.
https://forums.developer.apple.com/thread/117939#thread-message-373438
1. Add PushKit into your app
Implement Apple's PushKit API directly into your app to get a VoIP token.
See Apple's VoIP Best Practices for more help on getting set up.
2. Create a new OneSignal app for your VoIP device subscribers
Setup a 2nd OneSignal App with a different App ID specifically for your VoIP notifications. You should have 2 apps:
- Push App for "regular" notifications.
- VoIP App for VoIP notifications.
The certificate uploaded for the VoIP app must be a VoIP Services Certificate, which is a p12. You must use the same bundle id for the VoIP cert as you do for your main app.
Example p12 as seen in your Keychain Access:
3. Add the device with a VOIP token
Once you have a VoIP token use the Create user API to add the subscription to your VoIP app.
IMPORTANT: Common errors occur here
Include the
test_type
if you are generating the VoIP token in a sandbox or development environment.This is the reason for seeing "Failed" or "Errored" notifications and a "Mismatched Subscription Environment" error in your app's settings page, see details here.
curl --request POST \
--url https://api.onesignal.com/apps/your-onesignal-app-id/users \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"subscriptions": [
{
"type": "iOSPush",
"token": "your-voip-token",
"test_type": 1 //omit this on Production APNS environment
}
]
}
'
If you are updating the VoIP token for the same device, you can use the Update subscription API.
4. Send VoIP notifications
You can then start using OneSignal create notification REST API POST call to send notifications.
Make sure to use:
- the parameter
apns_push_type_override
with the valuevoip
- the
app_id
for your VoIP App.
curl --include \
--request POST \
--header "Content-Type: application/json; charset=utf-8" \
--header "Authorization: Basic YOUR_REST_API_KEY" \
--data-binary "{\"app_id\": \"YOUR_VOIP_APP_ID\",
\"contents\": {\"en\": \"English Message\"},
\"apns_push_type_override\": \"voip\",
\"include_player_ids\": [\"YOUR_PLAYER_ID\"]}" \
https://onesignal.com/api/v1/notifications
FAQ
Do confirmed deliveries work with VOIP?
Since VoIP notifications work much differently than regular push, Confirmed Deliveries will not be tracked for them. Confirmed Deliveries requires the Notification Service Extension, which may not start with VoIP.
The recommended option is to set up the iOS VoIP event: pushRegistry(_:didReceiveIncomingPushWith:for:completion:)
which is simpler as it is part of your main app target instead of having to bridge to the Notification Service Extension.
More details on this event in Apple's VoIP docs.
Updated about 2 months ago