gpt4 book ai didi

ios - pushRegistry :didUpdate:pushCredentials not being called

转载 作者:行者123 更新时间:2023-11-28 18:15:08 27 4
gpt4 key购买 nike

查看了过去关于此的问题,但这些问题的答案已应用于我的项目,但未调用 pushRegistry() 委托(delegate)方法。

首先是代码:

import UIKit
import PushKit
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate{

var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let notificationSettings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil)
application.registerUserNotificationSettings(notificationSettings)

UNUserNotificationCenter.current().delegate = self
UIApplication.shared.registerForRemoteNotifications()

let voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
voipRegistry.desiredPushTypes = Set([PKPushType.voIP])
voipRegistry.delegate = self;

return true
}
...
}

extension AppDelegate: PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
NSLog("voip token: \(pushCredentials.token)")
}

已启用以下应用程序功能:- 推送通知- 背景模式- 后台获取- 远程通知

我正在使用 Xcode 9.1 Beta,它不再将 Voip 作为一项显式功能,显然这不再需要,导入 PushKit 就足够了。

在配置门户上,已为应用程序 ID 启用推送通知。(已经生成了一个 Void Push 证书,但显然还不能用它来发送推送)

最佳答案

apparently this is no longer needed and importing PushKit should suffice.

我读了几篇帖子说这个,但它不正确。为了让事情正常进行,我必须手动编辑 info.plist 以将 voip 添加到背景模式列表中。

 <string>voip</string>

Apple 在玩什么?如果仍然需要,为什么他们将其从 Xcode 中删除?

关于ios - pushRegistry :didUpdate:pushCredentials not being called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46942345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com