Skip to content

Instantly share code, notes, and snippets.

@mikrobi
Created August 8, 2013 08:21
Show Gist options
  • Save mikrobi/6182683 to your computer and use it in GitHub Desktop.
Save mikrobi/6182683 to your computer and use it in GitHub Desktop.
Use `CDVInvokedUrlCommand ` as parameter to make the `setApplicationIconBadgeNumber` method callable from JavaScript
- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command; {
DLog(@"setApplicationIconBadgeNumber:%@\n", command.arguments);
self.callbackId = command.callbackId;
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
int badge = [[options objectForKey:@"badge"] intValue] ?: 0;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
[self successWithMessage:[NSString stringWithFormat:@"app badge count set to %d", badge]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment