极光推送设置

1、设置别名和标签
public class MyJpush {
	public  void pushInit(Context context, String UserName) {
		// JPushInterface.stopPush(context);
		//System.out.println(JPushInterface.isPushStopped(context)+ "   ****************");
		JPushInterface.setDebugMode(true);
		JPushInterface.init(context);
		JPushInterface.resumePush(context);
		Set tagSet = new LinkedHashSet();
		tagSet.add(UserName);
		//System.out.println("用户名: " + UserName);
		//别名alias和标签tag
		JPushInterface.setTags(context, tagSet, mTagsCallback);
	}
	private final  TagAliasCallback mTagsCallback = new TagAliasCallback() {		
		@Override
		public void gotResult(int code, String alias, Set tags) {
			String logs;
			switch (code) {
				case 0:
					logs = "推送注册成功";
				break;
				case 6002:
					logs = "推送注册失败";
				break;
				default:
					logs = "Failed with errorCode = " + code;
			}
			//Log.e("标签设置", logs);
			//System.out.println("推送状态:"+logs);
		}
	};
}

在登录时,根据用户名设置

// 设置标签别名
new MyJpush().pushInit(this,
	AbMd5.MD5("youyou" + bean.getClassid()).toLowerCase());

2、设置是否接收推送通知

JPushInterface.resumePush(getApplicationContext());//接收,可以再任意处设置
JPushInterface.stopPush(getApplicationContext());//不接收




你可能感兴趣的:(第三方)