संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
FCM HTTP v1 API और सूचना कंपोज़र, दोनों ही डिलीवरी के बाद डिवाइस पर इमेज डाउनलोड करने के लिए, डिसप्ले नोटिफ़िकेशन के पेलोड में इमेज के लिंक भेजने की सुविधा देते हैं.
यह सुविधा, Apple के ऐप्लिकेशन के लिए इमेज और वीडियो, दोनों के साथ काम करती है. फ़ाइल के साइज़ की सीमाएं जानने के लिए, Apple का दस्तावेज़ देखें.
Apple के किसी ऐप्लिकेशन में सूचना वाली इमेज पाने और उन्हें मैनेज करने के लिए, आपको Notification Service Extension जोड़ना होगा.
सूचना सेवा एक्सटेंशन की मदद से, आपका ऐप्लिकेशन, असली उपयोगकर्ता को सूचना दिखाने से पहले, FCM पेलोड में डिलीवर की गई इमेज को मैनेज कर सकता है.
सूचना सेवा एक्सटेंशन सेट अप करना
सेवा एक्सटेंशन जोड़ने के लिए, APNs में सूचनाओं में बदलाव करने और उन्हें दिखाने से जुड़े ज़रूरी सेटअप टास्क पूरे करें. इसके बाद, NotificationService.m में FCM एक्सटेंशन हेल्पर एपीआई जोड़ें.
खास तौर पर, कॉलबैक को 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];}...
अनुरोध भेजने की सुविधा बनाना
सूचना भेजने के अनुरोध में, ApnsConfig के ये विकल्प सेट करें:
fcm_options.image में इमेज का यूआरएल शामिल होना चाहिए. Apple के मुताबिक, इमेज के यूआरएल में मान्य फ़ाइल एक्सटेंशन शामिल होना चाहिए, ताकि संसाधन के टाइप की सही पहचान की जा सके.
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);});
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-09-05 (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."]]