I want to add an icon icon in UIButton in my application when a notification is sent, and I'm not quite sure how to achieve this. It will have to match the icon on the springboard icon, and the springboard icon and the icon on the UIButton should disappear when that UIButton is clicked in the application.
UPDATE:
I got an icon, but when I open the application, the icon gets reset back to zero when the application opens, so I do not see the icon on the button. I know the icon works because I checked it by doing the following:
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:1];
Here is the code for the icon:
NSString *badgeNumber = [NSString stringWithFormat:@"%d", [[UIApplication sharedApplication]applicationIconBadgeNumber]];
JSCustomBadge *actionAlertBadge = [JSCustomBadge customBadgeWithString:badgeNumber];
actionAlertBadge.frame = CGRectMake(188, 6, 30, 30);
[self.view addSubview:actionAlertBadge];
if ([badgeNumber isEqual:@"0"])
{
actionAlertBadge.hidden = YES;
}
How can I get the icon without reset when opening the application, but instead of reset when I click this button in the application?
, . , UIButton. , reset, , UIButton, . , , - , , .
- (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];
}
In viewDidLoad
badgeNumber = [NSString stringWithFormat:@"%d", [[UIApplication sharedApplication]applicationIconBadgeNumber]];
actionAlertBadge = [JSCustomBadge customBadgeWithString:badgeNumber];
actionAlertBadge.frame = CGRectMake(83, 6, 30, 30);
[self.view addSubview:actionAlertBadge];
if ([badgeNumber isEqualToString:@"0"])
{
actionAlertBadge.hidden = YES;
}