| | |
| | | import com.hdl.photovoltaic.push.PushMessageInfoBean; |
| | | import com.hdl.photovoltaic.ui.BPowerStationActivity; |
| | | import com.hdl.photovoltaic.ui.StartActivity; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | |
| | | import cn.jpush.android.api.NotificationMessage; |
| | | |
| | | /** |
| | | * 谷歌推送消息接收方法 |
| | | */ |
| | | public class MyFirebaseMessagingService extends FirebaseMessagingService { |
| | | private static final String TAG = "FCMService"; |
| | | |
| | |
| | | title = remoteMessage.getNotification().getTitle(); |
| | | content = remoteMessage.getNotification().getBody(); |
| | | } |
| | | if (isAppInForeground(this)) { |
| | | //原生在前台或者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); |
| | | // handleDataMessage(remoteMessage.getData()); |
| | | // this.showCustomNotification(pushMessageInfoBean); |
| | | } |
| | | } else { |
| | | // 检查消息是否包含通知负载 |
| | |
| | | .setWhen(System.currentTimeMillis()); |
| | | |
| | | // 设置点击意图,为通知添加点击后的跳转意图 |
| | | Intent intent = createNotificationIntent(pushMessageInfoBean.getExpandData()); |
| | | Intent intent = createNotificationIntent(pushMessageInfoBean); |
| | | PendingIntent pendingIntent = PendingIntent.getActivity( |
| | | this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); |
| | | builder.setContentIntent(pendingIntent); |
| | |
| | | notificationManager.createNotificationChannel(channel); |
| | | } |
| | | |
| | | private Intent createNotificationIntent(String data) { |
| | | private Intent createNotificationIntent(PushMessageInfoBean pushMessageInfoBean) { |
| | | Intent intent = new Intent(this, StartActivity.class); |
| | | intent.putExtra("from_fcm", true); |
| | | intent.putExtra("pushData", data); |
| | | intent.putExtra("pushData", JSONObject.toJSONString(pushMessageInfoBean)); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | return intent; |
| | | } |