迁移至iOS VoIP推送通知

3
我们有一个VoIP应用,目前正在使用标准的推送通知。我们希望更新到使用PushKit和VoIP推送通知。我有些不确定如何从我们当前的标准APNS设置迁移到新设置。问题如下:
1)我们当前的APNS生产证书能否向新的VoIP客户端发送推送消息?
2)我们的新VoIP推送证书能否向现有的标准APNS应用程序(令牌)发送推送消息?

从 https://developer.apple.com/library/prerelease/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW10 看来,基于令牌的提供者到 APNs 信任可以同时用于标准 APNS 和 VoIP 推送。 - toucan
使用您的 APNS 证书进行简单推送通知,并为 Voip 推送创建新的 Voip 证书。 - Krishna Datt Shukla
1个回答

3
请参考 pushkit 演示 https://github.com/hasyapanchasara/PushKit_SilentPushNotification。还有 Objective C 演示 https://github.com/hasyapanchasara/PushKit_SilentPushNotification/tree/master/Objective%20C%20Demo/PushKitDemoObjectiveC。下面是注册 push kit 并接收 pushkit 负载的 swift 代码。
import UIKit
import PushKit


class AppDelegate: UIResponder, UIApplicationDelegate,PKPushRegistryDelegate{



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
    // From here you have to schedule your local notification

}

}

当您的应用程序基于VOIP时,一旦收到Pushkit负载,则可以安排本地通知。根据交互式本地通知,您可以接收、断开等功能进行处理(与WhatsApp、Skype等相同)。
1)我们当前的APNS生产证书能否向新的VoIP客户端发送推送消息?
答:不行,您需要创建pem文件并在后端进行配置。
2)我们的新VoIP推送证书是否能够向现有的标准APNS应用程序(令牌)发送推送消息?
答:不行,Pushkit令牌将与APNS令牌不同。
更多信息请参阅调试、证书、本地通知。

https://github.com/hasyapanchasara/PushKit_SilentPushNotification


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接