Cordova VoIP Calls
Этот контент еще не доступен на вашем языке.
Pushwoosh supports VoIP-style call notifications for iOS and Android using the pushwoosh-cordova-plugin
. This enables native VoIP call functionality, including incoming call UI and call control events.
1. Add the Pushwoosh Cordova plugin with VoIP enabled
Anchor link toInstall the plugin with the VoIP flag enabled:
cordova plugin add pushwoosh-cordova-plugin --variable PW_VOIP_IOS_ENABLED=true
This will configure the plugin to support VoIP functionality on iOS.
2. Add the PushwooshVoIP CocoaPod dependency
Anchor link toMake sure the PushwooshVoIP
pod is included automatically via the plugin. If needed, manually verify in your Podfile
:
pod 'PushwooshVoIP'
This pod is required to support PushKit-based VoIP notifications and system-level call handling.
3. Enable VoIP background mode in Xcode
Anchor link toOpen your project in Xcode and follow these steps:
- Go to Signing & Capabilities.
- Add Background Modes capability.
- Check the Voice over IP option.
This allows your app to receive incoming VoIP pushes while in the background.
4. Configure VoIP app code (if using both VoIP and regular pushes)
Anchor link toIf your app uses both standard and VoIP pushes, you must explicitly set the VoIP application code before VoIP initialization:
pushwoosh.setVoipAppCode("XXXXX-XXXXX");
Replace "XXXXX-XXXXX"
with the Pushwoosh App Code assigned to your VoIP-enabled application in the Pushwoosh Control Panel.
5. Request call permission on Android
Anchor link toOn Android, you require to request to grant a permission to receive calls from a user. To do that, call the requestCallPermission()
method. This should be done before registering a device.
pushwoosh.requestCallPermission();
6. Initialize VoIP parameters
Anchor link toCall the following method to initialize VoIP functionality:
PushNotification.prototype.initializeVoIPParameters = function(supportsVideo, ringtoneSound, handleTypes, success, error) { if (typeof handleTypes === "function") { error = ringtoneSound; success = supportsVideo; handleTypes = undefined; ringtoneSound = undefined; supportsVideo = undefined; }
exec(success, error, "PushNotification", "initializeVoIPParameters", [ !!supportsVideo, ringtoneSound || "", handleTypes != null ? Number(handleTypes) : 1 ]);};
Parameters
Anchor link tosupportsVideo
–true
orfalse
depending on whether your app supports video callsringtoneSound
– custom ringtone file name (e.g."incoming.caf"
), or empty string for defaulthandleTypes
– numeric bitmask for call handle types (1
for phone number,2
for email, etc.)
7. Available VoIP callbacks and methods
Anchor link toThe Cordova plugin supports the following VoIP-related methods and events:
answer
– called when a user answers an incoming callendCall
– called when a user ends the current callhangup
– called when a call is hung upreject
– called when an incoming call is rejectedmuted
– toggle mute status, iOS-onlyheld
– toggle hold status, iOS-onlyvoipPushPayload
– returns push payload for the incoming VoIP callincomingCallSuccess
– called when system call UI is successfully shown, iOS-onlyincomingCallFailure
– called when system call UI fails to show, iOS-onlyspeakerOn
– turn speaker onspeakerOff
– turn speaker offplayDTMF
– play DTMF tone during a call, iOS-only
These can be hooked using Cordova’s PushNotification
object, allowing you to control and respond to VoIP call state changes.