在前台接收 Firebase 推送通知时,颤振应用会显示错误:"Reading a NULL string not supported here."



我在我的flutter应用程序中集成了Firebase云消息(FCM)。通知在后台和终止状态下都能正常工作。但是当处理前台消息时,错误显示E/Parcel (27639): Reading a NULL string not supported here.

代码如下:

FirebaseMessaging.onMessage.listen((RemoteMessage message) {
final notification = message.notification;
print(notification?.body);
});

注意:这个问题只在访问notification.body时发生,其他没有问题。

当你在前台时收到通知。您需要在活动结束标签之后和应用程序结束标签之前添加以下androidManifest.xml:

<!-- [START firebase_service] -->
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- [END firebase_service] -->

之后再run/build您的项目。我知道你会得到你的正文。

相关内容

最新更新