IOS 8 display App Corner label

Source: Internet
Author: User

1. The IOS 8 Corner display requires user authorization to request authorization when the app starts:

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {if([[Uidevice currentdevice].systemversion Doublevalue] >=8.0) {Uiusernotificationtype types= Uiusernotificationtypebadge | Uiusernotificationtypesound |Uiusernotificationtypealert; Uiusernotificationsettings*notificationsettings =[uiusernotificationsettings settingsfortypes:types Categories:nil];        [[UIApplication sharedapplication] registerusernotificationsettings:notificationsettings]; }        Else{uiremotenotificationtype Types= Uiusernotificationtypebadge | Uiusernotificationtypesound |Uiusernotificationtypealert;        [[UIApplication sharedapplication] registerforremotenotificationtypes:types]; }            returnYES; }

2. Display the angle label:

- (void) showbadgenumbers{
   Request Method (the server returns the specified data datas)

   // If no new data if([Datas isequaltostring:@"0"]) {[Self cleanbadgenumber]; } Else { //Tabbaritem The upper right corner shows no readingsSelf.tabBarItem.badgeValue =datas; //app not read in top right corner[UIApplication Sharedapplication].applicationiconbadgenumber =Datas.intvalue; }}

3. Clear the corner mark:

-(void) cleanbadgenumber{    //  Tabbaritem The top right corner shows the number of    unread tweets Self.tabBarItem.badgeValue = nil;     // app Unread Weibo is displayed in top right corner of application    0 ;}

4. Set Timer Automatic call

-(void
{ [Super Viewdidload];
// show no readings Nstimer *timer = [Nstimer scheduledtimerwithtimeinterval: target:self selector: @selector ( showbadgenumbers) Userinfo:nil Repeats:yes]; // Join Runloop [[Nsrunloop Mainrunloop] Addtimer:timer formode:nsrunloopcommonmodes]; }

5. The app goes into the background to continue calling

-(void) Applicationdidenterbackground: (UIApplication *
{ // apply for background run qualification to operating system, background run time is controlled by system __block uibackgroundtaskidentifier taskidentifier = [ Application beginbackgroundtaskwithexpirationhandler:^{ // Background run time has ended / / End Task [application endbackgroundtask:taskidentifier]; }];}

IOS 8 display App Corner label

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.