Commit ba9f4f63 by Samuel Michelot

Add option to display a message or just to update the badge (hasAction = not).…

Add option to display a message or just to update the badge (hasAction = not). And don't play sound if nothing is specified
parent b38b96a1
......@@ -106,16 +106,25 @@
NSString* title = [options objectForKey:@"title"];
NSString* sound = [options objectForKey:@"sound"];
NSString* repeat = [options objectForKey:@"repeat"];
bool hasAction = ([[options objectForKey:@"hasAction"] intValue] == 1)?YES:NO;
NSInteger badge = [[options objectForKey:@"badge"] intValue];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:timestamp];
UILocalNotification* notification = [[UILocalNotification alloc] init];
notification.fireDate = date;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.repeatInterval = [[[self repeatDict] objectForKey: repeat] intValue];
if ([msg isEqualToString:@""]) {
//No message, we just want to update the badge
notification.alertBody = nil;
} else {
notification.alertBody = title ? [NSString stringWithFormat:@"%@\n%@", title, msg] : msg;
}
if ( ! [sound isEqualToString:@""]) {
notification.soundName = sound;
}
notification.hasAction = hasAction;
notification.applicationIconBadgeNumber = badge;
return notification;
......
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