Commit ebbfc4d0 by Sebastián Katzer

Auto increment badge number on iOS

parent fe66fcaf
...@@ -360,7 +360,6 @@ ...@@ -360,7 +360,6 @@
*/ */
- (void) didReceiveLocalNotification:(NSNotification*)localNotification - (void) didReceiveLocalNotification:(NSNotification*)localNotification
{ {
UIApplication* app = [UIApplication sharedApplication];
UILocalNotification* notification = [localNotification object]; UILocalNotification* notification = [localNotification object];
BOOL autoCancel = notification.options.autoCancel; BOOL autoCancel = notification.options.autoCancel;
...@@ -368,7 +367,8 @@ ...@@ -368,7 +367,8 @@
NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click"; NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click";
app.applicationIconBadgeNumber -= 1; [UIApplication sharedApplication]
.applicationIconBadgeNumber -= 1;
[self fireEvent:event localNotification:notification]; [self fireEvent:event localNotification:notification];
......
...@@ -101,7 +101,13 @@ ...@@ -101,7 +101,13 @@
*/ */
- (NSInteger) badgeNumber - (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 - #pragma mark -
......
...@@ -64,7 +64,7 @@ exports._defaults = { ...@@ -64,7 +64,7 @@ exports._defaults = {
message: '', message: '',
title: '', title: '',
autoCancel: false, autoCancel: false,
badge: 0, badge: -1,
id: '0', id: '0',
json: '', json: '',
repeat: '' 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