gpt4 book ai didi

ios - 中心 didReceiveNotificationResponse 没有被调用

转载 作者:行者123 更新时间:2023-11-29 11:44:19 74 4
gpt4 key购买 nike

我已经实现了很多次推送服务,即使现在它还在工作,我能够收到通知,但不知道为什么下面的方法没有被调用

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler

我用谷歌搜索并试图找到解决方案,然后我发现了我的代码中已经存在的所有内容,但我仍然面临这个问题,我需要你们的编码人员帮助解决这个问题我们可能错过的任何事情, 任何帮助将不胜感激。

最佳答案

这个方法是一个委托(delegate)方法。因此,要调用它,您必须在头文件中实现 UNUserNotificationCenterDelegate 的委托(delegate)。如果您忘记使用委托(delegate),请将其放在头文件中。下面的示例显示了在头文件中放置名称为 ViewController 的 UIViewController 的委托(delegate):

 @interface ViewController : UIViewController<UNUserNotificationCenterDelegate>

并在方法或实现文件(ViewController.m)中,在其方法viewDidLoad中,放置

self.userNotificationCenter.delegate = self;

希望对您有所帮助:)

关于ios - 中心 didReceiveNotificationResponse 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44700445/

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