I've written about using Python to write a push server, and today, if you integrate the push service of the alliance
Before we do, we need to do some preparatory action.
#1. Register an app ID
#2. Enable push Notificationserivice, and create and download development/release Push certificates
#3. Install the push certificate and then push the certificate everywhere for the P12 file
#4. Pay attention to the Friend League account
#5. Create a push app and upload the P12 file for the push certificate and fill in the password
#6. Download the SDK to add to the project
In Appdelegatez
#import " UMessage.h "
Add a property
@property (nonatomic, strong) Nsdictionary *userinfo;
To add an agreement:
@interface Appdelegate () <UNUserNotificationCenterDelegate>
Set up Friends League Appkey
Static NSString *umessageappkey @ "112345678901234523";
Create a method to configure the Allies push
- (void) Configureumessagewithlaunchoptions: (Nsdictionary *) launchoptions {//set Appkey & Launchoptions[Umessage Startwithappkey:umessageappkey launchoptions:launchoptions]; //Initialize[Umessage registerforremotenotifications]; //Turn on log[Umessage Setlogenabled:yes]; //Check for iOS 10 or later if([[[[Uidevice Currentdevice] systemversion] Floatvalue] <10.0) { } Else { //If you have iOS 10 or later, you must do the following:Unusernotificationcenter *center =[Unusernotificationcenter Currentnotificationcenter]; Center.Delegate=Self ; Unauthorizationoptions Types10=Unauthorizationoptionbadge| Unauthorizationoptionalert |Unauthorizationoptionsound; [Center Requestauthorizationwithoptions:types10 Completionhandler:^ (BOOL Granted, Nserror *_nullable Error) { if(granted) {//Click Allow//Here you can add some of your own logic } Else { //Click Not allowed//Here you can add some of your own logic } }]; }}
Protocol method:
- (void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo {//turn off the pop-up box from the Friends League[Umessage Setautoalert:no]; [Umessage Didreceiveremotenotification:userinfo]; Self.userinfo=UserInfo; //Customizing the popup box if([uiapplication Sharedapplication].applicationstate = =uiapplicationstateactive) {Uialertview*alertview = [[Uialertview alloc] Initwithtitle:@"Warm Tips"message:self.userinfo[@"APS"][@"Alert"] Delegate: Self cancelbuttontitle:@"Determine"Otherbuttontitles:nil]; [Alertview show]; }}//iOS10 NEW: Handling agent methods for receiving notifications from the foreground- (void) Usernotificationcenter: (Unusernotificationcenter *) Center willpresentnotification: (unnotification*) Notification Withcompletionhandler: (void(^) (unnotificationpresentationoptions)) completionhandler{nsdictionary* UserInfo =Notification.request.content.userInfo; if([Notification.request.trigger Iskindofclass:[unpushnotificationtriggerclass]]) { //Remote push acceptance when the app is in the foreground//turn off the pop-up box from the Friends League[Umessage Setautoalert:no]; //This code must be added .[Umessage Didreceiveremotenotification:userinfo]; }Else{ //local push acceptance when the app is in the foreground } //when the app is in the foreground and prompts for settings, which one can be set whichCompletionhandler (Unnotificationpresentationoptionsound |Unnotificationpresentationoptionbadge|unnotificationpresentationoptionalert);}//iOS10 NEW: Proxy method for background click Notification-(void) Usernotificationcenter: (Unusernotificationcenter *) Centerdidreceivenotificationresponse: (Unnotificationresponse*) Response Withcompletionhandler: (void(^) ()) completionhandler{nsdictionary* UserInfo =Response.notification.request.content.userInfo; if([Response.notification.request.trigger Iskindofclass:[unpushnotificationtriggerclass]]) { //Remote push acceptance when the app is in the background//This code must be added .[Umessage Didreceiveremotenotification:userinfo]; }Else{ //local push acceptance when the app is in the background }}- (void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) Buttonindex {[Umessage sendclickreportforremotenotification:self. UserInfo];}
Finally, the method of configuring the AU push is called in Applicationdidfinishlaunch.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions { // Configure the friend Alliance push [self configureumessagewithlaunchoptions:launchoptions]; return YES;}
iOS integrated friend League push