在Android中获取java.lang.numberformatException无效的int null

时间:2018-09-19 11:27:58

标签: android firebase firebase-cloud-messaging firebase-notifications

我正在使用Firebase在我的应用程序中进行推送通知。我收到消息。当应用程序关闭并收到通知时,单击通知会打开该应用程序,但不会进入我指导的页面。我尝试调试;如果打开了该应用程序,则单击推送通知服务,但是在关闭该应用程序后,如果收到消息,则不会单击该服务断点。

后来我发现此异常:

  

在GCM事件中解析时间戳时发生错误java.lang.NumberFormatException android中的int null无效

有人知道如何解决这个问题吗?

W/FirebaseMessaging: Error while parsing timestamp in GCM event
java.lang.NumberFormatException: Invalid int: "null"
at java.lang.Integer.invalidInt(Integer.java:137)
at java.lang.Integer.parseInt(Integer.java:354)
at java.lang.Integer.parseInt(Integer.java:331)
at java.lang.Integer.valueOf(Integer.java:489)
at com.google.firebase.messaging.zzd.zzc(Unknown Source)
at com.google.firebase.messaging.zzd.zzi(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(Unknown Source)
at com.google.firebase.iid.zzc.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

这是代码

public class ToDoMessagingService extends FirebaseMessagingService {

private static final int NOTIFICATION_ID = 1;

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    try {
        Log.e("data", "Data Payload: " + remoteMessage.getData().toString());
        if (remoteMessage.getData().size() > 0) {
            Log.e("data", "Data Payload: " + remoteMessage.getData().toString());
        }
        String title = remoteMessage.getNotification().getTitle();
        String body = remoteMessage.getNotification().getBody();
        String media_type = remoteMessage.getData().get("mt");
        String username = remoteMessage.getData().get("unm");
        String post_user_image = remoteMessage.getData().get("pui");
        String hqp_media = remoteMessage.getData().get("hqm");
        String hqp_created_date = remoteMessage.getData().get("hqcd");
        String hqp_body = remoteMessage.getData().get("hqb");
        String likes_on_post = remoteMessage.getData().get("lks");
        String postid = remoteMessage.getData().get("pid");
        String video_thumbnail = remoteMessage.getData().get("vt");
        String you_liked = remoteMessage.getData().get("ul");

        Log.e("title", title);
        Log.e("body", body);
        Log.e("media_type", media_type);
        Log.e("date", hqp_created_date);
        if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(body)) {
            sendNotification(title, body, username, post_user_image, hqp_body, hqp_created_date, hqp_media, questid, likes_on_post, postid, video_thumbnail, you_liked, media_type);
        }
          } catch (Exception e) {
        e.printStackTrace();
    }
}

}

类似的问题在这里:- Error when push notification by postman but not when send by Firebase console

0 个答案:

没有答案