迁移到 iOS VoIP 推送通知 [英] Migrate to iOS VoIP push notifications

查看:27
本文介绍了迁移到 iOS VoIP 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 VoIP 应用程序,我们目前正在使用标准推送通知.我们想更新为使用 PushKit 和 VoIP 推送通知.我有点不确定如何从我们当前的标准 APNS 设置迁移到新的.问题:

We have a VoIP app where we are currently using standard push notifications. We would like to update to using PushKit and VoIP push notifications. I'm a bit unsure how to migrate from our current standard APNS setup to the new. Questions:

1) 我们当前的 APNS 生产证书能否向新的 VoIP 客户端发送推送消息?

1) Will our current APNS production certificate be able to send push messages to new VoIP clients?

2) 我们的新 VoIP 推送证书能否向现有的标准 APNS 应用(令牌)发送推送消息?

2) Will our new VoIP push certificate be able to send push messages to existing, standard APNS apps (tokens)?

推荐答案

请参考 pushkit demo https://github.com/hasyapanchasara/PushKit_SilentPushNotification

Objective c 演示也有 https://github.com/hasyapanchasara/PushKit_SilentPushNotification/tree/master/Objective%20C%20Demo/PushKitDemoObjectiveC

下面是注册pushkit和接收pushkit负载的swift代码.

Below is swift code to register for push kit and receive pushkit payload.

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 等相同).

When your app is based on VOIP, then once you receive pushkit payload then you can schedule local notification. As per interactive local notification you can receive, disconnect etc feature can process ( Same like Whatsapp, Skype etc ).

1) 我们当前的 APNS 生产证书能否向新的 VoIP 客户端发送推送消息?

1) Will our current APNS production certificate be able to send push messages to new VoIP clients?

  • 不,您还必须创建 pem 文件并在后端进行配置.

2) 我们的新 VoIP 推送证书能否向现有的标准 APNS 应用(令牌)发送推送消息?

2) Will our new VoIP push certificate be able to send push messages to existing, standard APNS apps (tokens)?

  • 不,Pushkit 令牌将不同于 APNS 令牌.
  • 列表项

有关调试、证书、本地通知的更多信息

https://github.com/hasyapanchasara/PushKit_SilentPushNotification

这篇关于迁移到 iOS VoIP 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆