VoIP-Pushes
In iOS 8 hat Apple PushKit und VoIP-Pushes eingeführt – eine neue Art von Push-Benachrichtigungen. Zusätzlich zur Standard-Push-Funktionalität ermöglicht ein VoIP-Push der App, Code auszuführen, bevor die Benachrichtigung dem Benutzer angezeigt wird.
1. Fügen Sie das PushwooshVoIP-Modul zu Ihrem Projekt hinzu.
Swift Package Manager

Cocoapods
# Uncomment the next line to define a global platform for your project# platform :ios, '9.0'
target 'MyApp' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks!
pod 'PushwooshXCFramework' pod 'PushwooshFramework/PushwooshVoIP'
end2. Fügen Sie im Tab Signing & Capabilities die Fähigkeit Voice over IP hinzu, indem Sie das Kontrollkästchen aktivieren, wie im folgenden Screenshot gezeigt:

3. Initialisieren Sie das PushwooshVoIP-Modul, wie im folgenden Code gezeigt.
import UIKitimport PushwooshFrameworkimport PushwooshVoIPimport CallKitimport PushKit
@mainclass AppDelegate: UIResponder, UIApplicationDelegate, PWVoIPCallDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
/// Initializes the Pushwoosh VoIP module. /// /// - Parameters: /// - supportVideo: A Boolean value indicating whether video calls are supported. /// - ringtoneSound: The name of the custom ringtone sound file to be used for incoming calls (e.g. `"mySound.caf"`). /// - handleTypes: The type of call handle to support. Possible values: /// - `1` – Generic /// - `2` – Phone number /// - `3` – Email address Pushwoosh.VoIP.initializeVoIP(true, ringtoneSound: "mySound.caf", handleTypes: 1)
// Set delegate to receive VoIP call events Pushwoosh.VoIP.delegate = self
return true }
// MARK: - Required PWVoIPCallDelegate Callbacks
func voipDidReceiveIncomingCall(payload: PushwooshVoIP.PWVoIPMessage) { // Handle incoming VoIP push }
func pwProviderDidReset(_ provider: CXProvider) { // Handle provider reset }
func pwProviderDidBegin(_ provider: CXProvider) { // Handle provider activation }}4. Das PWVoIPCallDelegate-Protokoll definiert erforderliche und optionale Callbacks zur Handhabung des VoIP-Anruf-Lebenszyklus und der CallKit-Interaktionen.
@objc public protocol PWVoIPCallDelegate: NSObjectProtocol {
/// Called when an incoming VoIP push is received. @objc func voipDidReceiveIncomingCall(payload: PushwooshVoIP.PWVoIPMessage)
/// Optional: Called when the incoming call was successfully reported to CallKit. @objc optional func voipDidReportIncomingCallSuccessfully(voipMessage: PushwooshVoIP.PWVoIPMessage)
/// Optional: Called when reporting the incoming call to CallKit failed. @objc optional func voipDidFailToReportIncomingCall(error: Error)
/// Optional: Called when a new outgoing call is started. @objc optional func startCall(_ provider: CXProvider, perform action: CXStartCallAction)
/// Optional: Called when an active call is ended. @objc optional func endCall(_ provider: CXProvider, perform action: CXEndCallAction, voipMessage: PushwooshVoIP.PWVoIPMessage?)
/// Optional: Called when an incoming call is answered. @objc optional func answerCall(_ provider: CXProvider, perform action: CXAnswerCallAction, voipMessage: PushwooshVoIP.PWVoIPMessage?)
/// Optional: Called when the call is muted or unmuted. @objc optional func mutedCall(_ provider: CXProvider, perform action: CXSetMutedCallAction)
/// Optional: Called when the call is held or unheld. @objc optional func heldCall(_ provider: CXProvider, perform action: CXSetHeldCallAction)
/// Optional: Called when a DTMF tone is played. @objc optional func playDTMF(_ provider: CXProvider, perform action: CXPlayDTMFCallAction)
/// Called when the CallKit provider is reset. @objc func pwProviderDidReset(_ provider: CXProvider)
/// Called when the CallKit provider begins. @objc func pwProviderDidBegin(_ provider: CXProvider)
/// Optional: Provides the CallKit call controller instance. @objc optional func returnedCallController(_ controller: CXCallController)
/// Optional: Provides the CallKit provider instance. @objc optional func returnedProvider(_ provider: CXProvider)
/// Optional: Called when the audio session is activated. @objc optional func activatedAudioSession(_ provider: CXProvider, didActivate audioSession: AVAudioSession)
/// Optional: Called when the audio session is deactivated. @objc optional func deactivatedAudioSession(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession)}5. Laden Sie Ihr VoIP-Zertifikat gemäß der Konfigurationsanleitung in das Pushwoosh Control Panel hoch und wählen Sie das Produktions-Gateway.
Das war’s!
Teilen Sie Ihr Feedback mit uns
Anchor link toIhr Feedback hilft uns, eine bessere Erfahrung zu schaffen. Wir würden uns daher freuen, von Ihnen zu hören, wenn Sie während des SDK-Integrationsprozesses auf Probleme stoßen. Sollten Sie Schwierigkeiten haben, zögern Sie bitte nicht, uns Ihre Gedanken über dieses Formular mitzuteilen.