Use of local push uilocalnotification for iOS

Source: Internet
Author: User

Uilocalnotification

1 First step: Receive local push2 3 Implementing proxy Methods Didreceivelocalnotification4 5- (void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification*) notification{6 7 //set resolution notification at this time and show the prompt view8 9 }Ten  One Step Two: Create a local push A- (void) createlocalnotification { -  - //Create a local push the  -  -Uilocalnotification *notification =[[[ Uilocalnotification alloc] init] autorelease]; -  +  -  + //set after 10 seconds A  at  -  -NSDate *pushdate = [NSDate datewithtimeintervalsincenow:Ten]; -  - if(Notification! =Nil) { -  in //Set push Time -  toNotification.firedate =pushdate; +  -   //Setting the time zone the  *Notification.timezone =[Nstimezone Defaulttimezone]; $ Panax Notoginseng //set the recurrence interval -  theNotification.repeatinterval =Kcfcalendarunitday; + //Push Sound ANotification.soundname =Uilocalnotificationdefaultsoundname; the //Push Content +Notification.alertbody =@"Push Content"; - //The number of the red circle displayed on the icon $Notification.applicationiconbadgenumber =1; $ //Setup UserInfo is convenient to use when you need to undo later -  -Nsdictionary *info = [Nsdictionary dictionarywithobject:@"name"Forkey:@"Key"]; the  -Notification.userinfo =info;Wuyi  the //add push to UIApplication -  WuUIApplication *app =[UIApplication sharedapplication]; -  About [app Schedulelocalnotification:notification]; $  - } -  - } A  + step three: unblock local push the  -- (void) removelocalnotication { $  the //Get UIApplication theUIApplication *app =[UIApplication sharedapplication]; the  the //get local push array -Nsarray *localarray =[app Scheduledlocalnotifications]; in  the  the  About //declaring a local notification object theUilocalnotification *localnotification; the  the if(LocalArray) { +  -  for(Uilocalnotification *notiinchLocalArray) { the BayiNsdictionary *dict =Noti.userinfo; the  the if(dict) { -  -NSString *inkey = [Dict objectforkey:@"Key"]; the  the if([Inkey isequaltostring:@"the corresponding key value"]) { the  the if(localnotification) { -  the [localnotification release]; the  theLocalnotification =Nil;94 } the  theLocalnotification =[Noti retain]; the 98  Break; About  - }101 102 }103 104 } the 106 107 //determine if a push is found for the same key that already exists108 if(!localnotification) {109  the //There is no initialization111Localnotification =[[Uilocalnotification alloc] init]; the 113 } the if(localnotification) { the //do not push cancel push the [app Cancellocalnotification:localnotification];117 [localnotification release];118 119 return; - }121 122 }123 124  the}

Use of local push uilocalnotification for iOS

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.