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

查看:239
本文介绍了迁移到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演示 目标c演示也在那里 下面是快速代码,用于注册Push Kit和接收Pushkit负载.

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天全站免登陆