相关疑难解决方法(0)

UILocalNotification在iOS10中已弃用

这可能是一个问题,但我想知道要使用什么而不是UILocalNotificationiOS10.我正在开发一个部署目标为iOS8的应用程序,所以可以使用UILocalNotification吗?

ios uilocalnotification

41
推荐指数
2
解决办法
5万
查看次数

用户通知框架徽章不会增加

UserNotification在我的应用程序中使用框架并发送本地通知(不是推送通知),我想将徽章设置为收到的通知数量,所以我所做的是将收到的通知数量设置为用户默认值然后我尝试将值分配给徽章以获取徽章编号,但徽章编号不会增加.这是我的代码

设置接收通知的值

center.getDeliveredNotifications { notification in

    UserDefaults.standard.set(notification.count, forKey: Constants.NOTIFICATION_COUNT)
    print("notification.count \(notification.count)")
    print(".count noti \(UserDefaults.standard.integer(forKey: Constants.NOTIFICATION_COUNT))")

}
Run Code Online (Sandbox Code Playgroud)

这准确地打印了收到的通知数量,当我决定将其设置为我的徽章时,它只显示1

content.badge = NSNumber(value: UserDefaults.standard.integer(forKey: Constants.NOTIFICATION_COUNT))
Run Code Online (Sandbox Code Playgroud)

我不知道为什么价值不会每次都增加.任何帮助,将不胜感激.

或者,如果可以随时在应用程序中的任何位置更新徽章.

ios swift usernotifications

7
推荐指数
1
解决办法
676
查看次数