Local Push Simple Code Demo

Source: Internet
Author: User

1 First step: Create a local push2 //Create a local push3Uilocalnotification *notification =[[[ Uilocalnotification alloc] init] autorelease];4 //set after 10 seconds5NSDate *pushdate = [NSDate datewithtimeintervalsincenow:Ten];6 if(Notification! =Nil) {7//Set push Time8Notification.firedate =pushdate;9//Setting the time zoneTenNotification.timezone =[Nstimezone Defaulttimezone]; One//set the recurrence interval ANotification.repeatinterval =Kcfcalendarunitday; -//Push Sound -Notification.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"]; +Notification.userinfo =info; A//add push to UIApplication atUIApplication *app =[UIApplication sharedapplication]; - [app Schedulelocalnotification:notification]; -     - } -  - Step two: Receive local push in- (void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification*) notification{ -Uialertview *alert = [[Uialertview alloc] Initwithtitle:@"IWeibo"Message:notification.alertBodyDelegate: Nil Cancelbuttontitle:@"Determine"Otherbuttontitles:nil]; to [alert show]; +//the number on the icon minus 1 -     1. Application.applicationiconbadgenumber-=1; the } *  $ step three: unblock local pushPanax Notoginseng //Get UIApplication -UIApplication *app =[UIApplication sharedapplication]; the //get local push array +Nsarray *localarray =[app Scheduledlocalnotifications]; A //declaring a local notification object theUilocalnotification *localnotification; + if(LocalArray) { - for(Uilocalnotification *notiinchLocalArray) { $Nsdictionary *dict =Noti.userinfo; $if(dict) { -NSString *inkey = [Dict objectforkey:@"Key"]; -if([Inkey isequaltostring:@"the corresponding key value"]) { theif(localnotification) { - [localnotification release];WuyiLocalnotification =Nil; the                 } -Localnotification =[Noti retain]; Wu Break; -             } About         } $     } -     -//determine if a push is found for the same key that already exists -if(!localnotification) { A//There is no initialization +Localnotification =[[Uilocalnotification alloc] init]; the     } -     $if(localnotification) { the//do not push cancel push the [app Cancellocalnotification:localnotification]; the [localnotification release]; thereturn; -     } in } the  the The process is probably like this. About 1. Build certificatesigningrequest.certsigningrequest file the 2. Upload certificatesigningrequest.certsigningrequest into developer, export the. cer file the 3. Export P12 files with CSR the 4the device token value needs to be prepared (no spaces) + 5. Use the push certificate used by the OpenSSL compositing server

Local Push Simple Code Demo

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.