kotlin 如何在Android中使用Firebase Cloud函数显示通知负载内的图像?

j1dl9f46  于 7个月前  发布在  Kotlin
关注(0)|答案(2)|浏览(96)

我想在Android中使用Firebase云函数在通知有效负载中显示照片。我想实现类似于screenshot.

中所示的内容
我的cloud函数payload代码在这里:

message = {
      notification: {
        title: username,
        body: content,
        image: profileImageUrl,  // I'm passing image url as image parameter
      },
      token: deviceToken,
    };

    return admin
      .messaging()
      .send(message)
      .then(async (response) => {
        return console.log(
          "Successfully sent notification:",
          deviceToken
        );
      })
      .catch(async (error) => {
        return console.log("Error sending notification:", error);
      });
  })
  .catch(async (error) => {
    return console.log("Error:", error);
  });

字符串
下面的代码不工作

r6vfmomb

r6vfmomb1#

不如这样:

const message = { 
    notification: {  
      title: 'Sparky says hello!' 
    },
     android: {  
      notification: {   
        imageUrl: 'https://foo.bar.pizza-monster.png'  
      } 
    },
     apns: {  
      payload: {   
        aps: {    
          'mutable-content': 1   
        }  
      },
        fcm_options: {   
        image: 'https://foo.bar.pizza-monster.png'  
      } 
    },

字符串
From:https://firebase.google.com/docs/cloud-messaging/android/send-image

e5nszbig

e5nszbig2#

“notification”:{

"title": "Sparky says hello!",

"image": "https://foo.bar.pizza-monster.png"

字符串
}

相关问题