Java Firebase云消息推送通知出现错误

Java Firebase云消息推送通知出现错误,java,android,firebase,firebase-cloud-messaging,Java,Android,Firebase,Firebase Cloud Messaging,所以基本上我已经尝试使用Firebase云消息模块实现推送通知。起初我无法接收通知,但在重新搜索Oreo版本的androi通知的代码差异后,当应用程序位于前台时,该通知工作正常,但当应用程序关闭或位于后台时,会出现以下错误: 因此,当我仔细监视日志猫时,它显示的是: 分析GCM事件中的时间戳时出错 java.lang.NumberFormatException:无效的int:“null” 位于java.lang.Integer.Invalidit(Integer.java:138) 我的Fi

所以基本上我已经尝试使用Firebase云消息模块实现推送通知。起初我无法接收通知,但在重新搜索Oreo版本的androi通知的代码差异后,当应用程序位于前台时,该通知工作正常,但当应用程序关闭或位于后台时,会出现以下错误:

因此,当我仔细监视日志猫时,它显示的是:

分析GCM事件中的时间戳时出错 java.lang.NumberFormatException:无效的int:“null” 位于java.lang.Integer.Invalidit(Integer.java:138)

我的FirebaseMessageService类代码如下:

    public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {

        private  String CHANNEL_ID = "personal_notifications";
        NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID,"personal_notifications",NotificationManager.IMPORTANCE_DEFAULT);


        @Override
        public void onMessageReceived(RemoteMessage remoteMessage) {
            super.onMessageReceived(remoteMessage);


            String notification_title = remoteMessage.getNotification().getTitle();
            String notification_message = remoteMessage.getNotification().getBody();

            String click_action = remoteMessage.getNotification().getClickAction();


                String from_user_id = remoteMessage.getData().get("from_user_id");

                NotificationCompat.Builder mBuilder =
                        new NotificationCompat.Builder(this, CHANNEL_ID)
                                .setSmallIcon(R.drawable.chitchat_icon)
                                .setContentTitle(notification_title)
                                .setAutoCancel(true)
                                .setContentText(notification_message);


                Intent resultIntent = new Intent(click_action);
                resultIntent.putExtra("user_id", from_user_id);


                PendingIntent resultPendingIntent =
                        PendingIntent.getActivity(
                                this,
                                0,
                                resultIntent,
                                PendingIntent.FLAG_UPDATE_CURRENT
                        );

                mBuilder.setContentIntent(resultPendingIntent);


                int mNotificationId = (int) System.currentTimeMillis();

            NotificationManager mNotificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                mNotificationManager.createNotificationChannel(mChannel);
            }

            mNotificationManager.notify(mNotificationId,mBuilder.build());
        } 
}
我不知道为什么我的频道只有在我尝试在后台发送通知时才为空

编辑:
当我在Linux上构建项目时,推送通知出现在前台,并在后台给出上述错误,但当我从windows构建项目时,我在后台或前台都没有收到任何通知。

要解决无法在通道null上发布通知的问题,您必须将您的firebase messaging版本更新为最新版本或至少15.0.2。希望这能解决问题

除此之外,您还可以将以下元数据添加到您的AndroidManifest中,以加倍确保其工作正常。谢谢

<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>


请详细说明哪个json文件?从服务器/邮递员传递给Firebase API的json对象。请检查:如果您想使用Firebase控制台发送通知,那么在android oreo及以后的版本中,它将不会在后台工作或处于Kill状态。我已经部署了一个js函数来发送付费负载:
const payload={notification:{title:{Friend Request],body:
${userName}已向您发送请求
,图标:“默认”,单击“操作:”com.example.chitchat\u TARGET\u NOTIFICATION“},数据:{from\u user\u id:from\u user\u id};
Ok,如果遵循此过程,则必须添加在单击系统托盘中的通知时要启动的活动的意图过滤器。