알림 페이로드로 이미지 보내기

FCM HTTP v1 API 및 알림 작성기는 디스플레이 알림의 페이로드로 이미지 링크를 보내 전송 후 기기에 이미지를 다운로드할 수 있도록 지원합니다. 알림용 이미지 크기는 1MB로 제한되어 있으며 그 밖에 기본 Android 이미지 지원 제한사항이 적용됩니다.

보내기 요청 빌드

알림 보내기 요청에서 다음과 같이 AndroidConfig 옵션을 설정합니다.

  • notification.image(이미지 URL 포함)

다음 전송 요청은 모든 플랫폼에 공통 알림 제목을 보내지만 이미지도 보냅니다. 다음은 사용자 기기에 표시되는 시각 효과의 예시입니다.

디스플레이 알림 이미지의 간단한 그림

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" } } } } 

메시지 본문의 플랫폼별 블록에서 제공하는 키에 관한 자세한 내용은 HTTP v1 참조 문서를 확인하세요.

위와 같이 보내기 요청에 notification을 설정하면 수신 클라이언트가 페이로드로 전달된 이미지를 처리할 수 있습니다.