applicationIconBadgeNumber未更新或增加

时间:2016-06-13 02:52:40

标签: swift uilocalnotification

我是iOS开发的新手!我尝试使用func createLocalNotification(structure:Structure) { let localNotification = UILocalNotification() localNotification.category = "CATEGORY" localNotification.alertBody = "\(structure.messageBody)" localNotification.alertAction = "see" localNotification.soundName = UILocalNotificationDefaultSoundName localNotification.userInfo = ["uuid":structure.UUID] localNotification.fireDate = structure.date localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1 print(localNotification) UIApplication.sharedApplication().scheduleLocalNotification(localNotification) } 创建应用。这就是我所做的:

applicationBadgeNumber

效果很好!我的问题行是property。这df = pd.DataFrame([[6, 3.14, 'c','d',4.2,'e']]) 似乎有效。但是当应用程序处于非活动状态时不会增加。然后一个应用程序启动Xcode给我一个错误:

快照未呈现的视图会导致空快照。确保在屏幕更新后快照或快照之前,您的视图至少呈现过一次。

意味着什么?怎么了?谢谢你的帮助!

2 个答案:

答案 0 :(得分:2)

您是否尝试过使用SoundBadge设置注册设置?

这样的事情:(部分来自this link

@IBAction func registerLocal(sender: AnyObject) {
    let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
}

答案 1 :(得分:1)

由于我没有足够的回复来评论。在您的应用程序未运行时,您能够动态设置徽章编号的唯一方法是使用推送通知。您必须在服务器端跟踪更新

当您的应用在后台时,无法使用本地通知动态更新徽章编号。您必须使用推送通知