如何在iPhone上启动应用程序时检查徽章编号 [英] How to check for a badge number on app launch on iPhone
问题描述
如何检查我的应用程序是否具有徽章编号.当我向用户发送推送通知时,它会在图标上添加"1"作为徽章编号.我想检查用户启动应用程序并将其定向为视图控制器时是否有徽章编号.
How can I check if my app has a badge number. When I send a push notification the users, it add a "1" as the badge number to the icon. I would like to check if there is a badge number when the user launches the app and direct them a view controller.
推荐答案
我会适当地使用-(BOOL)application:(UIApplication *)application的属性
的应用程序. applicationIconBadgeNumber
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I'd propably make use of the property applicationIconBadgeNumber
of the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
's application.
因此,要明确一点:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
application.applicationIconBadgeNumber = 1; /*some number...*/
//or to read the number
int appIconBadge = application.applicationIconBadgeNumber;
}
希望有帮助.
这篇关于如何在iPhone上启动应用程序时检查徽章编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!