2025年12月05日11:47:12 先隐藏掉阿拉伯语言
1,因为脚本还没有适配好;
| | |
| | | initAutoSize(); |
| | | // //初始化极光推送 |
| | | // initJPush(); |
| | | // //谷歌原生fcm推送 |
| | | // // 检查 Google Play Services 后再初始化 FCM |
| | | // if (isGooglePlayServicesAvailable(this)) { |
| | | // initFCM(); |
| | | // } else { |
| | | // HdlLogLogic.print("Google Play Services 不可用,无法使用 FCM", true); |
| | | // // 可以在这里初始化备选推送方案(如阿里云自建通道) |
| | | // } |
| | | //阿里云推送 |
| | | initAliYunPush(); |
| | | //谷歌原生fcm推送 |
| | | // 检查 Google Play Services 后再初始化 FCM |
| | | if (isGooglePlayServicesAvailable(this)) { |
| | | initFCM(); |
| | | } else { |
| | | HdlLogLogic.print("Google Play Services 不可用,无法使用 FCM", true); |
| | | // 可以在这里初始化备选推送方案(如阿里云自建通道) |
| | | } |
| | | // //阿里云推送 |
| | | // initAliYunPush(); |
| | | initHDLLinkPMSdk(); |
| | | HDLLinkLocalSdk.getInstance().init(getInstance()); |
| | | initSocket(); |
| | |
| | | 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("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>() { |
| | |
| | | * |
| | | * @param context 上下文 |
| | | * @param pushMessageInfoBean 推送数据对象实体 |
| | | * @param isOpened true=点击通知栏回调,false=收到推送通知回调; |
| | | * @param isAppInForeground true表示是前台,false表示后台 |
| | | */ |
| | | public void PushPushCommonData(Context context, PushMessageInfoBean pushMessageInfoBean, boolean isOpened) { |
| | | public void PushPushCommonData(Context context, PushMessageInfoBean pushMessageInfoBean, boolean isAppInForeground) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //添加推送数据到缓存列表中; |
| | | // this.addPushDataToMemoryList(pushMessageInfoBean); |
| | | if (isOpened) { |
| | | // //安装商跳转界面 |
| | | // Intent intent = new Intent(context, BPowerStationActivity.class); |
| | | // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | // intent.putExtra("skip", "skip");//里面判断有这个标识就跳转到消息中心界面 |
| | | // context.startActivity(intent); |
| | | } else { |
| | | if (isAppInForeground) { |
| | | //应用在前台通知更新住宅消息列表即可 |
| | | BaseEventBus bus = new BaseEventBus(); |
| | | bus.setTopic(ConstantManage.refresh_message_house); |
| | | bus.setType(ConstantManage.refresh_message_house); |
| | | EventBus.getDefault().post(bus); |
| | | EventBus.getDefault().postSticky(bus); |
| | | } else { |
| | | // 安装商跳转界面 |
| | | // Intent intent = new Intent(context, BPowerStationActivity.class); |
| | | // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | // intent.putExtra("skip", "skip");//里面判断有这个标识就跳转到消息中心界面 |
| | | // context.startActivity(intent); |
| | | } |
| | | } else { |
| | | // if (isOpened) { |
| | | //产品经理说暂时不做 2024年03月29日10:34:44 |
| | | // boolean existsActivity = AppManagerUtils.getAppManager().existsActivity(MessageCenterListActivity.class); |
| | | // if (existsActivity) { |
| | | // //存在唯一一种可能就是当前活动窗口就是它 |
| | | // return; |
| | | // } |
| | | // //跳转C端消息中心界面 |
| | | // Intent intent = new Intent(context, MessageCenterListActivity.class); |
| | | // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | // context.startActivity(intent); |
| | | // //不管存不存在这些Activity(找到才移除),都要做这些动作,有可能当前的活动窗口是其中一个 |
| | | // AppManagerUtils.getAppManager().finishActivity(AccountAndSecurityActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(AsRegardsActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(BindMailActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(BindPhoneActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(languageSelectionActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(MeChangePasswordActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(PersonalDataActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(SetActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(TemperatureUnitActivity.class); |
| | | // AppManagerUtils.getAppManager().finishActivity(WebActivity.class); |
| | | // //通知uni移除界面 |
| | | // HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | // uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_REMOVE_VIEW); |
| | | // HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | |
| | | // } |
| | | } |
| | | } |
| | |
| | | } |
| | | PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, data); |
| | | //原生在前台或者uni在前台 |
| | | if (this.isAppInForegroundOrIsShowUniMP(context)) { |
| | | HdlPushLogic.getInstance().PushPushCommonData(context, pushMessageInfoBean, false); |
| | | if (this.isAppInForeground(context)) { |
| | | HdlPushLogic.getInstance().PushPushCommonData(context, pushMessageInfoBean, true); |
| | | } else { |
| | | this.showCustomNotification(context, pushMessageInfoBean, fromPush); |
| | | } |
| | | // this.showCustomNotification(context, pushMessageInfoBean); |
| | | } |
| | | |
| | | /** |
| | | * 是否在前台 true表示在前台,false表示在后台 |
| | | * |
| | | * @param context 上下文 |
| | | * @return true表示在前台,false表示在后台 |
| | | */ |
| | | public boolean isAppInForegroundOrIsShowUniMP(Context context) { |
| | | return (this.isAppInForeground(context) || HDLUniMPSDKManager.getInstance().showUniMP()); |
| | | } |
| | | |
| | | /** |
| | | * 处理通知消息(应用在后台时,系统会自动显示通知) |
| | |
| | | |
| | | /** |
| | | * 获取Intent |
| | | * @param context 上下文 |
| | | * |
| | | * @param context 上下文 |
| | | * @param pushMessageInfoBean 数据模型 |
| | | * @param fromPush 消息来自(极光,谷歌,阿里云)平台 |
| | | * @param fromPush 消息来自(极光,谷歌,阿里云)平台 |
| | | * @return 意图 |
| | | */ |
| | | public Intent createNotificationIntent(Context context, PushMessageInfoBean pushMessageInfoBean, FromPush fromPush) { |
| | |
| | | * @param context 上下 |
| | | * @return true表示在前台,false在后台 |
| | | */ |
| | | private boolean isAppInForeground(Context context) { |
| | | public boolean isAppInForeground(Context context) { |
| | | try { |
| | | ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
| | | List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); |
| | |
| | | return false; |
| | | } |
| | | final String packageName = context.getPackageName(); |
| | | final String uniPackageName = packageName + ":unimp0"; |
| | | for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { |
| | | if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(packageName)) { |
| | | if ((appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(packageName)) || (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(uniPackageName))) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onNotPushData(Intent intent) { |
| | | //TODO 没有推送数据,可能是异常调用,需要异常处理 |
| | | finish(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void onParseFailed(Intent intent) { |
| | | //TODO 推送数据解密异常,需要异常处理 |
| | | finish(); |
| | | } |
| | | |
| | | /** |
| | | * 解析厂商特定的数据 |
| | | */ |
| | | private void parseVendorSpecificData(Intent intent) { |
| | | // 小米通道数据解析 |
| | | if (intent.hasExtra("miPushMessage")) { |
| | | Log.d(TAG, "小米通道数据"); |
| | | // 小米推送的数据结构 |
| | | } |
| | | |
| | | // 华为通道数据解析 |
| | | if (intent.hasExtra("hms_message_id")) { |
| | | Log.d(TAG, "华为通道数据"); |
| | | // 华为推送的数据结构 |
| | | } |
| | | |
| | | // OPPO通道数据解析 |
| | | if (intent.hasExtra("oppo_push_message")) { |
| | | Log.d(TAG, "OPPO通道数据"); |
| | | } |
| | | |
| | | // vivo通道数据解析 |
| | | if (intent.hasExtra("vivo_push_message")) { |
| | | Log.d(TAG, "vivo通道数据"); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | Log.d(TAG, "onNotificationReceivedInApp:title=" + title |
| | | + " content=" + content + " extraMap=" + JSON.toJSONString(extraMap) + " openType=" |
| | | + openType + " openActivity=" + openActivity + " openUrl=" + openUrl); |
| | | // CustomNotification.getInstance().messageDataProcessing(context, title, content, JSON.toJSONString(extraMap)); |
| | | //如果在前台时,发送通知让消息列表更新,在后台是,这里不会执行,会执行VendorChannelActivity.onSysNoticeOpened()的方法 |
| | | CustomNotification.getInstance().messageDataProcessing(context, title, content, JSON.toJSONString(extraMap),CustomNotification.FromPush.AliYun); |
| | | } |
| | | |
| | | /** |
| | |
| | | public boolean showNotificationNow(Context context, Map<String, String> extraMap) { |
| | | //false表示拦截,true表示不拦截,请根据进行拦截,拦截后会执行到 onNotificationReceivedInApp |
| | | Log.d(TAG, "showNotificationNow:" + "extraMap=" + JSON.toJSONString(extraMap)); |
| | | return !CustomNotification.getInstance().isAppInForegroundOrIsShowUniMP(context); |
| | | return !CustomNotification.getInstance().isAppInForeground(context); |
| | | // return false; |
| | | } |
| | | } |
| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.enums.MessageStateType; |
| | | import com.hdl.photovoltaic.other.HdlPushLogic; |
| | | import com.hdl.photovoltaic.push.CustomNotification; |
| | | import com.hdl.photovoltaic.push.PushMessageInfoBean; |
| | | import com.hdl.photovoltaic.ui.BPowerStationActivity; |
| | | import com.hdl.photovoltaic.ui.StartActivity; |
| | |
| | | */ |
| | | @Override |
| | | public void onMessageReceived(RemoteMessage remoteMessage) { |
| | | Log.d(TAG, "在前台还是在后" + isAppInForeground(this)); |
| | | Log.d(TAG, "是否在前台:" + isAppInForeground(this)); |
| | | Log.d(TAG, "来自RemoteMessage: " + JSON.toJSONString(remoteMessage)); |
| | | // // 数据消息:任何状态都会执行 |
| | | // if (!remoteMessage.getData().isEmpty()) { |
| | |
| | | // if (remoteMessage.getNotification() != null) { |
| | | // handleNotification(remoteMessage.getNotification()); // 只有前台执行 |
| | | // } |
| | | |
| | | |
| | | String title = "";//推送标题 |
| | | String content = "";//推送内容 |
| | | if (remoteMessage.getNotification() != null) { |
| | | title = remoteMessage.getNotification().getTitle(); |
| | | content = remoteMessage.getNotification().getBody(); |
| | | } |
| | | //原生在前台或者uni在前台 |
| | | if (isAppInForeground(this) || HDLUniMPSDKManager.getInstance().showUniMP()) { |
| | | // 检查消息是否包含数据负载 |
| | | if (!remoteMessage.getData().isEmpty()) { |
| | | PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, JSON.toJSONString(remoteMessage.getData())); |
| | | HdlPushLogic.getInstance().PushPushCommonData(this, pushMessageInfoBean, false); |
| | | // this.showCustomNotification(pushMessageInfoBean); |
| | | } |
| | | } else { |
| | | // 检查消息是否包含通知负载 |
| | | if (!remoteMessage.getData().isEmpty()) { |
| | | PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, JSON.toJSONString(remoteMessage.getData())); |
| | | this.showCustomNotification(pushMessageInfoBean); |
| | | } |
| | | if (!remoteMessage.getData().isEmpty()) { |
| | | CustomNotification.getInstance().messageDataProcessing(this, title, content, JSON.toJSONString(remoteMessage.getData()), CustomNotification.FromPush.FCM); |
| | | } |
| | | // //原生在前台或者uni在前台 |
| | | // if (isAppInForeground(this)) { |
| | | // // 检查消息是否包含数据负载 |
| | | // if (!remoteMessage.getData().isEmpty()) { |
| | | // PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, JSON.toJSONString(remoteMessage.getData())); |
| | | // HdlPushLogic.getInstance().PushPushCommonData(this, pushMessageInfoBean, false); |
| | | //// this.showCustomNotification(pushMessageInfoBean); |
| | | // } |
| | | // } else { |
| | | // // 检查消息是否包含通知负载 |
| | | // if (!remoteMessage.getData().isEmpty()) { |
| | | // PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing(title, content, JSON.toJSONString(remoteMessage.getData())); |
| | | // this.showCustomNotification(pushMessageInfoBean); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | return false; |
| | | } |
| | | final String packageName = context.getPackageName(); |
| | | final String uniPackageName = packageName + ":unimp0"; |
| | | for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { |
| | | if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(packageName)) { |
| | | if ((appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(packageName)) || (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && |
| | | appProcess.processName.equals(uniPackageName))) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | */ |
| | | private void clickNotificationMessageTab() { |
| | | //触发消息点击事件 |
| | | // 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); |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId()) && !pushMessageInfoBean.isAiPrompt()) { |
| | | return; |
| | | } |
| | | Log.d("==========111111", tag); |
| | | HDLUniMPSDKManager.uinEnabled = false; |
| | | if (tag.equals("onNewIntent")) { |
| | | HDLUniMPSDKManager.uinEnabled = false; |
| | |
| | | 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); |
| | | HdlLogLogic.print("uni---原生主动向小程序发送通知AI事件---", false); |
| | | } else { |
| | | MessageBean messageBean = new MessageBean(); |
| | | messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId())); |
| | |
| | | intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class); |
| | | intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean)); |
| | | startActivity(intentMessageInfoActivity); |
| | | HdlLogLogic.print("uni---原生主动向小程序发送通知AI事件---11111", false); |
| | | } |
| | | |
| | | } |