| | |
| | | |
| | | import cn.jpush.android.api.NotificationMessage; |
| | | |
| | | /** |
| | | * 谷歌推送消息接收方法 |
| | | */ |
| | | public class MyFirebaseMessagingService extends FirebaseMessagingService { |
| | | private static final String TAG = "FCMService"; |
| | | |
| | |
| | | .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; |
| | | } |