【发布时间】:2021-05-16 19:04:23
【问题描述】:
在我的颤振应用程序上使用firebase messaging 时遇到了令人沮丧的体验,因为在发送请求后应用程序处于后台时,onBackgroundmessage 没有被触发。我想知道为什么这是我的应用需要的核心功能。
Future initialize(context) async{
_firebaseMessaging.configure(
onBackgroundMessage: Platform.isIOS ? null:_myBackgroundMessageHandler,
);
}
Future<dynamic> _myBackgroundMessageHandler
(Map<String, dynamic> message) async {
print("onBackground Message called");
fetchRideInfoInBackground();
return Future<void>.value();
}
}
通知负载
const message = {
notification: {
title: 'New Incoming Request',
body: `New incoming ${service} request`,
},
data: { orderId: orderId },
android: {
ttl: 30,
priority: 'high',
notification: {
click_action: 'FLUTTER_NOTIFICATION_CLICK',
},
},
tokens: driversRegistrationToken,
};
【问题讨论】:
标签: flutter firebase-cloud-messaging