Adding a remote push code

Source: Internet
Author: User

Project one add way;

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

method to add a push to invoke

Push sub-iOS8 to handle

Item two how to add;

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

method to add a push to invoke

Item three how to add;

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

method to add a push to invoke

Code comparison

Push code in Project one

#pragmaMark Xgpush-(void) registerpush{floatSysver =[[[ Uidevice Currentdevice] systemversion] floatvalue]; if(Sysver <8{[[UIApplication sharedapplication] registerforremotenotificationtypes: (Uiremotenotificationtypealert| Uiremotenotificationtypebadge |Uiremotenotificationtypesound)]; }Else{#if__iphone_os_version_max_allowed >= _iphone80_uimutableusernotificationcategory*categorys =[[Uimutableusernotificationcategory alloc] init]; Uiusernotificationsettings*usersettings = [Uiusernotificationsettings settingsfortypes:uiusernotificationtypebadge| uiusernotificationtypesound|Uiusernotificationtypealert Catego        Ries:[nsset Setwithobject:categorys]];        [[UIApplication sharedapplication] registerusernotificationsettings:usersettings]; [[UIApplication sharedapplication] registerforremotenotifications];#endif    }}

Push code in Project two

#pragmaMark-Push the registration function (and select the type of push message registered)-(void) registernotificationtype{#ifdef__iphone_8_0if(Systemversion >=8.0) {[[UIApplication sharedapplication] registerforremotenotifications]; /** * @author zyz * * After 8 system, System push service*/        //Uiusernotificationtypebadge//Uiusernotificationtypesound//UiusernotificationtypealertUiusernotificationtype mytypes = Uiusernotificationtypebadge | Uiusernotificationtypesound |Uiusernotificationtypealert; Uiusernotificationsettings*settings =[uiusernotificationsettings settingsfortypes:mytypes Categories:nil];    [[UIApplication sharedapplication] registerusernotificationsettings:settings]; }    Else#endif{[[UIApplication sharedapplication] registerforremotenotificationtypes: (Uiremotenotificationtypebadge | Uiremotenotificationtypesound |Uiremotenotificationtypealert)]; }}

Push code in Project three

- (void) registerforremotenotifications{#ifSupport_ios8if([[[[Uidevice Currentdevice] systemversion] Floatvalue] >=8.0) {Uiusernotificationtype mytypes= Uiusernotificationtypebadge | Uiusernotificationtypealert |Uiusernotificationtypesound; Uiusernotificationsettings*settings =[uiusernotificationsettings settingsfortypes:mytypes Categories:nil];    [[UIApplication sharedapplication] registerusernotificationsettings:settings]; }Else#endif{uiremotenotificationtype mytypes= uiremotenotificationtypebadge| Uiremotenotificationtypealert|Uiremotenotificationtypesound;    [[UIApplication sharedapplication] registerforremotenotificationtypes:mytypes]; }    /*#if target_os_iphone#if Support_ios8 if ([[[[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0) { Uiremotenotificationtype mytypes = Uiremotenotificationtypebadge | Uiremotenotificationtypealert |        Uiremotenotificationtypesound;        Uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:mytypes categories:nil];    [[UIApplication sharedapplication] registerusernotificationsettings:settings]; }else#endif {[[UIApplication sharedapplication] Registerforremotenotificationtypes: (UIRemoteNotificati Ontypebadge | Uiremotenotificationtypesound |    Uiremotenotificationtypealert)]; } #endif*/}
#if support_ios8-(void) Application: (UIApplication *) application didregisterusernotificationsettings: ( Uiusernotificationsettings *) notificationsettings{    //Register to receive notifications      [application registerforremotenotifications];} #endif

Adding a remote push code

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.