I have got the following code in my index.ts
const payload: admin.messaging.MessagingPayload = {
notification: {
title: 'New Order!',
body: you sold a ${order.day} for ${order.time},
},
};
return fcm.sendToDevice(tokens, payload);
And this in my Flutter:
messaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
},
onBackgroundMessage: myBackgroundMessageHandler
);
}
static Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
var data = message['data'] ?? message;
print(data);
// Or do other work.
}
While the onMessage
part works perfectly finely, onLaunch and onResume don't work. Netierh does the onBackgroundMessage.
question from:
https://stackoverflow.com/questions/65942443/firebase-messaging-cant-send-background-messages-flutter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…