Bildirim yükünde resim gönderin

FCM HTTP v1 API'si ve Bildirim Oluşturucu, teslimattan sonra cihaza indirilmek üzere resim bağlantılarının bir görüntüleme bildiriminin yükünde gönderilmesini destekler. Bildirimlerdeki resimler 1 MB ile sınırlıdır ve aksi takdirde yerel Android resim desteği ile kısıtlanır.

Gönderme isteğini oluşturma

Bildirim gönderme isteğinizde aşağıdaki AndroidConfig seçeneğini ayarlayın:

  • notification.image içeren resim URL'si

Aşağıdaki örnek gönderme isteği, tüm platformlara ortak bir bildirim başlığı gönderir ancak bir resim de gönderir. Kullanıcının cihazındaki görsel efektin yaklaşık görünümü:

Görüntüleme bildirimindeki bir resmin basit çizimi

Node.js

const topicName = 'industry-tech';

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'
    }
  },
  webpush: {
    headers: {
      image: 'https://foo.bar.pizza-monster.png'
    }
  },
  topic: topicName,
};

getMessaging().send(message)
  .then((response) => {
    // Response is a message ID string.
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

REST

POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA
{
  "message":{
     "topic":"industry-tech",
     "notification":{
       "title":"Sparky says hello!",
     },
     "android":{
       "notification":{
         "image":"https://foo.bar/pizza-monster.png"
       }
     },
     "apns":{
       "payload":{
         "aps":{
           "mutable-content":1
         }
       },
       "fcm_options": {
           "image":"https://foo.bar/pizza-monster.png"
       }
     },
     "webpush":{
       "headers":{
         "image":"https://foo.bar/pizza-monster.png"
       }
     }
   }
 }

İleti gövdesindeki platforma özgü bloklarda bulunan anahtarlarla ilgili tüm ayrıntılar için HTTP v1 referans belgelerine bakın.

notification, gösterildiği gibi ayarlandığında bu gönderme isteği, alan istemcinin yükte teslim edilen resmi işlemesini sağlar.