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