| | |
| | | |
| | | import androidx.multidex.MultiDex; |
| | | |
| | | import com.alibaba.sdk.android.push.CloudPushService; |
| | | import com.alibaba.sdk.android.push.CommonCallback; |
| | | import com.alibaba.sdk.android.push.noonesdk.PushInitConfig; |
| | | import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; |
| | | import com.alibaba.sdk.android.push.register.MiPushRegister; |
| | | import com.alibaba.sdk.android.push.register.OppoRegister; |
| | | import com.google.android.gms.common.ConnectionResult; |
| | | import com.google.android.gms.common.GoogleApiAvailability; |
| | | import com.google.firebase.messaging.FirebaseMessaging; |
| | |
| | | // //9.初始化网络工具 |
| | | // NetWorkUtil.init(this); |
| | | initAutoSize(); |
| | | // //初始化极光推送 |
| | | // initJPush(); |
| | | // //谷歌原生fcm推送 |
| | | // // 检查 Google Play Services 后再初始化 FCM |
| | | // if (isGooglePlayServicesAvailable(this)) { |
| | | // initFCM(); |
| | | // } else { |
| | | // HdlLogLogic.print("Google Play Services 不可用,无法使用 FCM", true); |
| | | // // 可以在这里初始化备选推送方案(如阿里云自建通道) |
| | | // } |
| | | //阿里云推送 |
| | | initAliYunPush(); |
| | | //初始化极光推送 |
| | | initJPush(); |
| | | //谷歌原生fcm推送 |
| | | // 检查 Google Play Services 后再初始化 FCM |
| | | if (isGooglePlayServicesAvailable(this)) { |
| | | initFCM(); |
| | | } else { |
| | | HdlLogLogic.print("Google Play Services 不可用,无法使用 FCM", true); |
| | | // 可以在这里初始化备选推送方案(如阿里云自建通道) |
| | | } |
| | | initHDLLinkPMSdk(); |
| | | HDLLinkLocalSdk.getInstance().init(getInstance()); |
| | | initSocket(); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 初始化阿里云推送 |
| | | */ |
| | | private void initAliYunPush() { |
| | | PushInitConfig pushInitConfig = new PushInitConfig.Builder() |
| | | .application(this) |
| | | .appKey("335628427") //请填写你自己的appKey,云端给的 |
| | | .appSecret("fd1dabe7ec494c878a5970d8646c83bc") //请填写你自己的appSecret,云端给的 |
| | | .build(); |
| | | PushServiceFactory.init(pushInitConfig); |
| | | CloudPushService pushService = PushServiceFactory.getCloudPushService(); |
| | | pushService.register(this, new CommonCallback() { |
| | | @Override |
| | | public void onSuccess(String success) { |
| | | String deviceId = pushService.getDeviceId(); |
| | | Log.d("com.aliyun.emas.pocdemo", "获取deviceId " + deviceId); |
| | | saveToken(deviceId); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailed(String errorCode, String errorMessage) { |
| | | //错误码连接:https://help.aliyun.com/document_detail/434686.html?spm=a2c4g.11186623.0.0.62d3556dC2DqKJ#topic-1824037 |
| | | Log.d("com.aliyun.emas.pocdemo", "初始化失败,错误码: " + errorCode + "错误信息: " + errorMessage); |
| | | |
| | | } |
| | | }); |
| | | if (AppConfigManage.isDebug()) { |
| | | //仅适用于Debug包,正式包不需要此行 |
| | | pushService.setLogLevel(CloudPushService.LOG_DEBUG); |
| | | } |
| | | //小米 |
| | | //appKey/appSecret在小米开发者平台获取 |
| | | MiPushRegister.register(this, "2882303761520382032", "5612038223032"); |
| | | // OPPO通道注册 |
| | | //appKey/appSecret在OPPO开发者平台获取 |
| | | OppoRegister.register(this, "d80747c83e38442aaa2e5183c310bae0", "86afce21417b49a4984816024b15d4b9"); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 初始化友盟SDK,抓闪退日志 |