Jpush Aurora push (integration process)

Source: Internet
Author: User

Jpush instructions

Jpush IOS push principles and Problems

(Reference: http://blog.jpush.cn/apns)

 

Jpush IOs: get started with push Methods

(Details: http://docs.jpush.io/client/ios_sdk)

 

As you can see, jpush IOS push consists of two parts: apns push (proxy) and jpush in-app messages.

The red part is apns push, and the jpush proxy developer's application (based on the application certificate provided by the developer) is pushed to the Apple apns server. It is pushed by apns server to iOS devices.

The blue part is the push part in the jpush application. When the app is started, the embedded jpush SDK will enable persistent connection to the jpush server, so that the jpush server can push messages to the app.

 

 

Apns notification

Apns notifications: notifications sent to the Apple apns server, which are pushed to the iOS device and presented by the IOS system. In iOS, you can choose "Settings"> "notifications" to enable or disable the push capability of an app.

The jpush ios sdk does not display apns notifications. It only uploads device tokens to the jpush server. The jpush server proxy developer pushes notifications to Apple apns.

 

 

Get apns message content through Function

 

• If the app is in the foreground or background running status, this function will be called and you can determine whether the app is running in the foreground by checking whether the applicationstate of appdelegate is uiapplicationstateactive. This situation is handled in this function:

? (Void) Application :( uiapplication *) Application didreceiveremotenotification :( nsdictionary *) userinfo; // The content of APN is userinfo

• If the remote notification feature of iOS 7 is used, the processing function must use

? (Void) Application :( uiapplication *) Application didreceiveremotenotification :( nsdictionary *) userinfo fetchcompletionhandler :( void (^) (uibackgroundfetchresult) completionhandler; // The content of APN is userinfo

 

In-app message

In-app message: the in-app message function provided by the jpush ios sdk allows the app to receive pushed messages at the front-end. The app can use this function to send messages.

This message does not pass through the apns server and is fully supported by jpush.

 

Get application message content

 

Add the following code to method-(bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary *) launchoptions:

Nsicationicationcenter * defaultcenter = [nsnotificationcenter defacenter center];

[Defaultcenter addobserver: Self selector: @ selector (networkdidreceivemessage :) name: kjpfnetworkdidreceivemessagenotification object: Nil];

Implementation callback method networkdidreceivemessage

-(Void) networkdidreceivemessage :( nsnotification *) Notification {

Nsdictionary * userinfo = [Notification userinfo];

Nsstring * content = [userinfo valueforkey: @ "content"];

Nsdictionary * extras = [userinfo valueforkey: @ "EXTRAS"];

Nsstring * customizefield1 = [extras valueforkey: @ "customizefield1"]; // custom parameter. The key is defined by yourself}

 

 

 

Jpush-Ios certificate setting Guide

(See the document: http://docs.jpush.cn/pages/viewpage.action? Pageid = 1343727 and http://docs.jpush.cn/pages/viewpage.action? Pageid = 8820084)

 

1. Create an Application ID

2. Configure and download the certificate

3. Export the. p12 Certificate file

4. Upload a certificate

 

 

Jpush-SDK integration steps

(See the document: http://docs.jpush.cn/pages/viewpage.action? Pageid = 2621727)

 

1. Upload certificates and create applications on the jpush Management Portal. If you are not familiar with apns certificates, refer to the IOS certificate setting guide.

1.1 after the application is created successfully, an appkey is automatically generated to identify the application.

 

2. Import the API Development Kit to the Application Project

2.1 decompress the SDK package and add the decompressed lib subfolders (including apservice. h and libpushsdk. A) to your project directory.

 

3. necessary frameworks

• Cfnetwork. Framework

• Corefoundation. Framework

• Coretelephony. Framework

• Systemconfiguration. Framework

• CoreGraphics. Framework

• Foundation. Framework

• Uikit. Framework

• Security. Framework

• Libz. dylib

 

4. Build settings

4.1 set the user header search paths and library search paths under search paths. For example, if both the SDK folder (LIB by default) and the project file are in the same level directory, they are set to "$ (srcroot) /[Folder name.

 

5. Create and configure the pushconfig. plist File

5.1 create a new property list file in your project, name it pushconfig. plist, and fill in parameters such as app_key provided by the portal for your application.

{

"Aps_for_production" = "0"; // if the development is 0, the production value is 1.

"Channel" = "Publish channel ";

"App_key" = "appkey copied from jpush portal application ";

}

 

 

 

5.2-Channel

Specifies the download channel for the application package, to facilitate statistics by channel. You can define it as needed.

5.3 app_key

• The automatically generated (appkey) when creating an application on the Management Portal is used to identify the application. Make sure that the appkey configured in the application is the same as the appkey generated when you create an application on the portal in step 2. The appkey can be queried in application details.

5.4 aps_for_production

• Version 1.3.1 is added, indicating whether the application is published using the production certificate (ad_hoc or App Store). 0 (default) indicates that the developer certificate is used, and 1 indicates that the application is published using the production certificate. Note that the configuration here matches the web portal application environment settings.

• In the configuration file of 1.2.2 or earlier versions, there is the test_mode key. The new version of the SDK is no longer used and can be deleted.

 

 

 

 

 

6. Add code

 

API

 

APIS is mainly concentrated in the apservice interface class.

// The following four interfaces must be called:

+ (Void) setupwithoption :( nsdictionary *) launchingoption; // Initialization

+ (Void) registerforremotenotificationtypes :( nsuinteger) Types

Categories :( nsset *) categories; // register the apns type

+ (Void) registerdevicetoken :( nsdata *) devicetoken; // report the device token to the server.

+ (Void) handleremotenotification :( nsdictionary *)

Remoteinfo; // process the received apns message and report it to the server.

 

 

 

 

 

 

Call Code

-(Bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary *) launchoptions

{

Self. Window = [[[uiwindow alloc] initwithframe: [[uiscreen mainscreen] bounds] autorelease];

Self. Window. backgroundcolor = [uicolor whitecolor];

[Self. Windows makekeyandvisible];

 

// Required

If([[Uidevice currentdevice]. systemversion floatvalue]> = 8.0 ){

// You can add custom categories

[Apservice registerforremotenotificationtypes: (uiusernotificationtypebadge |

Uiusernotificationtypesound |

Uiusernotificationtypealert)

Categories: Nil];

}

Else 

{

// Categories must be nil

[Apservice registerforremotenotificationtypes :( uiremotenotificationtypebadge |

Uiremotenotificationtypesound |

Uiremotenotificationtypealert)

Categories: Nil];

}

# Else

// Categories must be nil

[Apservice registerforremotenotificationtypes :( uiremotenotificationtypebadge |

Uiremotenotificationtypesound |

Uiremotenotificationtypealert)

Categories: Nil];

# Endif

// Required

[Apservice setupwithoption: launchoptions];

ReturnYes;

}

 

 

 

 

 

 

-(Void) Application :( uiapplication *) Application didregisterforremotenotificationswithdevicetoken :( nsdata *) devicetoken {

// Required

[Apservice registerdevicetoken: devicetoken];

}

 

-(Void) Application :( uiapplication *) Application didreceiveremotenotification :( nsdictionary *) userinfo {

// Required

[Apservice handleremotenotification: userinfo];

}

 

-(Void) Application :( uiapplication *) Application didreceiveremotenotification :( nsdictionary *) userinfo fetchcompletionhandler :(Void(^) (Uibackgroundfetchresult) completionhandler {

 

 

// IOS 7 support required

[Apservice handleremotenotification: userinfo];

Completionhandler (uibackgroundfetchresultnewdata );

}

 

 

7. Listener notifications

The API provides the following five types of notifications:

Extern nsstring * const kjpfnetworkdidsetupnotification; // establish a connection

Extern nsstring * const kjpfnetworkdidclosenotification; // close the connection

Extern nsstring * const kjpfnetworkdidregisternotification; // registration successful

Extern nsstring * const kjpfnetworkdidloginnotification; // logon successful

Extern nsstring * const kjpfnetworkdidreceivemessagenotification; // receives a message (not apns)

 

 

8. Continue.

(FAQ reference: http://docs.jpush.cn/pages/viewpage.action? Pageid = 7864782)

8.1 how to obtain the appkey?

Obtained from the pushconfig. plist file we created.

-(Nsstring *) getappkey

{

Nsurl * urlpushconfig = [[[nsbundle mainbundle] urlforresource: @ "pushconfig" withextension: @ "plist"] Copy];

Nsdictionary * dictionary = [nsdictionary dictionarywithcontentsofurl: urlpushconfig];

If (! Dictionary)

{

Return nil;

}

// Appkey

Nsstring * strappkey = [dictionary valueforkey: @ "app_key"];

If (! Strappkey)

{

Return nil;

}

Return [strappkey lowercasestring]; // convert uppercase letters to lowercase letters.

}

 

8.2 call/** when registration is successful to obtain the registration ID

* Get registrationid

*/

+ (Nsstring *) registrationid;

Jpush Aurora push (integration process)

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.