Android solutions can be found here: Android Solutions
iOS if there is no page to jump the need to use the Aurora push, if there is a page jump if you use the Aurora push to write only with OC, but I do not OC, so smart abandon the Aurora choose iOS own APNs to achieve
The new project is almost the same as the Android-created project, which is the initial session phonegap when the new is completed, and note that the Phonegap.platform is set to iOS in the Phonegap.local.properties file
CMD move to the PhoneGap folder under the new project to install the plugin:
PhoneGap Local plugin Add https://github.com/phonegap-build/PushPlugin.git
After installing the plugin, we can write the logic code in the App.js folder. The main logic code is written in the lunch method in App.js, and the object cannot be found outside.
Plugins.pushNotification.register ( Tokenhandler, ErrorHandler, { "badge": "True", "sound": " True ", " alert ":" True ", " ECB ":" ONNOTIFICATIONAPN " });
Tokenhandler is the way to get tokens:
function Tokenhandler (Result) { alert (' token = ' + result);}
This token is very important to get, and the APNs push that you implement later needs this token to indicate which device to push to
ErrorHandler is the wrong callback and can be used to alert users to push failures.
function ErrorHandler (Result) { //Your IOS push server needs to know the token before it can push to this device
//Here's where you might want to send it the token for later use.}
I'm not writing logic here.
ONNOTIFICATIONAPN: This thing is very important, this is to click on the post-push callback function
function Onnotificationapn (event) { if (Event.alert) { ext.getcmp (' tab '). Setactiveitem (1); } }
This method inside can write the jump page logic code, my logic here is if the push content is not empty to jump to the second page
The app's code is done, and now it's time to write your own way of implementing APNs. Java Implementation Code
After unpacking the package there is a COM folder and a text file, put the COM folder into the Java project, and then write a controller to call the text file inside the method;
Text inside loaded a p12 file, this file is the push license we requested, generate method
Token: It is the token that is acquired in our app and is pushed to the device based on this.
If you imagine an aurora push, sending additional fields can be
String payload = Apns.newpayload (). CustomField ("type", 4). Alertbody (content). Badge (Badge). build ();
In this code, Add. CustomField (), parameter is the key value pair of Key-value, after success in the foregroundthe value of the corresponding value can be obtained by result.key the Tokenhandler directly.