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