| | |
| | | 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; |
| | | |
| | | 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; |