如何从 firebase_messaging 推送通知中获取时间?
How to get time from firebase_messaging push notifications?
我正在 Android 上制作一个 Flutter 应用,它接收来自 Firebase 云消息服务的通知。有什么方法可以让我知道我的 phone 收到通知的时间吗?当我的 onMessage、onResume 和 onLaunch 函数触发时,我注意到有一个 "google.sent_time:" 键,但我不知道如何将其转换为实际时间。
sent_time
应该是自纪元以来的毫秒数。您可以使用以下代码段将此时间戳转换为日期:
new DateTime.fromMillisecondsSinceEpoch(sentTime);
我正在 Android 上制作一个 Flutter 应用,它接收来自 Firebase 云消息服务的通知。有什么方法可以让我知道我的 phone 收到通知的时间吗?当我的 onMessage、onResume 和 onLaunch 函数触发时,我注意到有一个 "google.sent_time:" 键,但我不知道如何将其转换为实际时间。
sent_time
应该是自纪元以来的毫秒数。您可以使用以下代码段将此时间戳转换为日期:
new DateTime.fromMillisecondsSinceEpoch(sentTime);