首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pushRegistry(:didUpdate:for)未被调用

pushRegistry(:didUpdate:for)未被调用
EN

Stack Overflow用户
提问于 2020-03-09 18:37:29
回答 1查看 579关注 0票数 0

我已经查看了所有有关这方面的问题,但是这些问题的答案已经应用到我的项目中,但是pushRegistry()委托方法并没有被调用。

首先,这是代码:

代码语言:javascript
复制
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天。

EN

回答 1

Stack Overflow用户

发布于 2021-08-26 10:57:41

  1. 您的PKPushRegistry对象在registerVoIPPush()方法完成后立即被释放,检查是否设置了适当的背景模式

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60606515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档