しばらくの間、「うまくいく」はずの何かに苦労してきました。Urban Airship を介してプッシュ通知を設定しましたが、アプリがバックグラウンドにある間にバッジが更新されることを除いて、すべて正常に動作します。私が知る限り、バッジがペイロードで整数に設定されている限り、アプリがフォアグラウンドにない場合、これはそれ自体を処理するはずです。
アプリがフォアグラウンドにあるときにバッジの更新をキャプチャすると、適切に設定できますが、それがアプリでバッジを使用する理由ではありません。
これが私のセットアップですdidFinishLaunchingWithOptions:
UAConfig *config = [UAConfig defaultConfig];
// You can also programatically override the plist values:
// config.developmentAppKey = @"YourKey";
// etc.
// Call takeOff (which creates the UAirship singleton)
[UAirship takeOff:config];
[UAPush shared].notificationTypes = (UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeNewsstandContentAvailability);
[[UAPush shared] setPushEnabled:YES];
[[UAPush shared] setAutobadgeEnabled:YES];
[self performSelector:@selector(resetUABadge:)];
[[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
applicationState:application.applicationState];
resetUABadge 呼び出しは、アプリの起動時にすべてを 0 に戻すだけです。この問題は、その performSelector があるかどうかにかかわらず持続します。
不足している構成があるかどうかはわかりませんが、プッシュ通知の他のすべての部分は、アプリがバックグラウンド/クローズされている間 (アラート、サウンド) に機能しますが、バッジは更新されません。