Commit ebbfc4d0 by Sebastián Katzer

Auto increment badge number on iOS

parent fe66fcaf
......@@ -360,7 +360,6 @@
*/
- (void) didReceiveLocalNotification:(NSNotification*)localNotification
{
UIApplication* app = [UIApplication sharedApplication];
UILocalNotification* notification = [localNotification object];
BOOL autoCancel = notification.options.autoCancel;
......@@ -368,7 +367,8 @@
NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click";
app.applicationIconBadgeNumber -= 1;
[UIApplication sharedApplication]
.applicationIconBadgeNumber -= 1;
[self fireEvent:event localNotification:notification];
......
......@@ -101,7 +101,13 @@
*/
- (NSInteger) badgeNumber
{
return [[dict objectForKey:@"badge"] intValue];
NSInteger number = [[dict objectForKey:@"badge"] intValue];
if (number == -1) {
number = 1 + [UIApplication sharedApplication].applicationIconBadgeNumber;
}
return number;
}
#pragma mark -
......
......@@ -64,7 +64,7 @@ exports._defaults = {
message: '',
title: '',
autoCancel: false,
badge: 0,
badge: -1,
id: '0',
json: '',
repeat: ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment