Latest iOS Developer account Related: Second, third-party push Add (2015.10.9)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.