Firebase 消息传递获取云函数名称
Firebase Messaging Get Cloud Function Name
我有 2 个不同的云功能可以向设备发送通知。一个是 sendNewChatMessageNotification,另一个是 sendNewFriendRequestNotification。
如何获取触发 firebaseMessaging 实例的 onMessage 方法的函数名称?因为我想为不同的云功能显示不同的消息。
final firebaseMessaging = FirebaseMessaging();
firebaseMessaging.getToken().then((tokenVal) {
fcmToken = tokenVal;
firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
// -----> how can I get the cloudFunctionName ??
if(cloudFunctionName == "sendNewFriendRequestNotification"){
//show friend request notification
}else if(cloudFunctionName == "sendNewChatMessageNotification"){
//show new chat message notification
}
}
您必须编写函数代码以在消息的有效负载中发送该字符串值。不会自动发送。
我有 2 个不同的云功能可以向设备发送通知。一个是 sendNewChatMessageNotification,另一个是 sendNewFriendRequestNotification。
如何获取触发 firebaseMessaging 实例的 onMessage 方法的函数名称?因为我想为不同的云功能显示不同的消息。
final firebaseMessaging = FirebaseMessaging();
firebaseMessaging.getToken().then((tokenVal) {
fcmToken = tokenVal;
firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
// -----> how can I get the cloudFunctionName ??
if(cloudFunctionName == "sendNewFriendRequestNotification"){
//show friend request notification
}else if(cloudFunctionName == "sendNewChatMessageNotification"){
//show new chat message notification
}
}
您必须编写函数代码以在消息的有效负载中发送该字符串值。不会自动发送。