iOS local push removal is not a workaround

Source: Internet
Author: User

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

Related Article

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.