如何清除在iPhone应用程序的图标点击徽章柜台? [英] How to clear badge counter on click of app icon in iphone?

查看:211
本文介绍了如何清除在iPhone应用程序的图标点击徽章柜台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经开发使用PhoneGap的iOS应用程序,并在我们的应用程序实现的推送通知功能。
推送通知的作品完美的罚款我们。我们已经配置为(警报和徽章),推送通知和两个工作正常。
当我们点击提示列表重定向我们的应用程序,并从提示列表中清除所有的通知,也徽章计数器设置为0。

We have developed an ios app using phonegap and have implemented push notification functionality in our app. Push notification works perfectly fine for us. We have configured push notification for both (alerts and badge) and both works fine. When we click on the alert list it redirects us to the application and clears all the notifications from the alert list and also the badge counter is set to 0.

但是,当我们的应用程序图标上单击(徽章计数器)带来应用推到前台,但徽章柜台和警报没有得到清除。

But when we click on the application icon(badge counter) it brings app to the foreground but the badge counter and alerts are not getting cleared.

我们已经使用按照didFinishLaunchingWithOptions方法(在appdelegate.m文件)code,它清除了警报,只有在点击警报复位徽章

We have used following code in didFinishLaunchingWithOptions method (in appdelegate.m file)that clears out the alerts and resets the badge only on-click of alerts

 application.applicationIconBadgeNumber = 0;

任何人都可以提供给我们,显示相同的行为,当我们点击应用程序图标与徽章柜台的解决方案。

can anyone provide us the solution that shows same behaviour when we click on app icon with badge counter.

推荐答案

要清除当应用程序被激活使用委托

To clear the badge count whenever the application becomes active use delegate method

致电 [UIApplication的sharedApplication] setApplicationIconBadgeNumber:0]; 在任的 applicationWillEnterForeground 也没有 applicationDidBecomeActive

- (void)applicationWillEnterForeground:(UIApplication *)application

{
 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
 }

- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}

斯威夫特

func applicationWillEnterForeground(application: UIApplication) {
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}

func applicationDidBecomeActive(application: UIApplication) {
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}

这篇关于如何清除在iPhone应用程序的图标点击徽章柜台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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