无需推送通知即可更新iOS徽章 [英] Updating iOS badge without push notifications

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

问题描述

我已经看到一些todo应用程序在午夜更新其应用徽章,始终显示正确的任务数量。他们这样做没有使用推送通知 - 所以我的问题是:他们是如何做到这一点的?他们是否使用本地通知 - 如果是,请在关闭设备时调用这些通知吗?我有点困惑,并希望得到一些意见。

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 <中设置值/ code>

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天全站免登陆