我正在为VoIP推送通知搜索有关推送通知的信息。在我看来,有一点仍然不清楚:
1)如果用户尚未打开该应用程序,则该用户将收到一个呼叫。是否有从通知中启动应用程序的方法?
2)应用程序如何等待特定事件?例如,我的设备怎么知道他接到了某个人的电话?
3)我使用了来自https://github.com/Hitman666/ios-voip-push的应用程序委托文件,但在我的例子中,它不能工作(很多错误),这里是我得到的错误的预览。
谢谢
发布于 2017-05-10 13:44:30
1)如果用户尚未打开该应用程序,则该用户将收到一个呼叫。是否有从通知中启动应用程序的方法?
-第一次用户必须点击应用程序图标,并打开它,然后只有设备id将获得注册,以接收推送工具包的有效载荷。那就不需要打开应用程序了。当应用程序处于死状态时,它也可以工作,并且您必须按照push kit有效载荷来安排本地通知。
2)应用程序如何等待特定事件?例如,我的设备怎么知道他接到了某个人的电话?
-您必须按照push kit的有效载荷来安排本地通知。
3)我使用了来自https://github.com/Hitman666/ios-voip-push的应用程序委托文件,但是在我的例子中它不能工作(很多错误),这里是我得到的错误的预览。
-请参阅下面的代码
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
}
}获取有关如何集成基于VOIP的应用程序的推送工具包的更多信息。
刚刚更新的Swift 4.0代码以及。
https://stackoverflow.com/questions/43638814
复制相似问题