| | |
| | | package com.yeshi.push; |
| | | |
| | | import android.app.ActivityManager; |
| | | import android.app.Application; |
| | | import android.content.Context; |
| | | import android.os.Build; |
| | | import android.os.Process; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import com.heytap.msp.push.HeytapPushManager; |
| | | import com.heytap.msp.push.callback.ICallBackResultService; |
| | | import com.huawei.hms.aaid.HmsInstanceId; |
| | | import com.huawei.hms.common.ApiException; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.meizu.cloud.pushsdk.PushManager; |
| | | import com.vivo.push.IPushActionListener; |
| | | import com.vivo.push.PushClient; |
| | | import com.xiaomi.mipush.sdk.MiPushClient; |
| | | |
| | | import java.util.List; |
| | | //暂时取消小米推送 |
| | | //import com.xiaomi.mipush.sdk.MiPushClient; |
| | | |
| | | public class PushUtil { |
| | | |
| | |
| | | new Thread() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | // 从agconnect-service.json文件中读取appId |
| | | String appId = "10409568"; |
| | | // 输入token标识"HCM" |
| | | String tokenScope = "HCM"; |
| | | String token = HmsInstanceId.getInstance(context).getToken(appId, tokenScope); |
| | | Log.i(TAG, "get token: " + token); |
| | | |
| | | // 判断token是否为空 |
| | | if(!TextUtils.isEmpty(token)) { |
| | | tokenListener.onToken("hw",token); |
| | | } |
| | | } catch (ApiException e) { |
| | | Log.e(TAG, "hw: get token failed, " + e); |
| | | } |
| | | // try { |
| | | // // 从agconnect-service.json文件中读取appId |
| | | // String appId = "10409568"; |
| | | // // 输入token标识"HCM" |
| | | // String tokenScope = "HCM"; |
| | | // String token = HmsInstanceId.getInstance(context).getToken(appId, tokenScope); |
| | | // Log.i(TAG, "get token: " + token); |
| | | // |
| | | // // 判断token是否为空 |
| | | // if(!TextUtils.isEmpty(token)) { |
| | | // tokenListener.onToken("hw",token); |
| | | // } |
| | | // } catch (ApiException e) { |
| | | // Log.e(TAG, "hw: get token failed, " + e); |
| | | // } |
| | | } |
| | | }.start(); |
| | | return; |
| | |
| | | |
| | | String appId = ManifestDataUtil.getAppMetaData(context, "XIAOMI_APPID").replace("XIAOMI-", ""); |
| | | String appKey = ManifestDataUtil.getAppMetaData(context, "XIAOMI_APPKEY").replace("XIAOMI-", ""); |
| | | MiPushClient.registerPush(context, appId, appKey);//注册小米推送 |
| | | xmRegId = MiPushClient.getRegId(context); |
| | | Log.i(TAG, "小米注册成功:" + xmRegId); |
| | | // MiPushClient.registerPush(context, appId, appKey);//注册小米推送 |
| | | // xmRegId = MiPushClient.getRegId(context); |
| | | // Log.i(TAG, "小米注册成功:" + xmRegId); |
| | | if (!StringUtils.isEmpty(xmRegId)) { |
| | | tokenListener.onToken("xm", xmRegId); |
| | | } |