Now some of the third-party push platform is very useful, mainly because they have a similar public platform, the same management background, easy to use, packaging a lot of developers need to push the function.
This three-party framework integration is relatively simple, can refer to a push appdemo for integration, mainly import library, and then in the Appdelegate configuration is good.
Demo and document address: http://docs.igetui.com/pages/viewpage.action?pageId=1934080
The place to note in the code is:
Online push and offline push portals are not the same
Offline, the delegate portal is pushed through the Apple server turnover:
- (void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo {//[4-ext]: Handling APNNSString *payloadmsg = [UserInfo objectforkey:@"Payload"]; if(payloadmsg) {NSString*record = [NSString stringWithFormat:@"[apn]%@,%@", [NSDate Date], payloadmsg]; NSLog (@"get push message 1:%@", record); }}
Online from a push server direct message sent, a push of the delegate, and then you can use the following function to do a local notification:
- (void) Getuisdkdidreceivepayload: (NSString *) Payloadid andtaskid: (NSString *) taskId Andmessageid: (NSString *) aMsgId Fromapplication: (NSString *) appid{//[4]: Received a push message_payloadid =[payloadid copy]; NSData* Payload =[Getuisdk Retrivepayloadbyid:payloadid]; NSString*payloadmsg =Nil; if(payload) {payloadmsg=[[NSString alloc] InitWithBytes:payload.bytes length:payload.length Encoding:nsutf8stringencoding]; } nsstring*record = [NSString stringWithFormat:@"%d,%@,%@", ++_lastpayloadindex, [self formatetime:[nsdate Date]], payloadmsg]; NSLog (@"task ID:%@, messageid:%@, content:%@", TaskId, Amsgid,record); [Self createnotifiction:payloadmsg];}
Local notifications:
-(void) Createnotifiction: (NSString *) content{//defining local Notification ObjectsUilocalnotification *notification=[[Uilocalnotification alloc]init]; //Set call timeNotification.firedate=[nsdate Datewithtimeintervalsincenow:0];//notification trigger time, after 10sNotification.repeatinterval=2;//Notification Repeat Count//Notification.repeatcalendar=[nscalendar Currentcalendar];//current calendar, it is best to set the time zone and other information to enable automatic synchronization//Set notification PropertiesNotification.alertbody=content;//Notification BodyNotification.applicationiconbadgenumber=1;//the number of messages displayed in the upper-right corner of the application iconnotification.alertaction=@"swipe to view";//Sliding action Tips for the standby interface//[email protected] "Default";//Click the notification to open the app when the start picture, here to use the program to start the pictureNotification.soundname=Uilocalnotificationdefaultsoundname; //set up user information[Email protected] {@"type":@"localnotification"};//binding to other additional information on the notification//Invoke Notification[[UIApplication sharedapplication] schedulelocalnotification:notification];}
Latest iOS Developer account Related: Second, third-party push Add (2015.10.9)