问题
How can I prevent PushPlugin from reseting my badge count to 0 after entering the app from the background?
回答1:
I just came across this problem as well.
For some reason this is intended behaviour. It's because in the com.phonegap.plugins.PushPlugin, the badge get cleared to 0 when the app get active again.
I ended up editing the plugin:
In the file "AppDelegate+notification.m", in the method:
"- (void)applicationDidBecomeActive:(UIApplication *)application {"
Change line ~90:
//zero badge
application.applicationIconBadgeNumber = 0;
to:
//zero badge
//application.applicationIconBadgeNumber = 0;
(I just ended up commenting it out).
来源:https://stackoverflow.com/questions/24601874/phonegap-pushplugin-reset-badge-after-opening-app