在没有推送通知的情况下更新 iOS 徽章 [英] Updating iOS badge without push notifications

查看:21
本文介绍了在没有推送通知的情况下更新 iOS 徽章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些待办事项应用程序会在午夜更新其应用程序徽章,始终显示正确的到期任务数.他们在不使用推送通知的情况下做到这一点 - 所以我的问题是:他们是如何做到这一点的?他们是否使用本地通知——如果是这样,当设备关闭时这些通知会被调用吗?我有点困惑,希望能提供一些意见.

I have seen a few todo apps that update their app badges at midnight, always showing the correct number of due tasks. They do this without the use of Push Notifications - so my question is: how do they do this? Do they use local notifications - if so, do these get called when the device is turned off? I'm a little confused and would appreciate some input.

推荐答案

试试这个

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];

要通过本地通知执行此操作,您必须在 applicationIconBadgeNumber 中设置值

To do this through local notifications you have to set the value in applicationIconBadgeNumber

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.applicationIconBadgeNumber = 1;// set here the value of badge

这篇关于在没有推送通知的情况下更新 iOS 徽章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆