Commit ebbfc4d0 authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Auto increment badge number on iOS

parent fe66fcaf
Loading
Loading
Loading
Loading
+2 −2
Changes for src/ios/APPLocalNotification.m: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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];

+7 −1
Changes for src/ios/APPLocalNotificationOptions.m: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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 -
+1 −1
Changes for www/local-notification.js: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ exports._defaults = {
    message:    '',
    title:      '',
    autoCancel: false,
    badge:      0,
    badge:      -1,
    id:         '0',
    json:       '',
    repeat:     ''