2017-04-26 305 views
0

我在搜索有關VoIP推送通知推送通知的信息。一些點尚不清楚對我說:iOS VoIP推送通知(PushKit)

1)如果用戶沒有打開的應用程序,然後,他接到一個電話。是否有通過通知啓動應用程序的意思?

2)如何申請等待特定的事件?例如,我的設備如何知道他接到某人的電話?

3)我使用https://github.com/Hitman666/ios-voip-push的Appdelegate文件,但在我的情況下它不起作用(很多錯誤),here是我得到的錯誤的預覽。

謝謝

+0

參見[如何問問題(https://stackoverflow.com/help/how-to-ask),這是太廣闊! – Honey

回答

2

1)如果用戶還沒有打開應用程序,然後他接到一個電話。是否有通過通知啓動應用程序的意思?

- 首次用戶挖掘上的應用程序圖標,打開它,然後唯一的設備ID將獲得註冊,以便接收推動器的有效載荷。那麼不需要打開應用程序。它也可以在應用程序處於死亡狀態時工作,並且您必須按照推送套件有效負載計劃本地通知。

2)如何申請等待特定的事件?例如,我的設備如何知道他收到某人的電話?

- 你必須安排本地通知按照推動器的有效載荷。

3)我使用https://github.com/Hitman666/ios-voip-push的Appdelegate文件,但在我的情況下它不工作(很多錯誤),這裏是我得到的錯誤的預覽。

- 請參閱下面的代碼

import UIKit 
import PushKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate,PKPushRegistryDelegate { 

    var window: UIWindow? 


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 


     let types: UIRemoteNotificationType = [.Alert, .Badge, .Sound] 
     application.registerForRemoteNotificationTypes(types) 

     self.PushKitRegistration() 

     return true 
    } 

    //MARK: - PushKitRegistration 

    func PushKitRegistration() 
    { 

     let mainQueue = dispatch_get_main_queue() 
     // Create a push registry object 
     if #available(iOS 8.0, *) { 

      let voipRegistry: PKPushRegistry = PKPushRegistry(queue: mainQueue) 

      // Set the registry's delegate to self 

      voipRegistry.delegate = self 

      // Set the push type to VoIP 

      voipRegistry.desiredPushTypes = [PKPushTypeVoIP] 

     } else { 
      // Fallback on earlier versions 
     } 


    } 


    @available(iOS 8.0, *) 
    func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) { 
     // Register VoIP push token (a property of PKPushCredentials) with server 

     let hexString : String = UnsafeBufferPointer<UInt8>(start: UnsafePointer(credentials.token.bytes), 
      count: credentials.token.length).map { String(format: "%02x", $0) }.joinWithSeparator("") 

     print(hexString) 


    } 


    @available(iOS 8.0, *) 
    func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) { 
     // Process the received push 


    } 

} 

獲取有關如何pushkit基於VOIP的應用程序集成的更多信息。

https://github.com/hasyapanchasara/PushKit_SilentPushNotification