Created
February 24, 2014 03:35
-
-
Save keicoder/9181549 to your computer and use it in GitHub Desktop.
objective-c : basic local notifications
This file contains hidden or 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
| //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