FCM HTTP v1 API 및 알림 작성기는 디스플레이 알림의 페이로드로 이미지 링크를 보내 전송 후 기기에 이미지를 다운로드할 수 있도록 지원합니다.
이 기능은 Apple 앱의 이미지와 동영상을 모두 지원합니다(파일 크기 제한은 Apple 문서 참조).
Apple 앱에서 알림 이미지를 수신하고 처리하려면 알림 서비스 확장 프로그램을 추가해야 합니다.
알림 서비스 확장 프로그램을 사용하면 앱에서 최종 사용자에게 알림이 표시되도록 FCM 페이로드로 전송되는 이미지를 처리할 수 있습니다.
알림 서비스 확장 프로그램 설정
서비스 확장 프로그램을 추가하려면 APN에서 알림 수정 및 표시에 필요한 설정 작업을 수행한 후 NotificationService.m에서 FCM 확장 프로그램 도우미 API를 추가하세요.
특히 self.contentHandler(self.bestAttemptContent);로 콜백을 완성하는 대신 다음과 같이 FIRMessaging extensionHelper를 포함해 완성해야 합니다.
@interfaceNotificationService()<NSURLSessionDelegate>
@property(nonatomic)void(^contentHandler)(UNNotificationContent*contentToDeliver);@property(nonatomic)UNMutableNotificationContent*bestAttemptContent;@end@implementationNotificationService-(void)didReceiveNotificationRequest:(UNNotificationRequest*)requestwithContentHandler:(void(^)(UNNotificationContent*_Nonnull))contentHandler{self.contentHandler=contentHandler;self.bestAttemptContent=[request.contentmutableCopy];// Modify the notification content here as you wishself.bestAttemptContent.title=[NSStringstringWithFormat:@"%@ [modified]",self.bestAttemptContent.title];// Call FIRMessaging extension helper API.[[FIRMessagingextensionHelper]populateNotificationContent:self.bestAttemptContentwithContentHandler:contentHandler];}...
fcm_options.image(이미지 URL 포함). Apple에서는 리소스 유형을 올바르게 식별하기 위해 이미지 URL에 유효한 파일 확장자를 포함하도록 요구합니다.
headers({ "mutable-content": 1})
다음 전송 요청 예시는 모든 플랫폼에 공통 알림 제목을 보내지만 이미지도 보냅니다. 다음은 사용자 기기에 표시되는 시각 효과의 근사치입니다.
Node.js
consttopicName='industry-tech';constmessage={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);});
[null,null,["최종 업데이트: 2025-08-16(UTC)"],[],[],null,["The FCM HTTP v1 API and the\n[Notifications composer](//console.firebase.google.com/project/_/notification)\nsupport sending image links in the payload of a display\nnotification, for image download to the device after delivery.\nThis functionality supports both images and videos for Apple apps\n(see Apple documentation for file size limits).\n| Keep in mind:\n|\n| - Images uploaded via the Notifications composer are limited to 300KB in size.\n| - Images stored or served from Cloud Storage are subject to standard [quota limits](https://firebase.google.com/pricing)\n\nTo be able to receive and handle notification images in an Apple app, you must add\na [Notification Service Extension](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension).\nThe notification service extension allows your app to handle the image\ndelivered in the FCM payload before displaying the notification to the end user.\n\nSet up the notification service extension\n\nTo add a service extension, perform the required setup tasks for\n[modifying and presenting notifications](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ModifyingNotifications.html)\nin APNs, and then add the FCM extension helper API in `NotificationService.m`.\nSpecifically, instead of completing the callback with\n`self.contentHandler(self.bestAttemptContent);`,\ncomplete it with `FIRMessaging extensionHelper` as shown: \n\n @interface NotificationService () \u003cNSURLSessionDelegate\u003e\n @property(nonatomic) void (^contentHandler)(UNNotificationContent *contentToDeliver);\n @property(nonatomic) UNMutableNotificationContent *bestAttemptContent;\n @end\n\n @implementation NotificationService\n\n - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {\n self.contentHandler = contentHandler;\n self.bestAttemptContent = [request.content mutableCopy];\n\n // Modify the notification content here as you wish\n self.bestAttemptContent.title = [NSString stringWithFormat:@\"%@ [modified]\",\n self.bestAttemptContent.title];\n\n // Call FIRMessaging extension helper API.\n [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent\n withContentHandler:contentHandler];\n\n }\n ...\n\nBuild the send request\n\nIn your notification send request, set the following [ApnsConfig](/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig)\noptions:\n\n- `fcm_options.image` containing the image URL. Apple requires that the image URL includes a valid file extension to correctly identify the resource type.\n- `headers({ \"mutable-content\": 1})`\n\nThe following example send request sends a common notification title to all platforms, but it also sends an image. Here's an approximation of the\nvisual effect on a user's device:\n\nNode.js \n\n const topicName = 'industry-tech';\n\n const message = {\n notification: {\n title: 'Sparky says hello!'\n },\n android: {\n notification: {\n imageUrl: 'https://foo.bar.pizza-monster.png'\n }\n },\n apns: {\n payload: {\n aps: {\n 'mutable-content': 1\n }\n },\n fcm_options: {\n image: 'https://foo.bar.pizza-monster.png'\n }\n },\n webpush: {\n headers: {\n image: 'https://foo.bar.pizza-monster.png'\n }\n },\n topic: topicName,\n };\n\n getMessaging().send(message)\n .then((response) =\u003e {\n // Response is a message ID string.\n console.log('Successfully sent message:', response);\n })\n .catch((error) =\u003e {\n console.log('Error sending message:', error);\n });\n\nREST \n\n POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1\n\n Content-Type: application/json\n Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA\n {\n \"message\":{\n \"topic\":\"industry-tech\",\n \"notification\":{\n \"title\":\"Sparky says hello!\",\n },\n \"android\":{\n \"notification\":{\n \"image\":\"https://foo.bar/pizza-monster.png\"\n }\n },\n \"apns\":{\n \"payload\":{\n \"aps\":{\n \"mutable-content\":1\n }\n },\n \"fcm_options\": {\n \"image\":\"https://foo.bar/pizza-monster.png\"\n }\n },\n \"webpush\":{\n \"headers\":{\n \"image\":\"https://foo.bar/pizza-monster.png\"\n }\n }\n }\n }\n\nSee the\n[HTTP v1 reference documentation](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages)\nfor complete detail on the keys available in platform-specific blocks in the\nmessage body.\n\nWith `mutable-content` set as shown, this send request enables the service\nextension on the receiving client to handle the image delivered in the payload."]]