iOS Alarm Clock implementation

Source: Internet
Author: User

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[email protected] "time! ";

Notification.alertbody = [NSString stringwithformat:@ "@% time is up!", NAMESTR];

nsdictionary* info = [nsdictionary dictionarywithobject:uniquecodestr forkey:code];
Notification.userinfo = info;

[[UIApplication sharedapplication] schedulelocalnotification:notification];

}

When the time is up, a prompt will pop up on the desktop and the software can be started after the point is displayed. And then in
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (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];
}
}, the lanchoptions is processed, find the information inside it, you can get the settings need to deal with things, you can continue to operate.

If your client software is still open at this point, it will call the
-(void) Application: (UIApplication *) app Didreceivelocalnotification: (uilocalnotification *) Notif
{

}
The same treatment method.

iOS Alarm Clock implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.