First step: Create a local push
Create a local push
Uilocalnotification *notification = [[[[Uilocalnotification alloc] init] autorelease];
Set after 10 seconds
NSDate *pushdate = [NSDate datewithtimeintervalsincenow:10];
if (notification! = nil) {
Set push time
Notification.firedate = pushdate;
Setting the time zone
Notification.timezone = [Nstimezone defaulttimezone];
Set the recurrence interval
Notification.repeatinterval = Kcfcalendarunitday;
Push Sound
Notification.soundname = Uilocalnotificationdefaultsoundname;
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;
Add push to UIApplication
UIApplication *app = [UIApplication sharedapplication];
[App Schedulelocalnotification:notification];
}
Step two: Receive local push
-(void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification*) notification{
Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "IWeibo" Message:notification.alertBody Delegate:nil cancelbuttontitle:@ "determine" otherbuttontitles:nil];
[Alert show];
The number on the icon minus 1
Application.applicationiconbadgenumber-= 1;
}
Step three: Unblock local push
Get UIApplication
UIApplication *app = [UIApplication sharedapplication];
Get local push array
Nsarray *localarray = [app scheduledlocalnotifications];
Declaring a local notification object
Uilocalnotification *localnotification;
if (LocalArray) {
For (Uilocalnotification *noti in LocalArray) {
Nsdictionary *dict = Noti.userinfo;
if (dict) {
NSString *inkey = [dict objectforkey:@ "key"];
if ([Inkey isequaltostring:@ "corresponding key value"]) {
if (localnotification) {
[Localnotification release];
Localnotification = nil;
}
Localnotification = [Noti retain];
Break
}
}
}
Determine if a push is found for the same key that already exists
if (!localnotification) {
Initialization not present
Localnotification = [[Uilocalnotification alloc] init];
}
if (localnotification) {
Do not push cancel push
[App Cancellocalnotification:localnotification];
[Localnotification release];
Return
}
}
[Reprint]ios local Push-spare