本文整理汇总了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);
}
});
}
}