IOS alert clock implementation, ios alert clock implementation
UILocalNotification * notification = [[UILocalNotification alloc] init];
If (notification! = Nil)
{
NSDate * now = [NSDate new];
// Notification. fireDate = [now addTimeInterval: period];
Notification. fireDate = [now dateByAddingTimeInterval: period];
NSLog (@ "% d", period );
Notification. timeZone = [NSTimeZone defaultTimeZone];
Notification. soundName = @ "ping. caf ";
// Notification. alertBody = @ "TIME! ";
Notification. alertBody = [NSString stringWithFormat: @ "@ % The time is up! ", NameStr];
NSDictionary * info = [NSDictionary dictionaryWithObject: uniqueCodeStr forKey: CODE];
Notification. userInfo = info;
[[UIApplication sharedApplication] scheduleLocalNotification: notification];
}
After the set time is reached, a prompt box will pop up automatically on the desktop. After clicking it, you can start the software. Then
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions
{
UILocalNotification * localNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsLocalNotificationKey];
If (localNotif)
{
NSLog (@ "Recieved Notification % @", localNotif );
NSDictionary * infoDic = localNotif. userInfo;
NSLog (@ "userInfo description = % @", [infoDic description]);
NSString * codeStr = [infoDic objectForKey: CODE];
}
}, Process lanchOptions, find the information in it, you can get what needs to be processed during the settings, you can continue the operation.
If your client software is still open
-(Void) application :( UIApplication *) app didReceiveLocalNotification :( UILocalNotification *) notif
{
}
The same processing method.