Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement