wjc
1 天以前 b48b2ecc0882fb68ae0c6bd631bb5b913fe1428c
app/src/main/java/com/hdl/photovoltaic/push/fcm/MyFirebaseMessagingService.java
@@ -26,6 +26,7 @@
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;
@@ -37,6 +38,9 @@
import cn.jpush.android.api.NotificationMessage;
/**
 * 谷歌推送消息接收方法
 */
public class MyFirebaseMessagingService extends FirebaseMessagingService {
    private static final String TAG = "FCMService";
@@ -72,12 +76,13 @@
            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 {
            // 检查消息是否包含通知负载
@@ -112,7 +117,7 @@
                .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);
@@ -133,10 +138,10 @@
        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;
    }