gpt4 book ai didi

ios - 当应用程序完全关闭时关闭和打开通知

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

我已经在我的项目中安装了 OneSiganl,我关闭本地通知的方法是:OneSignal.setSubscription(false)我还补充说UNUserNotificationCenter.current().removeAllPendingNotificationRequests()

现在我有一个开关,当开关关闭时,我将开关状态保存在 NSUserDefaults 中

if NSUserDefaults.state == "OFF"{
`OneSignal.setSubscription(false)`

`UNUserNotificationCenter.current().removeAllPendingNotificationRequests()`
}

if NSUserDefaults.state == "ON"{
`OneSignal.setSubscription(true)`

}

我的问题是当用户完全关闭应用程序时,他/她是否会收到从我的服务器发送的通知?如果用户打开开关,他们会收到通知吗?

最佳答案

UNUserNotificationCenter.current().removeAllPendingNotificationRequests() 仅删除本地预定通知。如果您正确注册了远程通知(并且我假设 OneSignal 会为您完成此操作以及如何根据请求许可设置应用程序权限和用户消息的说明,但我不熟悉该框架)那么您的答案问题是:是的。

关于ios - 当应用程序完全关闭时关闭和打开通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46912386/

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