FirebaseMessaging.onBackgroundMessage
不行,我是按照官方文件做的,我用的版本是:firebase_messaging: ^14.2.1
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Handling a background message: ${message.messageId}");
}
void main() async {
await Firebase.initializeApp()
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
}
这是我如何通过云函数发送我的fcn:
admin.messaging().sendMulticast({
tokens: [user.fcmToken!],
apns: {
payload: {
aps: {
"mutable-content": 1,
"content-available": 1,
},
},
},
notification: {
body: body,
title: title,
},
data: {
hello: "world?!",
},
});
我可以看到推送通知在我的设备上弹出,但是FirebaseMessaging.onBackgroundMessage
没有被调用。你知道问题出在哪里吗?
1条答案
按热度按时间omhiaaxx1#
我想你忘了确保初始化:)