2017-10-10 83 views
0

我試圖建立一個PKPushRegistry,所以我可以接收VOIP服務推送但我的代表沒有開火。我成功找回了一個設備,所以我知道這個過程的第一部分工作。另外,我的服務器擁有適合這兩種推送的證書。Voip服務(PKPush)委託方法不被調用

class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate { 

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { 

      self.voipRegistration() 
    } 

    func voipRegistration() { 
     let mainQueue = DispatchQueue.main 
     let voipRegistry: PKPushRegistry = PKPushRegistry(queue: mainQueue) 
     voipRegistry.delegate = self 
     voipRegistry.desiredPushTypes = [PKPushType.voIP] 
    } 


    func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) { 
     // 
    } 

    func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) { 
     // 
    } 

    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { 
     // 
    } 


    func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping() -> Void) { 
     // 
    } 

回答

2

蘋果把VOIP出背景的模式,所以我手動添加它和它的工作

<key>UIBackgroundModes</key> 
<array> 
    <string>audio</string> 
    <string>voip</string> 
    <string>fetch</string> 
    <string>remote-notification</string> 
</array>