Recently in the study of Apple push, when testing the local push, the problem is that once you add a local push notification, when you modify the code, delete the app, when you run the app again, it will pop up on the banner push, and how can not be deleted, almost collapsed, Began to think is iOS7 bug, Apple father since iOS7 after various bugs have not poor, but finally calmly think about, there is the possibility of the app local push is set up the system inside, so you in the app delete local push code no way to cancel push, so finally to I found a Cancelalllocalnotifications method, and the local push of the egg ache finally disappeared ... The Dogskin plaster demon was finally gone.
This is a local notification to generate local push, once you run it, then congratulations, you delete the app, modify the code, then install, the banner has been the bomb ah ...
Uilocalnotification *notification =[[Uilocalnotification alloc] init]; //set after 10 secondsNSDate*pushdate = [NSDate datewithtimeintervalsincenow:Ten]; if(Notification! =Nil) { //Set push Timenotification.firedate=pushdate; //Setting the time zoneNotification.timezone=[Nstimezone Defaulttimezone]; //set the recurrence intervalNotification.repeatinterval=Kcfcalendarunitday; //Push SoundNotification.soundname=Uilocalnotificationdefaultsoundname; //Push ContentNotification.alertbody=@"Push Content"; //The number of the red circle displayed on the iconNotification.applicationiconbadgenumber=1; //Setup UserInfo is convenient to use when you need to undo laternsdictionary*info = [Nsdictionary dictionarywithobject:@"name"Forkey:@"Key"]; Notification.userinfo=info; //add push to UIApplicationuiapplication*app =[UIApplication sharedapplication]; [App Schedulelocalnotification:notification];
How can we cancel this rogue behavior? Only need 3 lines of code, the world is instantly pure ... and remove that little red dot of 1.
UIApplication *app = [uiapplication sharedapplication];
App.applicationiconbadgenumber = 0;
[App Cancelalllocalnotifications];
iOS local push removal is not a workaround