-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUILocalNotification.m
More file actions
30 lines (26 loc) · 893 Bytes
/
Copy pathUILocalNotification.m
File metadata and controls
30 lines (26 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// UILocalNotification.m
// SupplementTracker
//
// Created by Chris Sheldrick on 6/12/11.
// Copyright 2011 Chris Sheldrick. All rights reserved.
//
#import "UILocalNotification.h"
@implementation UILocalNotification (incrementBadge)
+(void)setBadge
{
NSArray *notifArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
int count = [notifArray count];
for (int x = 0; x < count; x++)
{
if (count > 0 )
{
UILocalNotification *localNotif = [notifArray objectAtIndex:x];
[[UIApplication sharedApplication] cancelLocalNotification:localNotif];
localNotif.applicationIconBadgeNumber = x + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
//NSLog(@"notif: %@ badge %i", localNotif, localNotif.applicationIconBadgeNumber);
}
}
}
@end