【问题标题】:turn off and on notifications when app is completely closed当应用程序完全关闭时关闭和打开通知
【发布时间】:2017-10-24 13:54:02
【问题描述】:

我已经在我的项目中安装了 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)`

}

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

【问题讨论】:

    标签: ios swift uilocalnotification uiswitch onesignal


    【解决方案1】:

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

    【讨论】:

    • 对。我对其进行了测试,即使应用程序关闭,OneSignal 也会删除所有通知
    猜你喜欢
    • 1970-01-01
    • 2020-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多