答案 0 :(得分:5)
你可以随处设置它。 E.g:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:123]; // this one
}
答案 1 :(得分:3)
当您收到通知时,会调用此方法:
application:didReceiveRemoteNotification:
这将包含NSDictionary
`(NSDictionary *)userInfo`
使用
功能更新应用图标徽章计数[UIApplication sharedApplication].applicationIconBadgeNumber = [[[userInfo objectForKey:@"aps"] objectForKey: @"badgecount"] intValue];
您的有效负载如下所示:
{
"aps" : {
"alert" : "You got your emails.",
"badge" : 9
}
}
要隐藏徽章,请使用零(0)
答案 2 :(得分:1)
它叫做徽章,你可以写下面一行来实现这个目标:
private static void Main(string[] args)
{
new Check().UseDelegate();
}
如果您想了解其在样本申请中的工作情况,请参阅以下链接:
http://www.touch-code-magazine.com/how-to-add-a-badge-to-the-application-icon/
答案 3 :(得分:0)
在Swift 4中,您可以通过添加以下行来设置徽章:
>>>>import rae
>>>>help(rae)
Help on package rae:
NAME
rae - # -*- coding: utf-8 -*-
FILE
/home/sahil/.local/lib/python2.7/site-packages/rae/__init__.py
PACKAGE CONTENTS
CLASSES
__builtin__.object
Article
DA
DEJ
DLE
DPD
class Article(__builtin__.object)
| Methods defined here:
|