Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0Digg thisPin on Pinterest0Email this to someone

你好,

新版本 》 http://kiteplans.info/2015/04/04/appcelerator-titanium-alloy-jpush-push-notification-module-ios-and-android-china-push-notification-non-gcm/

你们都知道国内安卓的手机几乎不支持谷歌的服务,所以GCM不可用。

对于国内的推送,建议用JPUSH(极光推送)

我做了很多研究,没有找到任何好的Titanium Alloy JPUSH 模块。我在这个博客上找到了一个几乎不能用的,借鉴了一些,然后写了自己的模块。

所以这是我自己为Titanium Alloy写的JPUSH模块,该模块已经测试,能够直接使用。

因为写出该模块花费了不少精力,所以你需要支付一定费用才能下载使用。

****本人不提供任何安装或使用支持****

点击下方来付款并下载Titanium Alloy JPUSH 模块

你支付后会收到一封邮件,邮件中有具体下载链接。

##安装说明

1. 将已下载的zip放在你APP的root中,build app——Titanium 会自己安装

2. 将这一行添加到tiapp.xml

<module platform="android">com.yeshcp.jpush</module>

3. 将这一行添加到tiapp.xml来避免安卓crash bug

<property name="ti.android.bug2373.finishfalseroot" type="bool">true</property>

## app 设置

4. 你需要把J push给你的App ID放在

app/modules/android/com.yeshcp.jpush/VERSION/timodule.xml

<meta-data android:name="JPUSH_APPKEY" android:value="YOUR-JPUSH-APPID-GOES-HERE"/

##如何使用

5. 把这个放在你的App.js file

// 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);

****如果你需要这个模块的source,请在评论中留言。

If you enjoyed this post, why not leave a comment or consider a Donation as a token of your appreciation. If you need help implementing something you saw on this site or any other project why not Hire Me?
Appcelerator Titanium Alloy JPUSH 模块 – 安卓推送模块 - 国内可用的安卓推送
Tagged on:                                 

Leave a Reply

Your email address will not be published. Required fields are marked *

13 thoughts on “Appcelerator Titanium Alloy JPUSH 模块 – 安卓推送模块 - 国内可用的安卓推送

Loading Facebook Comments ...