Skip to content

Instantly share code, notes, and snippets.

@keicoder
Created February 24, 2014 03:35
Show Gist options
  • Select an option

  • Save keicoder/9181549 to your computer and use it in GitHub Desktop.

Select an option

Save keicoder/9181549 to your computer and use it in GitHub Desktop.
objective-c : basic local notifications
//basic local notifications
#pragma mark - didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
//local notifications test
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:10];
UILocalNotification *localNotification =
[[UILocalNotification alloc] init];
localNotification.fireDate = date; localNotification.timeZone = [NSTimeZone defaultTimeZone]; localNotification.alertBody = @"I am a local notification!"; localNotification.soundName =
UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
return YES;
}
#pragma mark - didReceiveLocalNotification
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
NSLog(@"didReceiveLocalNotification %@", notification);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment