Latest Appcelerator Titanium Alloy JPUSH Push Notification Module – iOS and Android, China Push Notification- NON GCM
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.
You can sign up at https://www.jpush.cn/
I wrote a JPUSH Module for Titanium Alloy iOS and ANDROID 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 iOS and Android Modules.
**** 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. Installation
- Extract the JPUSH_MODULES.zip you received after your donation.
- Move Zips to root of your Application
2. Register your module with your application by editingtiapp.xml
and adding your module.
<modules> <module platform="iphone">cn.jpush.ti</module> <module platform="android">cn.jpush.ti</module> </modules>
3. Add the Following Like to you tiapp.xml file to prevent Android Crashing
<property name="ti.android.bug2373.finishfalseroot" type="bool">true</property>
4. You Will also need to change the the YOURAPPID below to your app ID found on JPUSH
Android Location: modules/android/cn.jpush.to/VERSION/timodule.xml
<meta-data android:name="JPUSH_APPKEY" android:value="YOUR-JPUSH-APPID-GOES-HERE"/>
iOS Location: modules/iphone/cn.jpush.to/VERSION/platform/iphone/PushConfig.plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>APP_KEY</key> <string>YOUR_APP_KEY_STRING</string> <key>APS_FOR_PRODUCTION</key> <string>0</string> <key>CHANNEL</key> <string>Push channel</string> </dict> </plist>
5. Place the following code if you app.js file to catch the Push Notification and display it via a POPUP in your app
////////////////////////////////////////////////////////////////////////////// // Start Push Section // // START IF - iOS ELSE Android if (Ti.Platform.name == 'iPhone OS'){ // REQUIRE JPUSH MODULE var JPush = require('cn.jpush.ti'); // START FUNCTION - registerForPush function registerForPush() { Ti.Network.registerForPushNotifications({ success: deviceTokenSuccess, error: deviceTokenError, callback: receivePush }); // Remove event listener once registered for push notifications Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush); }; // END FUNCTION - registerForPush // ADD Eventlistener to Wait for user settings to be registered before registering for push notifications Ti.App.iOS.addEventListener('usernotificationsettings', registerForPush); // START JPUSH - with callback getRegistrationID JPush.start(JPushLoginSuccess); // START FUNCTION - callback to store JPushID function JPushLoginSuccess(JPushID){ Ti.API.log("JPushLoginSuccess - JPushID: " + JPushID); // run JPushID set data after 2 second delay setTimeout(function(){ // set JPushID to Ti.App.Properties Ti.App.Properties.setString('JPushID',JPushID); // run addJPushGroup() after JPushLoginSuccess addJPushGroup(); }, 2000); }; // END FUNCTION - callback to store JPushID // Start Function - deviceTokenSuccess function deviceTokenSuccess(e) { Ti.API.log("Register with deviceToken: " + e.deviceToken); JPush.registerDeviceToken(e.deviceToken); }; // End Function - deviceTokenSuccess // Start Function - deviceTokenError function deviceTokenError(e) { Ti.API.log("Failed to Find Token" + e.error); }; // End Function - deviceTokenError // START FUNCTION - receivePush for iOS function receivePush(e) { // Ti.API.info Raw Payload Ti.API.info("Received Push:" + JSON.stringify(e)); // JSON.parse payload var pushNotification = e; // Set Values var pushData = pushNotification.data; // send pushData to JPush to log Push received JPush.pushReceived(pushData); // setTimeout of 500miliseconds and then run pushPopUp function with params setTimeout(function(){ // YOUR CUSTOM POPUP ALERT HERE // USING DATA YOU CAN EXTRACT OUT OF pushData },500); }; // END FUNCTION - receivePush for iOS // ELSE IF - Android only }else if (Ti.Platform.name == 'android'){ // REQUIRE JPUSH MOFULE var JPush = require('cn.jpush.ti'); // ADD EVENTLISTENTER AND FUNCTION TO MODULE JPush.addEventListener('JPushLoginSuccess',function(evt){ Ti.API.log("JPushLoginSuccess - JPushID: " + evt.registrationID); // set JPushID to Ti.App.Properties Ti.App.Properties.setString('JPushID',evt.registrationID); // run addJPushGroup() after JPushLoginSuccess addJPushGroup(); }); // 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 pushData = JSON.parse(evt); // setTimeout of 500miliseconds and then run pushPopUp function with params setTimeout(function(){ // YOUR CUSTOM POPUP ALERT HERE // USING DATA YOU CAN EXTRACT OUT OF pushData },500); }); }; // END IF - Android Only /////////////////////////////////////////////////////////////////////////////////////////// // START FUNCTION TO ADD TO JPUSH GROUP // // START FUNCTION - addJPushGroup function addJPushGroup(){ // firstClear groups var clearTags = []; JPush.setTags(clearTags); // set tagsToSet in Array var tagsToSet = []; tagsToSet.push("highUsage"); Ti.API.log("JPush.setTags: " + tagsToSet); // SET JPush tags JPush.setTags(tagsToSet); }; // END FUNCTION - addJPushGroup // END FUNCTION TO ADD TO JPUSH GROUP // ///////////////////////////////////////////////////////////////////////////////////////////
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.
Hi Kiteplans,
I have requirement to display the custom layout remote push notification with the “Accept” and “Decline” button options along with description and image. And need to handle its corresponding actions from the notification. We are not using the ArrowDB services. Kindly let me know if your module supports the above requirement, if so I am interested to purchase your module. It is at high priority, eagerly waiting for your response.
Thanks,
Basappa
Yes it should be able to do custom Layout for Android but I can not offer support
Thanks, I got it.
I have posted 3 orders, but they were all marked as fraud and cancelled, could you help me ?
Hi,
Glad you found my iOS and Android Titanium JPUSH module! I have edited your account and re-submitted an order – please submit payment – after payment you will receive links to the download.
Peace
I have some questions, how can I reach you?
I already sent you an email earlier – check your email and spam box..
The new issue that I have found is message of notification has been truncated on notification column. Can you help me figure it out? Thanks
Can you email me an example?
Dear Kiteplans ,
when I clicked the Complete Order button for the item “Appcelerator Titanium Alloy JPUSH Push Notification Module – iOS and Android” , It came one problem,the message is:
Oops, there’s a problem…
MaxMind Error
Hello,
I noticed that your order was marked as fraud. I have fixed this and marked the invoice as unpaid. Please pay the invoice, then I will send you the latest versions of the Modules.
David
你好,
我看到你的订单被认为是欺诈行为。 我已经从新设置。 你支付以后我就可以发给你最新版的模块。
谢谢
大卫