本文整理汇总了Java中com.xiaomi.mipush.sdk.MiPushClient类的典型用法代码示例。如果您正苦于以下问题:Java MiPushClient类的具体用法?Java MiPushClient怎么用?Java MiPushClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MiPushClient类属于com.xiaomi.mipush.sdk包,在下文中一共展示了MiPushClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceiveRegisterResult
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void onReceiveRegisterResult(Context context, MiPushCommandMessage message) {
Log.v(DemoApplication.TAG,
"onReceiveRegisterResult is called. " + message.toString());
String command = message.getCommand();
List<String> arguments = message.getCommandArguments();
String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
String log;
if (MiPushClient.COMMAND_REGISTER.equals(command)) {
if (message.getResultCode() == ErrorCode.SUCCESS) {
mRegId = cmdArg1;
//Log.d("register","success");
//log = context.getString(R.string.register_success);
} else {
//log = context.getString(R.string.register_fail);
}
} else {
//log = message.getReason();
}
/*Message msg = Message.obtain();
msg.obj = log;
DemoApplication.getHandler().sendMessage(msg);*/
}
示例2: setServiceEnable
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
/**
* Set XMPush sdk enable
* @param enable enable
* @param context context param
*/
public static void setServiceEnable (boolean enable, Context context) {
if (enable && isAppMainProc(context)) {
MiPushClient.registerPush(wrapContext(context), APP_ID, APP_KEY);
} else {
MiPushClient.unregisterPush(wrapContext(context));
// Force stop and disable services.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.cancelAll();
}
context.stopService(new Intent(context, XMPushService.class));
}
}
示例3: onReceiveRegisterResult
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void onReceiveRegisterResult(Context context, MiPushCommandMessage message) {
Log.v(MYTAG,
"onReceiveRegisterResult is called. " + message.toString());
String command = message.getCommand();
List<String> arguments = message.getCommandArguments();
String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
String log;
if (MiPushClient.COMMAND_REGISTER.equals(command)) {
if (message.getResultCode() == ErrorCode.SUCCESS) {
deviceMiToken = cmdArg1;
Log.v(MYTAG,
"小米推送token:" + deviceMiToken);
} else {
Log.v(MYTAG,
"小米推送注册失败!" );
}
} else {
log = message.getReason();
}
}
示例4: initData
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
protected void initData() {
try {
Login.setInstance((Login) MySharedPreferences.getObjectData(Login.sharedPreferences));
BaseModuleCache.setInstance((BaseModuleCache) MySharedPreferences.getObjectData(BaseModuleCache.sharedPreferences));
} catch (Exception e) {
e.printStackTrace();
}
/*设置推送别名,可以在服务端指定登录者推送消息*/
MiPushClient.setUserAccount(MainActivity.this, Login.getInstance().getUserAccount(), null);
getPermission();
/*获取待审核消息数量*/
GetJobTip.GetNoticeCount(txtJobTip);
/*获取没有阅读公告消息的数量*/
GetNotReadTip.GetMyNotReadNoticeCount(txtReportTip);
/*获取更新*/
UpdateManager update = new UpdateManager(MainActivity.this);
update.checkUpdate(false);
/*获取公告*/
paraMap.put("userId", Login.getInstance().getUserId());
paraMap.put("moduleId", ModuleUtil.getModuleId("公告消息"));
paraMap.put("Readstatu", "2");//0未读公告2全部
new SystemMsgItemPresenter(this);
presenter.getData(mOffset, SIZE, paraMap);
}
示例5: onReceiveRegisterResult
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void onReceiveRegisterResult(Context context, MiPushCommandMessage message) {
Log.v(MyApplication.TAG, "onReceiveRegisterResult is called. " + message.toString());
String command = message.getCommand();
List<String> arguments = message.getCommandArguments();
String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
String log;
if (MiPushClient.COMMAND_REGISTER.equals(command)) {
if (message.getResultCode() == ErrorCode.SUCCESS) {
mRegId = cmdArg1;
log = context.getString(R.string.register_success);
} else {
log = context.getString(R.string.register_fail);
}
} else {
log = message.getReason();
}
Message msg = Message.obtain();
msg.obj = log;
MyApplication.getHandler().sendMessage(msg);
}
示例6: unregister
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
public static void unregister(Context context) {
if (context == null)
return;
if (RomUtil.rom() == Target.EMUI) {
EMHuaweiPushReceiver.clearPushInterface();
PushManager.deregisterToken(context, getToken(context).getToken());
return;
}
if (RomUtil.rom() == Target.MIUI) {
MiuiReceiver.clearPushInterface();
MiPushClient.unregisterPush(context);
return;
}
if (RomUtil.rom() == Target.FLYME) {
FlymeReceiver.clearPushInterface();
com.meizu.cloud.pushsdk.PushManager.unRegister(context, Const.getFlyme_app_id(), Const.getFlyme_app_key());
return;
}
if (RomUtil.rom() == Target.JPUSH) {
JPushReceiver.clearPushInterface();
JPushInterface.stopPush(context);
return;
}
}
示例7: getToken
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
/**
* 获取唯一的token
*
* @param context
* @return
*/
public static TokenModel getToken(Context context) {
if (context == null)
return null;
TokenModel result = new TokenModel();
result.setTarget(RomUtil.rom());
if (RomUtil.rom() == Target.EMUI) {
result.setToken(EMHuaweiPushReceiver.getmToken());
}
if (RomUtil.rom() == Target.MIUI) {
result.setToken(MiPushClient.getRegId(context));
}
if (RomUtil.rom() == Target.FLYME) {
result.setToken(com.meizu.cloud.pushsdk.PushManager.getPushId(context));
}
if (RomUtil.rom() == Target.JPUSH) {
result.setToken(JPushInterface.getRegistrationID(context));
}
return result;
}
示例8: unregister
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
public static void unregister(Context context) {
if (context == null)
return;
if (RomUtil.rom() == PhoneTarget.EMUI) {
HWReceiver.clearPushListener();
com.huawei.android.pushagent.api.PushManager.deregisterToken(context, getToken(context).getToken());
return;
}
if (RomUtil.rom() == PhoneTarget.MIUI) {
MiMessageReceiver.clearPushListener();
MiPushClient.unregisterPush(context);
return;
}
if (RomUtil.rom() == PhoneTarget.JPUSH) {
JPushReceiver.clearPushListener();
JPushInterface.stopPush(context);
return;
}
}
示例9: getToken
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
/**
* 获取唯一的token
*
* @param context
* @return
*/
public static TokenModel getToken(Context context) {
if (context == null)
return null;
TokenModel result = new TokenModel();
result.setTarget(RomUtil.rom());
if (RomUtil.rom() == PhoneTarget.EMUI) {
result.setToken(HWReceiver.getmToken());
}
if (RomUtil.rom() == PhoneTarget.MIUI) {
result.setToken(MiPushClient.getRegId(context));
}
if (RomUtil.rom() == PhoneTarget.JPUSH) {
result.setToken(JPushInterface.getRegistrationID(context));
}
return result;
}
示例10: onReceiveRegisterResult
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void onReceiveRegisterResult(Context context, MiPushCommandMessage message) {
//注意:本回调在非主UI线程
Log4jLog.d(LONG_TAG, "onReceiveRegisterResult is called. " + message.toString());
String command = message.getCommand();
List<String> arguments = message.getCommandArguments();
String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
String log;
if (MiPushClient.COMMAND_REGISTER.equals(command)) {
if (message.getResultCode() == ErrorCode.SUCCESS) {
mRegId = cmdArg1;
log = "register_success, mRegId = " + mRegId;
ThirdPartyPushHelper.pushToken = mRegId;
ThirdPartyPushHelper.setPushToken(true);
} else {
log = "register_fail: " + message.getReason();
}
} else {
log = message.getReason();
}
Log4jLog.d(LONG_TAG, log);
}
示例11: handleMessage
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
final Context context = CURRENT_CONTEXT.get();
if (context == null) {
Log.d(TAG, "null context.");
return;
}
if (msg.what == PushSDKManager.MSG_START_SDK) {
Log.d(TAG, "try start sdk.");
MiPushClient.registerPush(context, APP_ID, APP_KEY);
} else if (msg.what == PushSDKManager.MSG_STOP_SDK) {
Log.d(TAG, "try stop sdk.");
MiPushClient.unregisterPush(context);
PrefUtil.setBooleanValue(context, PREF_KEY_ENABLE, false);
PrefUtil.setBooleanValue(context, PREF_KEY_STOPPING, false);
}
}
示例12: onCreate
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// 注册push服务,注册成功后会向DemoMessageReceiver发送广播
// 可以从DemoMessageReceiver的onCommandResult方法中MiPushCommandMessage对象参数中获取注册信息
if (shouldInit()) {
MiPushClient.registerPush(this, APP_ID, APP_KEY);
}
/*if (sHandler == null) {
sHandler = new DemoHandler(getApplicationContext());
}*/
}
示例13: setAccountAsAlias
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
public void setAccountAsAlias() {
String xiaomiUserId = Utils.getXiaomiUserId(this.mAppCtx);
if ((TextUtils.isEmpty(this.mUid) && !TextUtils.isEmpty(xiaomiUserId)) || (!TextUtils.isEmpty(this.mUid) && !this.mUid.equals(xiaomiUserId))) {
if (TextUtils.isEmpty(this.mUid)) {
MiPushClient.setAlias(this.mAppCtx, xiaomiUserId, null);
} else {
MiPushClient.unsetAlias(this.mAppCtx, this.mUid, null);
}
this.mUid = xiaomiUserId;
}
}
示例14: registerMi
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
/**
* 注册小米推送
* @param context
* @param miAppId
* @param miAppKey
*/
public static void registerMi(Context context, String miAppId, String miAppKey) {
try {
MiPushClient.registerPush(context, miAppId, miAppKey);
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: unsetAlias
import com.xiaomi.mipush.sdk.MiPushClient; //导入依赖的package包/类
@Override
public void unsetAlias(Context context, String alias) {
List<String> allAlias = MiPushClient.getAllAlias(context);
for (int i = 0; i < allAlias.size(); i++) {
MiPushClient.unsetAlias(context, allAlias.get(i), null);
}
}