gpt4 book ai didi

ios - scheduleLocalNotification 不调用 didReceiveLocalNotification

转载 作者:可可西里 更新时间:2023-11-01 06:15:29 25 4
gpt4 key购买 nike

我正在使用 UILocalNotification

问题是当我使用 scheduleLocalNotification 发布我的通知时,它永远不会触发 didReceiveLocalNotificationpresentLocalNotificationNow 每次都会触发。

我需要在 didReceiveLocalNotification 中显示一个警报,但使用 scheduleLocalNotification 而不是 presentLocalNotificationNow。

有人遇到过同样的问题吗?

最佳答案

来自本地和远程通知编程指南:

In iOS 8 and later, apps that use either local or remote notifications must register the types of notifications they intend to deliver. The system then gives the user the ability to limit the types of notifications your app displays. The system does not badge icons, display alert messages, or play alert sounds if any of these notification types are not enabled for your app, even if they are specified in the notification payload.

如指南所示,Apple 展示的示例代码是:

UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;

UIUserNotificationSettings *我的设置 = [UIUserNotificationSettings settingsForTypes:types categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

关于ios - scheduleLocalNotification 不调用 didReceiveLocalNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19978398/

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