UPDATED VERSION: Appcelerator Titanium Alloy JPUSH Push Notification Module – iOS and Android, China Push Notification- NON GCM
Hi,
As you may know Chinese Android phones do not ship with the Google Play store – thus Google Cloud Messaging does not work.
If you are creating a Android Application or a version of your APP for the Chinese market it would be best if you use a Chinese Push Service like JPUSH.
The backend is in Chinese – You can sign up at https://www.jpush.cn/ – Its very very simple – you should just be able to use Google Translate to help you figure out how to use it – Its totally free.
After alot of research and searching I found that there was not a module that would work – I did find a half written module on a Chinese Blog but it was not exactly what I needed.
So I wrote a JPUSH Module for Titanium Alloy to be able to use the Chinese JPUSH Service. As this was alot of work I am asking for a small donation to be able to download the compiled and ready to use version of my JPUSH Titanium Alloy Android Module.
**** THIS MODULE IS PROVIDED WITHOUT ANY FORM OF SUPPORT ****
CLICK HERE TO DONATE AND DOWNLOAD THE JPUSH TITANIUM ALLOY ANDROID MODULE
Once you donate you will receive an email with instructions on how to download the module – if you do not please let me know!
## INSTALLATION
1. Place zip in your app root and build app – titanium will automatically extract and install the app.
2. Add Module into your tiapp.xml via Studion GUI or via adding
<module platform="android">com.yeshcp.jpush</module>
3. Add the Following Like to you tiapp.xml file to prevent Android Crashing
<property name="ti.android.bug2373.finishfalseroot" type="bool">true</property>
## SETTING YOUR APP ID
4. You Will also need to change the the YOURAPPID below to your app ID found on JPUSH
Location: modules/android/com.yeshcp.jpush/VERSION/timodule.xml
<meta-data android:name="JPUSH_APPKEY" android:value="YOUR-JPUSH-APPID-GOES-HERE"/>
## USAGE
5. Place the following code if you app.js file to catch the Push Notification and display it via a POPUP in your app
// REQUIRE JPUSH MOFULE var JPush = require('com.yeshcp.jpush'); // ADD EVENTLISTENTER AND FUNCTION TO MODULE JPush.addEventListener('pushCallBack',function(evt){ // Set pushNotification as evt var pushNotification = evt; // Set pushExtras and JSON.parse into Object var pushNotificationExtra = JSON.parse(evt.extras); // set pushType as alertType var pushType = pushNotificationExtra.alertType || 'push type'; // Set Values var pushTitle = pushNotification.title || 'Push Title'; var pushMessage = pushNotification.alert || 'Push Alert'; var pushConfirm = pushNotificationExtra.alertConfirm || 'Push Confirm'; var pushCancel = pushNotificationExtra.alertCancel || 'Push Cancel'; var pushURL = pushNotificationExtra.alertURL || 'Push URL'; // Ti.API.info all Values Ti.API.info("Type:" + pushType + "Title:" + pushTitle + "Message:" + pushMessage + "pushConfirm:" + pushConfirm + "pushCancel:" + pushCancel + "pushURL:" + pushURL); // setTimeout of 500miliseconds and then run pushPopUp function with params setTimeout(function(){ pushPopUp(pushType,pushTitle,pushMessage,pushConfirm,pushCancel,pushURL); },500); });
// OTHER POSSIBLE FUNCTIONS // Set Alias and Tags push.setAliasAndTags('chelsea',['grade1','grade2'],function(e){ alert('setAliasAndTags' + JSON.stringify(e)); }); setTimeout(function(){ push.setAlias('',function(e){ alert('setAlias' + JSON.stringify(e)); }); },5000); setTimeout(function(){ push.setTags([],function(e){ alert('setTags' + JSON.stringify(e)); }); },10000);
If you would like the Source of the Module to add features and compile on your own let me know and I can provide it to you as well.
If you would not like to pay for the module and have a good reason like being a non-profit let me know in the comments and I can provide you with a copy for free.
Let me know if you need any help.
Its not working when application is not running
Hi,
first of all, thanks for a wonderful solution. There is no a lot of information about this issue. Just one thing I didn’t understand do I need some application installed on the cellular (in China) in order to use this solution. How the mobile phone know to receive notification from service?
Thank you in advance,
Julia.
Hi, You do not need to install anything on the phone – when you add and configure this module in your app it will automatically start a service that will listen for the push notifications. Let me know if you need any help…
Thank you for your answer 🙂 I have a server that sends notifications and the application, which runs on the mobile phone in China. When I will add your module to the mobile application how you code will recognize my messages? Does the server need some key for this?
Thanks,
Julia
So does this push service work as google cloud? I mean is the device able to get notifications when the application are not running or in background?
Yes it works really well – the phone still receives push notification even when the app is closed or in the background – I have even done testing when the wifi/data is turned off – once it comes back on the phone receives the push notifications – let me know if there is anything else
Hi I would like to use your module but what about the backend what is the method to send the push notification
Hi Jose,
The backend is in Chinese – You can sign up at https://www.jpush.cn/ – Its very very simple – you should just be able to use Google Translate to help you figure out how to use it – Its totally free. Go try to sign up and figure it out – if you have any questions let me know and I can help you. I could maybe even post a how to guide to explain everything.
Let me know,
Peace