我已经查看了所有有关这方面的问题,但是这些问题的答案已经应用到我的项目中,但是pushRegistry()委托方法并没有被调用。
首先,这是代码:
import UIKit
import PushKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
print("App Launched");
self.registerVoIPPush();
return true
}
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
print("didUpdate");
print(pushCredentials);
print(type);
if type == PKPushType.voIP {
let tokenData = pushCredentials.token
let voipPushToken = String(data: tokenData, encoding: .utf8)
print(voipPushToken);
//send token to server
}
}
func registerVoIPPush() {
print("registerVoIPPush");
let voipPushResgistry = PKPushRegistry(queue: DispatchQueue.main)
voipPushResgistry.delegate = self
voipPushResgistry.desiredPushTypes = [PKPushType.voIP]
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
print(payload);
ATCallManager.shared.incommingCall(from: "jane@example.com", delay: 0)
}
}i还启用了以下应用程序功能:-推送通知-后台模式-后台获取-远程通知- IP语音
我正在使用Xcode11.3 &使用iOS13.2构建
在供应门户上,已为应用程序id启用了推送通知。(已经生成了一个VoIP推送证书&也导入到了密钥链访问中,但显然还不能使用它来发送推送)。
任何帮助都将是非常感谢的,因为我正试图做到这一点,从过去的3天。
发布于 2021-08-26 10:57:41

https://stackoverflow.com/questions/60606515
复制相似问题