PHONEGAP implementation information push-based on Aurora push (Android version)

Source: Internet
Author: User

Aurora Push Plugin installation Address:

Https://github.com/jpush/jpush-phonegap-plugin

After installing the plugin, you need to configure the app Key for the Aurora platform application in Androidmanifest.xml:

<meta-data android:name= "Jpush_appkey" android:value= "aca4b37e5c00d477b*****"/>
there is an error in the 22 line of the Jpushplugin.java file, you need to change it to your own main package name.

The Settags method in Jpushplugin.js in the plugin has a bug and needs to be added in the data parameter [], as follows:

JPushPlugin.prototype.setTags = function (data) {        try{this.call_native ("Settags", [Data],null);} catch (Exception) {Console.log (exception);}}

Also, because the Aurora push plugin uses the PHONEGAP device plugin, it needs to be installed:

Cordova Plugin Add Org.apache.cordova.device

If you need to push information to all users, simply initialize the plugin when the app starts:

Document.addeventlistener ("Deviceready", function () {////plug-in initialization window.plugins.jPushPlugin.init ();}, False);

If you need to push a user, you need to get the user's device ID after the plug-in is initialized and store it on the server:

Document.addeventlistener ("Deviceready", function () {///plug-in initialization window.plugins.jPushPlugin.init ();
Window.plugins.jPushPlugin.getRegistrationID (function (ID) {//The acquired ID is credited to the service side}); }, False);

If you need to push information to a certain category of people, you can set the tag for the device, such as setting the same tag for the same professional user at the same level:

Login after setting Tag,tag format for ' tag_ ' + grade id+ ' _ ' + Professional ID, as shown below, multiple tags separated by commas var tag = ' tag_16_1 ';// Set Tagwindow.plugins.jPushPlugin.setTags (tag) for the current device;//When you exit the login, clear the tag, you will no longer receive the push message window.plugins.jPushPlugin.setTags (‘‘);
Click the callback method in the notification bar:
Click the callback in the notification bar, where you write the specific logic window.plugins.jpushplugin.opennotificationinandroidcallback= function (data) {Console.log ( data);}

The format of data is similar to the following example, in which the JSON data can be parsed to complete the custom logic:

{    "alert": "Hello, this is a piece of information of smart work big push",    "extras": {        "Cn.jpush.android.MSG_ID": "692692481",        "app": " Com.jiusem.jingle ",        " Cn.jpush.android.ALERT ":" Detailed content ",        " Cn.jpush.android.EXTRA ":" {"article_id": 1} ",// Article ID        "Cn.jpush.android.PUSH_ID": "692692481",        "Cn.jpush.android.NOTIFICATION_ID": 692692481,        " Cn.jpush.android.NOTIFICATION_TYPE ":" 0 "    }}

Well, after the above configuration is complete, you can push the notifications in the Aurora background.

Of course, the aurora pushes much more than is described above, but also supports custom messages and rich media messages push, here is just a simple introduction and get started, please visit official documents.

In addition, you can use the service-side SDK or API provided by Aurora to do this work, in addition to the Aurora background push operation, please refer to my other articles.

PhoneGap implementation information push-based on Aurora push (Android edition)

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.