本文整理匯總了Java中cn.jpush.android.api.JPushInterface.setAlias方法的典型用法代碼示例。如果您正苦於以下問題:Java JPushInterface.setAlias方法的具體用法?Java JPushInterface.setAlias怎麽用?Java JPushInterface.setAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.jpush.android.api.JPushInterface
的用法示例。
在下文中一共展示了JPushInterface.setAlias方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAliasInJpush
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
/**
* 在jpush上設置別名
*/
public static void setAliasInJpush(final Context context, String alias)
{
//在jpush上設置別名
JPushInterface.setAlias(context.getApplicationContext(), alias, new TagAliasCallback()
{
@Override
public void gotResult(int i, String s, Set<String> set)
{
if (i == 0)
{
L.e("設置別名成功");
} else
{
HandleResponseCode.onHandle(context, i);
}
}
});
}
示例2: setAlias
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
public static void setAlias(JSONArray data, CallbackContext callbackContext) {
try {
String alias = data.getString(0);
JPushInterface.setAlias(cordovaCxt,
alias, mTagWithAliasCallback);
callbackContext.success();
} catch (JSONException e) {
e.printStackTrace();
callbackContext.error("Error reading alias JSON");
}
}
示例3: onCreate
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
@Override
public void onCreate() {
context = getApplicationContext();
super.onCreate();
// 初始化極光推送sdk
// JPushInterface.setDebugMode(true);
JPushInterface.init(this);
JPushInterface.setAlias(context, "WOTPlus1.0", new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
Log.d("Jpush set alias", String.valueOf(i));
}
});
}
示例4: setAlias
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
/**
* 設置別名,
* 華為不支持alias的寫法,所以隻能用tag,tag隻能放map,所以alias作為value,key為name
*
* @param context
* @param alias
*/
public static void setAlias(final Context context, String alias) {
if (TextUtils.isEmpty(alias))
return;
if (RomUtil.rom() == Target.EMUI) {
Map<String, String> tag = new HashMap<>();
tag.put("name", alias);
PushManager.setTags(context, tag);
return;
}
if (RomUtil.rom() == Target.MIUI) {
MiPushClient.setAlias(context, alias, null);
return;
}
if (RomUtil.rom() == Target.FLYME) {
com.meizu.cloud.pushsdk.PushManager.subScribeAlias(context, Const.getFlyme_app_id(), Const.getFlyme_app_key(), getToken(context).getToken(), alias);
return;
}
if (RomUtil.rom() == Target.JPUSH) {
JPushInterface.setAlias(context, alias, new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
if (i == 0) { // 這裏極光規定0代表成功
if (JPushReceiver.getPushInterface() != null) {
L.i("JPushInterface.setAlias");
JPushReceiver.getPushInterface().onAlias(context, s);
}
}
}
});
return;
}
}
示例5: setAlias
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
/**
* 設置別名
* <p>
* 華為
* <p>
* 不支持alias的寫法,所以隻能用tag,tag隻能放map,所以alias作為value,key為name
* ==========
* 極光 別名
* <p>
* "" (空字符串)表示取消之前的設置。
* 每次調用設置有效的別名,覆蓋之前的設置。
* 有效的別名組成:字母(區分大小寫)、數字、下劃線、漢字、特殊字符(v2.1.6支持)@!#$&*+=.|。
* 限製:alias 命名長度限製為 40 字節。(判斷長度需采用UTF-8編碼)
* ==========
* 小米 別名
* <p>
* 一個RegId可以被設置多個別名,如果設置的別名已經存在,會覆蓋掉之前的別名。
*/
public static void setAlias(final Context context, String alias) {
if (TextUtils.isEmpty(alias))
return;
if (RomUtil.rom() == PhoneTarget.EMUI) {
Map<String, String> tag = new HashMap<>();
tag.put("name", alias);
com.huawei.android.pushagent.api.PushManager.setTags(context, tag);
return;
}
if (RomUtil.rom() == PhoneTarget.MIUI) {
MiPushClient.setAlias(context, alias, null);
return;
}
if (RomUtil.rom() == PhoneTarget.JPUSH) {
JPushInterface.setAlias(context, alias, new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
if (i == 0) { // 這裏極光規定0代表成功
if (JPushReceiver.getPushListener() != null) {
JPushReceiver.getPushListener().onAlias(context, s);
}
}
}
});
}
}
示例6: pushBindService
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
/**
* 向雲端綁定推送
*
* @param Token
* @param Channel_ID
* @param gizPushType
*/
public static void pushBindService(String token) {
if (GizPushType.GizPushJiGuang == gizPushType) {
// 獲取JPush的RegistrationID,即Channel_ID
Channel_ID = JPushInterface.getRegistrationID(context);
// 設定JPush類型
JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
@Override
public void gotResult(int arg0, String arg1, Set<String> arg2) {
if (arg0 == 0) {
Log.i("Apptest", "Alias: " + arg1);
} else {
Log.e("Apptest", "Result: " + arg0);
}
}
});
} else if (GizPushType.GizPushBaiDu == gizPushType) {
// 獲取BDPush的Channel_ID
Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
} else {
return;
}
// TODO 綁定推送
Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
示例7: saveToSP
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
private void saveToSP(User user) {
SPUtils.setParam(context,Constants.LOGIN_INFO,Constants.SP_TEL,user.getT_user_login().getTel()!=null?user.getT_user_login().getTel():"");
SPUtils.setParam(context,Constants.LOGIN_INFO,Constants.SP_PASSWORD,user.getT_user_login().getPassword()!=null?user.getT_user_login().getPassword():"");
SPUtils.setParam(context,Constants.LOGIN_INFO,Constants.SP_USERID,user.getT_user_login().getId());
SPUtils.setParam(context,Constants.LOGIN_INFO,Constants.SP_STATUS,user.getT_user_login().getStatus());
SPUtils.setParam(context,Constants.LOGIN_INFO,Constants.SP_QNTOKEN,user.getT_user_login().getQiniu());
SPUtils.setParam(context,Constants.USER_INFO,Constants.USER_NICK,user.getT_merchant().getName()!=null?user.getT_merchant().getName():"");
SPUtils.setParam(context,Constants.USER_INFO,Constants.USER_MERCHANT_ID,user.getT_merchant().getId());
SPUtils.setParam(context,Constants.USER_INFO,Constants.USER_PAY_PASS,user.getT_merchant().getPay_password());
SPUtils.setParam(context,Constants.USER_INFO,Constants.USER_IMG,user.getT_merchant().getName_image()!=null?user.getT_merchant().getName_image():"");
final ChatManager chatManager = ChatManager.getInstance();
if (!TextUtils.isEmpty(String.valueOf(user.getT_user_login().getId()))) {
chatManager.setupManagerWithUserId(this, String.valueOf(user.getT_user_login().getId()));
JPushInterface.setAlias(getApplicationContext(), "jianguo"+user.getT_user_login().getId(), new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
}
});
}
ChatManager.getInstance().openClient(new AVIMClientCallback() {
@Override
public void done(AVIMClient avimClient, AVIMException e) {
if (null == e) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
} else {
showShortToast(e.toString());
}
}
});
}
示例8: handleAction
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
/**
* 處理設置tag
* */
public void handleAction(Context context, int sequence, TagAliasBean tagAliasBean){
init(context);
if(tagAliasBean == null){
Logger.w(TAG,"tagAliasBean was null");
return;
}
put(sequence,tagAliasBean);
if(tagAliasBean.isAliasAction){
switch (tagAliasBean.action){
case ACTION_GET:
JPushInterface.getAlias(context,sequence);
break;
case ACTION_DELETE:
JPushInterface.deleteAlias(context,sequence);
break;
case ACTION_SET:
JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
break;
default:
Logger.w(TAG,"unsupport alias action type");
return;
}
}else {
switch (tagAliasBean.action) {
case ACTION_ADD:
JPushInterface.addTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_SET:
JPushInterface.setTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_DELETE:
JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_CHECK:
//一次隻能check一個tag
String tag = (String)tagAliasBean.tags.toArray()[0];
JPushInterface.checkTagBindState(context,sequence,tag);
break;
case ACTION_GET:
JPushInterface.getAllTags(context, sequence);
break;
case ACTION_CLEAN:
JPushInterface.cleanTags(context, sequence);
break;
default:
Logger.w(TAG,"unsupport tag action type");
return;
}
}
}
示例9: saveToSP
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
private void saveToSP(User user) {
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_WQTOKEN, user.getT_user_login().getQqwx_token() != null ? user.getT_user_login().getQqwx_token() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_TEL, user.getT_user_login().getTel() != null ? user.getT_user_login().getTel() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_PASSWORD, user.getT_user_login().getPassword() != null ? user.getT_user_login().getPassword() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_USERID, user.getT_user_login().getId());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_STATUS, user.getT_user_login().getStatus());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_QNTOKEN, user.getT_user_login().getQiniu());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_APK_URL, user.getApk_url());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_VERSION, user.getVersion());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_CONTENT, user.getContent());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_RESUMM, user.getT_user_login().getResume());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_HOBBY, user.getT_user_login().getHobby());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_NICK, user.getT_user_info().getNickname() != null ? user.getT_user_info().getNickname() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_NAME, user.getT_user_info().getName() != null ? user.getT_user_info().getName() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_IMG, user.getT_user_info().getName_image() != null ? user.getT_user_info().getName_image() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_SCHOOL, user.getT_user_info().getSchool() != null ? user.getT_user_info().getSchool() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_CREDIT, user.getT_user_info().getCredit());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_INTEGRAL, user.getT_user_info().getIntegral());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.USER_SEX, user.getT_user_info().getUser_sex());
// 暫時關閉果聊功能
// final ChatManager chatManager = ChatManager.getInstance();
if (!TextUtils.isEmpty(String.valueOf(user.getT_user_login().getId()))) {
if (JPushInterface.isPushStopped(getActivity().getApplicationContext())) {
JPushInterface.resumePush(getActivity().getApplicationContext());
}
//登陸leancloud服務器 給極光設置別名
// chatManager.setupManagerWithUserId(this, String.valueOf(user.getT_user_login().getId()));
JPushInterface.setAlias(getActivity().getApplicationContext(), "jianguo" + user.getT_user_login().getId(), new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
LogUtils.e("jpush", s + ",code=" + i);
}
});
}
// ChatManager.getInstance().openClient(new AVIMClientCallback() {
// @Override
// public void done(AVIMClient avimClient, AVIMException e) {
// if (null == e) {
// TalkMessageEvent talkMessageEvent=new TalkMessageEvent();
// talkMessageEvent.isLogin=true;
// EventBus.getDefault().post(talkMessageEvent);
// } else {
// showShortToast(e.toString());
// }
// }
// });
}
示例10: saveToSP
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
private void saveToSP(User user) {
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_WQTOKEN, user.getT_user_login().getQqwx_token() != null ? user.getT_user_login().getQqwx_token() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_TEL, user.getT_user_login().getTel() != null ? user.getT_user_login().getTel() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_PASSWORD, user.getT_user_login().getPassword() != null ? user.getT_user_login().getPassword() : "");
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_USERID, user.getT_user_login().getId());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_STATUS, user.getT_user_login().getStatus());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_QNTOKEN, user.getT_user_login().getQiniu());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_APK_URL, user.getApk_url());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_VERSION, user.getVersion());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_CONTENT, user.getContent());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.LOGIN_HOBBY, user.getT_user_login().getHobby());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_NICK, user.getT_user_info().getNickname() != null ? user.getT_user_info().getNickname() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_NAME, user.getT_user_info().getName() != null ? user.getT_user_info().getName() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_IMG, user.getT_user_info().getName_image() != null ? user.getT_user_info().getName_image() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_SCHOOL, user.getT_user_info().getSchool() != null ? user.getT_user_info().getSchool() : "");
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_CREDIT, user.getT_user_info().getCredit());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.SP_INTEGRAL, user.getT_user_info().getIntegral());
SPUtils.setParam(getActivity(), Constants.LOGIN_INFO, Constants.SP_RESUMM, user.getT_user_login().getResume());
SPUtils.setParam(getActivity(), Constants.USER_INFO, Constants.USER_SEX, user.getT_user_info().getUser_sex());
// 暫時關閉果聊功能
// final ChatManager chatManager = ChatManager.getInstance();
if (!TextUtils.isEmpty(String.valueOf(user.getT_user_login().getId()))) {
if (JPushInterface.isPushStopped(getActivity().getApplicationContext())) {
JPushInterface.resumePush(getActivity().getApplicationContext());
}
//登陸leancloud服務器 給極光設置別名
// chatManager.setupManagerWithUserId(getActivity(), String.valueOf(user.getT_user_login().getId()));
JPushInterface.setAlias(getActivity().getApplicationContext(), "jianguo" + user.getT_user_login().getId(), new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
LogUtils.e("jpush", s + ",code=" + i);
}
});
}
// ChatManager.getInstance().openClient(new AVIMClientCallback() {
// @Override
// public void done(AVIMClient avimClient, AVIMException e) {
// if (null == e) {
// TalkMessageEvent talkMessageEvent=new TalkMessageEvent();
// talkMessageEvent.isLogin=true;
// EventBus.getDefault().post(talkMessageEvent);
// } else {
//// Toast.makeText(getActivity(),e.getMessage(),Toast.LENGTH_SHORT).show();
//// getActivity().showShortToast(e.toString());
// }
// }
// });
}
示例11: saveToSP
import cn.jpush.android.api.JPushInterface; //導入方法依賴的package包/類
private void saveToSP(User user) {
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_WQTOKEN, user.getT_user_login().getQqwx_token() != null ? user.getT_user_login().getQqwx_token() : "");
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_TEL, user.getT_user_login().getTel() != null ? user.getT_user_login().getTel() : "");
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_PASSWORD, user.getT_user_login().getPassword() != null ? user.getT_user_login().getPassword() : "");
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_USERID, user.getT_user_login().getId());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_STATUS, user.getT_user_login().getStatus());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_QNTOKEN, user.getT_user_login().getQiniu());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.SP_RESUMM, user.getT_user_login().getResume());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.LOGIN_APK_URL, user.getApk_url());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.LOGIN_VERSION, user.getVersion());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.LOGIN_CONTENT, user.getContent());
SPUtils.setParam(context, Constants.LOGIN_INFO, Constants.LOGIN_HOBBY, user.getT_user_login().getHobby());
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_NICK, user.getT_user_info().getNickname() != null ? user.getT_user_info().getNickname() : "");
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_NAME, user.getT_user_info().getName() != null ? user.getT_user_info().getName() : "");
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_IMG, user.getT_user_info().getName_image() != null ? user.getT_user_info().getName_image() : "");
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_SCHOOL, user.getT_user_info().getSchool() != null ? user.getT_user_info().getSchool() : "");
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_CREDIT, user.getT_user_info().getCredit());
SPUtils.setParam(context, Constants.USER_INFO, Constants.SP_INTEGRAL, user.getT_user_info().getIntegral());
SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_SEX, user.getT_user_info().getUser_sex());
LogUtils.e("jpush","userid"+user.getT_user_login().getId());
//暫時關閉果聊功能
// final ChatManager chatManager = ChatManager.getInstance();
if (!TextUtils.isEmpty(String.valueOf(user.getT_user_login().getId()))) {
//登陸leancloud服務器 給極光設置別名
// LCChatKit.getInstance().open(String.valueOf(user.getT_user_login().getId()), new AVIMClientCallback() {
// @Override
// public void done(AVIMClient avimClient, AVIMException e) {
// if (null == e) {
// finish();
// Intent intent = new Intent(SplashActivity.this, MainActivity.class);
// startActivity(intent);
// } else {
// Toast.makeText(SplashActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
// }
// }
// });
// chatManager.setupManagerWithUserId(this, String.valueOf(user.getT_user_login().getId()));
LogUtils.e("jpush","調用jpush");
if (JPushInterface.isPushStopped(getApplicationContext())){
JPushInterface.resumePush(getApplicationContext());
}
// ","隔開的多個 轉換成 Set,設置tags
// String tag = "test";
// String[] sArray = tag.split(",");
// Set<String> tagSet = new LinkedHashSet<String>();
// tagSet.add(tag);
// for (String sTagItme : sArray) {
// tagSet.add(sTagItme);
// }
// JPushInterface.setAliasAndTags(getApplicationContext(),"jianguo"+user.getT_user_login().getId(),tagSet, new TagAliasCallback() {
// @Override
// public void gotResult(int i, String s, Set<String> set) {
// LogUtils.e("jpush",s+",code="+i);
// }
// });
JPushInterface.setAlias(getApplicationContext(),"jianguo"+user.getT_user_login().getId(), new TagAliasCallback() {
@Override
public void gotResult(int i, String s, Set<String> set) {
LogUtils.e("jpush",s+",code="+i);
}
});
}
}