Turn push on or off
-(void) Pushswitch: (Uiswitch *) Sender { if (sender.on) { [[nsuserdefaults standarduserdefaults] setobject:@ "1 "forkey:@" Jpushstate "]; [Apservice registerforremotenotificationtypes: (Uiremotenotificationtypebadge | Uiremotenotificationtypesound | Uiremotenotificationtypealert) Categories:nil]; } else {[ [nsuserdefaults standarduserdefaults] setobject:@ "0" forkey:@ "jpushstate"]; [[UIApplication sharedapplication] unregisterforremotenotifications]; }}
In the Appdelegate file
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {if ([[ [Nsuserdefaults Standarduserdefaults] objectforkey:@ "jpushstate"] isequaltostring:@ "1"]) { [APService Registerforremotenotificationtypes: (Uiremotenotificationtypebadge | Uiremotenotificationtypesound | Uiremotenotificationtypealert) Categories:nil]; [Apservice setupwithoption:launchoptions];} }
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken { [Apservice registerdevicetoken:devicetoken];} -(void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) userInfo { [ Apservice Handleremotenotification:userinfo];} -(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler { [apservice Handleremotenotification:userinfo]; Completionhandler (uibackgroundfetchresultnewdata);}
Aurora Push Jpush Project Simple to use