Joh*_*tam 8 xcode push-notification ios parse-platform ios7
嗨,我正在开发一个使用推送通知的应用程序.我已经成功地使用它与Parse一起工作,我的应用程序正在接收通知.我的问题不是当我打开应用程序时如何重置徽章,因为我已经使用此代码.
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
Run Code Online (Sandbox Code Playgroud)
该代码从应用程序中删除徽章,但当我发送另一个通知时,该号码现在是2而不是1.我该如何解决这个问题?
Nit*_*hel 15
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;解析时无法清除徽章.我刚刚阅读了Parse Push通知指南文档和文档说明.
徽章: iOS应用的图标徽章的当前值.在PFInstallation上更改此值将更新应用程序图标上的徽章值.应将更改保存到服务器,以便将来用于徽标增量推送通知.
徽章:(仅限iOS)应用程序图标右上角显示的值.这可以设置为值或增量,以便将当前值增加1.
清除徽章您需要执行以下代码:
- (void)applicationDidBecomeActive:(UIApplication *)application {
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if (currentInstallation.badge != 0) {
currentInstallation.badge = 0;
[currentInstallation saveEventually];
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5073 次 |
| 最近记录: |