Last active
October 14, 2015 01:43
-
-
Save seaders/d3c9239d682e6223a6ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LocalNotification(NSString* body, int seconds, NSString* action) | |
{ | |
UILocalNotification *localNotification = [ [UILocalNotification alloc] init ]; | |
if(localNotification == nil) | |
{ | |
return; | |
} | |
// Set the fire date/time | |
[ localNotification setFireDate: [ [NSDate date] dateByAddingTimeInterval: seconds ] ]; | |
[ localNotification setTimeZone: [NSTimeZone defaultTimeZone] ]; | |
localNotification.applicationIconBadgeNumber = 1; | |
[ localNotification setHasAction: ![action isEqual:@""] ]; | |
if( [localNotification hasAction] ) | |
{ | |
[localNotification setAlertAction: action]; | |
} | |
[localNotification setAlertBody: body]; | |
localNotification.soundName=UILocalNotificationDefaultSoundName; | |
[localNotification setHasAction: NO]; | |
UIApplication *app = [UIApplication sharedApplication]; | |
[app scheduleLocalNotification: localNotification]; | |
NSLog(@"LocalNotification in %@ (%@)\nfor %@", localNotification.fireDate, localNotification.timeZone, localNotification.alertBody); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment