This example for you to share the iOS local push the specific code, for your reference, the specific content as follows
Create a global local notification object and pop-up box first
Pop-up local message @property (Nonatomic,strong) uilocalnotification *localnotification;
@property (Nonatomic,strong) Uialertcontroller *alertcontrol;
Second, the code is implemented as follows:-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler {//Determine if the program is open, that is, whether the status is running in the foreground (Applica Tion.applicationstate = = uiapplicationstateactive) {//If the message was previously accepted and the user did not process the pop-up box, close the original pop-up if (Self.localnotificati
ON) {[Self.alertcontrol dismissviewcontrolleranimated:yes completion:nil];
[Self bulidlocationnotification:application userinfo:userinfo]; }else{//Judge whether the program is not open, that is, whether it is running or shutting down in the background, Aurora push set the corner sign if ([application applicationiconbadgenumber]>0) {[Jpushserv
Ice setbadge:[application Applicationiconbadgenumber]];
} [Jpushservice Handleremotenotification:userinfo];
NSLog (@ "received notice:%@", [self logdic:userinfo]); Completionhandler (uibackgroundfetchresultnewdATA);
}-(void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification *) Notification { Pop-up message if (self.localnotification) {Self.alertcontrol = [Uialertcontroller alertcontrollerwithtitle:@ "" Message:se
Lf.localNotification.alertBody Preferredstyle:uialertcontrollerstylealert]; Uialertaction *action = [uialertaction actionwithtitle:@ "OK" style:uialertactionstyledefault handler:^ (UIAlertAction
* _nonnull action) {self.localnotification = nil;
Self.alertcontrol = nil;
}];
[Self.alertcontrol addaction:action];
[Self.window.rootViewController PresentViewController:self.alertcontrol Animated:yes Completion:nil]; }//Create local push message-(void) Bulidlocationnotification: (uiapplication *) application userinfo: (nsdictionary *) userinfo{self.
Localnotification = [[Uilocalnotification alloc]init];
Self.localNotification.fireDate = [NSDate datewithtimeintervalsincenow:1]; Self.localNotification.alertBody = [[UserInfo objectforkey:@ "APS"] objectforkey:@ "alert"];
Self.localNotification.alertAction = @ "OK";
Self.localNotification.soundName = @ "SOUND.CAF";
Self.localNotification.userInfo = UserInfo;
[Application presentLocalNotificationNow:self.localNotification];
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.