【问题标题】:Firebase Messaging Get Cloud Function NameFirebase 消息传递获取云函数名称
【发布时间】:2020-11-22 20:56:04
【问题描述】:

我有 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
}


}

【问题讨论】:

    标签: firebase flutter google-cloud-functions firebase-cloud-messaging


    【解决方案1】:

    您必须编写函数代码以在消息的有效负载中发送该字符串值。它不会自动发送。

    【讨论】:

      猜你喜欢
      • 2017-07-31
      • 2019-05-14
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多