تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح واجهة برمجة التطبيقات FCM HTTP v1 وأداة إنشاء الإشعارات إرسال روابط صور في حمولة إشعار العرض، وذلك لتنزيل الصورة على الجهاز بعد تسليمها.
تتيح هذه الوظيفة استخدام الصور والفيديوهات لتطبيقات Apple (راجِع مستندات Apple للتعرّف على الحدود القصوى لحجم الملف).
لتلقّي صور الإشعارات والتعامل معها في تطبيق Apple، يجب إضافة إضافة خدمة الإشعارات.
يتيح إضافة خدمة الإشعارات لتطبيقك معالجة الصورة
المضمّنة في حمولة FCM قبل عرض الإشعار للمستخدم النهائي.
إعداد إضافة خدمة الإشعارات
لإضافة إضافة خدمة، عليك تنفيذ مهام الإعداد المطلوبة من أجل
تعديل الإشعارات وعرضها
في APNs، ثم إضافة واجهة برمجة التطبيقات المساعدة الخاصة بإضافة FCM في NotificationService.m.
على وجه التحديد، بدلاً من إكمال عملية رد الاتصال باستخدام 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 الذي يحتوي على عنوان 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);});
راجِع المستند المرجعي لإصدار HTTP 1 للحصول على التفاصيل الكاملة حول المفاتيح المتاحة في الأقسام الخاصة بالمنصة في نص الرسالة.
عند ضبط mutable-content على النحو الموضّح، يتيح طلب الإرسال هذا لبرنامج الخدمة المساعد على جهاز العميل المستلِم معالجة الصورة التي تم تسليمها في الحمولة.
تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]