app/build.gradle
@@ -237,8 +237,8 @@ // implementation 'com.aliyun.ams:alicloud-android-third-push-huawei:3.10.1' //小米国内通道依赖 implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.9.2' ////OPPO依赖 // implementation 'com.aliyun.ams:alicloud-android-third-push-oppo:3.10.1' //OPPO依赖 implementation 'com.aliyun.ams:alicloud-android-third-push-oppo:3.9.2' ////vivo依赖 // implementation 'com.aliyun.ams:alicloud-android-third-push-vivo:3.10.1' ////魅族依赖 app/src/main/AndroidManifest.xml
@@ -198,6 +198,7 @@ android:exported="false" /> <activity android:name=".ui.CPowerStationActivity" android:launchMode="singleTask" android:exported="false" /> <activity android:name=".ui.message.MessageInfoActivity" @@ -254,6 +255,7 @@ android:exported="false" /> <activity android:name=".ui.BPowerStationActivity" android:launchMode="singleTask" android:exported="false" /> <activity android:name=".ui.LoginActivity" app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -24,6 +24,7 @@ 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; @@ -252,7 +253,11 @@ pushService.setLogLevel(CloudPushService.LOG_DEBUG); } //小米 //appKey/appSecret在小米开发者平台获取 MiPushRegister.register(this, "2882303761520382032", "5612038223032"); // OPPO通道注册 //appKey/appSecret在OPPO开发者平台获取 OppoRegister.register(this, "d80747c83e38442aaa2e5183c310bae0", "86afce21417b49a4984816024b15d4b9"); } app/src/main/java/com/hdl/photovoltaic/other/HdlAccountLogic.java
@@ -820,7 +820,7 @@ * 退出登录 */ public void logout(LogoutType logoutType) { HdlResidenceLogic.getInstance().pushDel(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushDel(new CloudCallBeak<String>() { @Override public void onSuccess(String obj) { // SharedPreUtils.putBoolean("pushAddCache", true); app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java
@@ -2,14 +2,21 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.text.TextUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.hdl.linkpm.sdk.core.exception.HDLException; import com.hdl.photovoltaic.config.AppConfigManage; import com.hdl.photovoltaic.config.ConstantManage; import com.hdl.photovoltaic.config.UserConfigManage; import com.hdl.photovoltaic.enums.MessageStateType; import com.hdl.photovoltaic.internet.HttpClient; import com.hdl.photovoltaic.internet.api.HttpApi; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.push.PushMessageInfoBean; import com.hdl.photovoltaic.ui.BPowerStationActivity; import com.hdl.photovoltaic.ui.bean.MessageBean; @@ -47,6 +54,78 @@ } /** * 添加推送Token * * @param cloudCallBeak - */ public void pushAdd(CloudCallBeak<String> cloudCallBeak) { String requestUrl = HttpApi.POST_push_add; JsonObject json = new JsonObject(); json.addProperty("deviceName", Build.MODEL);//设备名称 json.addProperty("deviceType", "Android");//设备类型 json.addProperty("produce", AppConfigManage.isIsOnlineServer());//表示是否是正式服务器 json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken());//App的推送Token,在极光为RegId json.addProperty("software", "PHOTOVOLTAIC");//软件来源把PHOTOVOLTAIC改成XENTERRA,也就云端说的通道号(channel) json.addProperty("platform", "ALIYUN_APNS");//阿里云的版本的platform // json.addProperty("platform", "FCM");//google的版本的platform json.addProperty("language", UserConfigManage.getInstance().getCurrentAppLanguage());//2.0追加的字段 HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { if (!TextUtils.isEmpty(pushId)) { UserConfigManage.getInstance().setPushId(pushId); UserConfigManage.getInstance().Save(); } if (cloudCallBeak != null) { cloudCallBeak.onSuccess(pushId); } } @Override public void onFailure(HDLException e) { if (cloudCallBeak != null) { cloudCallBeak.onFailure(e); } } }); } /** * 删除推送Token * * @param cloudCallBeak - */ public void pushDel(CloudCallBeak<String> cloudCallBeak) { String requestUrl = HttpApi.POST_push_del; JsonObject json = new JsonObject(); json.addProperty("pushId", UserConfigManage.getInstance().getPushId()); json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken()); HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { @Override public void onSuccess(String jsonStr) { if (cloudCallBeak != null) { cloudCallBeak.onSuccess(jsonStr); } } @Override public void onFailure(HDLException e) { if (cloudCallBeak != null) { cloudCallBeak.onFailure(e); } } }); } /** * 推送数据统一处理的方法 * * @param context 上下文 app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -1140,77 +1140,7 @@ } /** * 添加推送Token * * @param cloudCallBeak - */ public void pushAdd(CloudCallBeak<String> cloudCallBeak) { String requestUrl = HttpApi.POST_push_add; JsonObject json = new JsonObject(); json.addProperty("deviceName", Build.MODEL);//设备名称 json.addProperty("deviceType", "Android");//设备类型 json.addProperty("produce", AppConfigManage.isIsOnlineServer());//表示是否是正式服务器 json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken());//App的推送Token,在极光为RegId json.addProperty("software", "XENTERRA");//软件来源把PHOTOVOLTAIC改成XENTERRA json.addProperty("platform", "ALIYUN_APNS");//阿里云的版本的platform // json.addProperty("platform", "FCM");//google的版本的platform json.addProperty("language", UserConfigManage.getInstance().getCurrentAppLanguage());//2.0追加的字段 HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { if (!TextUtils.isEmpty(pushId)) { UserConfigManage.getInstance().setPushId(pushId); UserConfigManage.getInstance().Save(); } if (cloudCallBeak != null) { cloudCallBeak.onSuccess(pushId); } } @Override public void onFailure(HDLException e) { if (cloudCallBeak != null) { cloudCallBeak.onFailure(e); } } }); } /** * 删除推送Token * * @param cloudCallBeak - */ public void pushDel(CloudCallBeak<String> cloudCallBeak) { String requestUrl = HttpApi.POST_push_del; JsonObject json = new JsonObject(); json.addProperty("pushId", UserConfigManage.getInstance().getPushId()); json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken()); HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { @Override public void onSuccess(String jsonStr) { if (cloudCallBeak != null) { cloudCallBeak.onSuccess(jsonStr); } } @Override public void onFailure(HDLException e) { if (cloudCallBeak != null) { cloudCallBeak.onFailure(e); } } }); } public static class HouseBeanClass { app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -968,6 +968,7 @@ */ public void sendUni(String topic, HDLUniMP.UniCallBackBaseBean callBackBaseBean) { try { // HdlLogLogic.print("uni---原生主动向小程序发送通知事件---" +topic, false); HDLUniMPSDKManager.getInstance().sendUniMPEvent(HDLUniMP.UNI_APP_ID, topic, getJSONObject(callBackBaseBean)); } catch (Exception e) { HdlLogLogic.print("uni---原生主动向小程序发送通知事件---" + e.getMessage(), false); app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -111,7 +111,7 @@ @Override public void onBindView(Bundle savedInstanceState) { // //通知栏点击进来,防止应用在后台时被重复启动,阿里云推动通知指定打开某个Activity,没有设置Flags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);默认启动新实例,导致多个实例 //// //通知栏点击进来,防止应用在后台时被重复启动,阿里云推动通知指定打开某个Activity,没有设置Flags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);默认启动新实例,导致多个实例 // if (!isTaskRoot()) { // finish(); // } @@ -155,8 +155,8 @@ if (TextUtils.isEmpty(data)) { return; } PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class); // PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data); // PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class); PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data); if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) { return; } @@ -324,7 +324,7 @@ // UserConfigManage.getInstance().setRegistrationID(registrationID); // UserConfigManage.getInstance().Save(); String finalRegistrationID = registrationID; HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { @@ -362,7 +362,7 @@ if (TextUtils.isEmpty(token)) { return; } HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true); @@ -878,15 +878,16 @@ */ private void clickNotificationMessageTab() { //触发消息点击事件 viewBinding.myMessageBottomIl2.clickTv.performClick(); // if (currentFragmentIndex == 2) { // return; // } // currentFragmentIndex = 2; // bottomViewChangeOfStyle(); // showFragment(); // HdlCommonLogic.lowerTagType = LowerTagType.message; // HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString()); // viewBinding.myMessageBottomIl2.clickTv.performClick(); if (currentFragmentIndex == 2) { HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); return; } currentFragmentIndex = 2; bottomViewChangeOfStyle(); showFragment(); HdlCommonLogic.lowerTagType = LowerTagType.message; HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); } app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -152,7 +152,7 @@ return; } PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data); if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) { if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId()) && !pushMessageInfoBean.isAiPrompt()) { return; } HDLUniMPSDKManager.uinEnabled = false; @@ -208,7 +208,10 @@ @Override public void run() { if (pushMessageInfoBean.isAiPrompt()) { HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message, new HDLUniMP.UniCallBackBaseBean()); HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message); HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); // HdlLogLogic.print("uni---原生主动向小程序发送通知AI事件---", false); } else { MessageBean messageBean = new MessageBean(); messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId())); @@ -465,7 +468,7 @@ // UserConfigManage.getInstance().setRegistrationID(registrationID); // UserConfigManage.getInstance().Save(); String finalRegistrationID = registrationID; HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { @@ -502,7 +505,7 @@ if (TextUtils.isEmpty(token)) { return; } HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { app/src/main/java/com/hdl/photovoltaic/ui/LoginActivity.java
@@ -33,6 +33,7 @@ import com.hdl.photovoltaic.databinding.ActivityHomeLoginBinding; import com.hdl.photovoltaic.enums.Languages; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlPushLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; import com.hdl.photovoltaic.other.HdlUniLogic; import com.hdl.photovoltaic.ui.account.ChangePassword; @@ -210,17 +211,6 @@ intent.setClass(HDLApp.getInstance(), StartActivity.class); startActivity(intent); viewBinding.homeLoginLanguageTv.setText(itemData.getTitle()); HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true); } @Override public void onFailure(HDLException e) { HdlLogLogic.print("添加令牌到云端失败 PushToken:" + UserConfigManage.getInstance().getPushToken() + " 错误:" + e.getMessage(), true); } }); } }); } app/src/main/java/com/hdl/photovoltaic/ui/StartActivity.java
@@ -301,7 +301,7 @@ Log.d("来自点击消息的数据===", JSONObject.toJSONString(getIntent().getExtras())); for (String key : getIntent().getExtras().keySet()) { Log.d("来自点击消息的数据", "key: " + key + " value: " + getIntent().getExtras().get(key)); if (key.equals("pushData")) { if (key.equals("pushData") || key.equals("extraMap")) { return Objects.requireNonNull(getIntent().getExtras().get(key)).toString(); } } app/src/main/java/com/hdl/photovoltaic/ui/me/languageSelectionActivity.java
@@ -17,6 +17,7 @@ import com.hdl.photovoltaic.databinding.ActivityLanguageSelectionBinding; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlPushLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.photovoltaic.ui.StartActivity; @@ -143,7 +144,7 @@ Intent intent = new Intent(); intent.setClass(HDLApp.getInstance(), StartActivity.class); startActivity(intent); HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { @Override public void onSuccess(String pushId) { HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true); app/src/main/java/com/hdl/photovoltaic/ui/message/MessageHouseFragment.java
@@ -48,7 +48,7 @@ private FragementMessageHouseBinding viewBinding; private MessageHouseAdapter mMessageHouseAdapter; private boolean isFirstLoading = true; private boolean isRead = true; private final List<MessageBean> mList = new ArrayList<>(); @@ -82,7 +82,7 @@ HdlMessageLogic.getInstance().getMessageHouseList(homeName, new CloudCallBeak<List<MessageBean>>() { @Override public void onSuccess(List<MessageBean> list) { isFirstLoading = false; isRead = false; if (isShowLoading) { hideLoading(); } @@ -339,18 +339,17 @@ // 取消粘性事件 EventBus.getDefault().removeStickyEvent(eventBus); HdlLogLogic.print("正在点击【消息】"); //第二次进来不显示加载框 if (!isFirstLoading) { if (!isRead) { //第二次进来不显示加载框 initData(false); } } } else if (eventBus.getTopic().equals(ConstantManage.refresh_message_house)) { // 取消粘性事件 EventBus.getDefault().removeStickyEvent(eventBus); //第二次进来不显示加载框 if (!isFirstLoading) { initData(false); } initData(false); } }