I am using Urban Airship for push notifications and showing a badge on a UIButton on the home screen of my app. This works fine if the app is in a closed state and not in the background. The problem I'm having is that if the app isn't in a closed state and a push notification comes through, the home screen of the app doesn't refresh to show the badge on the button.
Here is the code I'm currently using to show the badge.
In viewDidLoad
Button
Here is the code I'm currently using to show the badge.
In viewDidLoad
Code:
badgeNumber = [NSString stringWithFormat:@"%d", [[UIApplication sharedApplication]applicationIconBadgeNumber]];
actionAlertBadge = [JSCustomBadge customBadgeWithString:badgeNumber];
actionAlertBadge.frame = CGRectMake(83, 6, 30, 30);
if ([badgeNumber isEqualToString:@"0"])
{
actionAlertBadge.hidden = YES;
}
[self.view addSubview:actionAlertBadge];
Button
Code:
- (IBAction)gotoActionAlerts
{
ActionAlertsViewController *actionAlerts = [[ActionAlertsViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[actionAlerts setWebViewController:wvc];
actionAlerts.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[[UAPush shared] resetBadge];
actionAlertBadge.hidden = YES;
[self.navigationController pushViewController:actionAlerts animated:YES];
}
Last edited: