عند بدء تشغيل تطبيقك لأول مرة، تنشئ حزمة تطوير البرامج (SDK) FCM رمز تسجيل
لنسخة تطبيق العميل. إذا كنت تريد استهداف أجهزة فردية أو إنشاء مجموعات أجهزة لاستخدام FCM، عليك الحصول على رمز الدخول هذا.
يمكن أن تمثّل الرسائل أنواعًا مختلفة من البيانات الواردة. في معظم الحالات، يتم إرسال الرسائل إلى التطبيق بعد أن يبدأها المطوّر. يتم أيضًا إرسال رسائل إلى تطبيقك لتمثيل أحداث الرسائل المرسَلة وأحداث أخطاء إرسال الرسائل وأحداث الرسائل المحذوفة. ويمكن التمييز بين هذه الأحداث الخاصة من خلال التحقّق من الحقل Message::message_type.
تم حذف الرسائل
يتم إرسال هذا الرمز إلى تطبيقك عندما يحذف خادم FCM الرسائل المعلّقة.
سيصبح Message::message_type هو "deleted_messages". قد يتم حذف الرسائل للأسباب التالية:
تم تخزين عدد كبير جدًا من الرسائل على خادم FCM.
يمكن أن يحدث ذلك عندما ترسل خوادم أحد التطبيقات مجموعة من الرسائل غير القابلة للتصغير إلى خوادم FCM أثناء عدم اتصال الجهاز بالإنترنت.
لم يتصل الجهاز بالإنترنت لفترة طويلة، وأرسل خادم التطبيق رسالة إلى التطبيق على هذا الجهاز مؤخرًا (خلال الأسابيع الأربعة الماضية).
ويُنصح التطبيق بإجراء مزامنة كاملة مع خادم التطبيق بعد تلقّي هذا الطلب.
تاريخ التعديل الأخير: 2025-09-03 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-03 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["To receive simple downstream messages, each client app needs to implement the\nmethods on the\n[firebase::messaging::Listener](/docs/reference/cpp/class/firebase/messaging/listener)\nAPI.\n\nInitialize FCM\n\nBefore you can use FCM to get access to your registration token or receive messages it must be initialized.\n\nTo initialize FCM, call\n[::firebase::messaging::Initialize](/docs/reference/cpp/namespace/firebase/messaging#initialize)\nand supply it with your\n[::firebase::App](/docs/reference/cpp/class/firebase/app)\nobject as well as an implementation of the\n[::firebase::messaging::Listener](/docs/reference/cpp/class/firebase/messaging/listener)\nclass. \n\n```c++\nMyListener my_listener_implementation;\n::firebase::messaging::Initialize(app, &my_listener_implementation);\n```\n\nAccess the registration token\n\nOn initial startup of your app, the FCM SDK generates a registration\ntoken for the client app instance. If you want to target single devices, or\ncreate device groups for FCM, you'll need to access this token.\n\nYou can access the token's value through the\n[::firebase::messaging::Listener::OnTokenReceived](/docs/reference/cpp/class/firebase/messaging/listener#ontokenreceived)\nvirtual function. \n\n```c++\nvoid OnTokenReceived(const char* token) {\n LogMessage(\"The registration token is `%s`\", token);\n\n // TODO: If necessary send token to application server.\n}\n```\n\nReceive and handle messages\n\nTo receive messages, your Listener class must implement the\n[OnMessage](/docs/reference/cpp/class/firebase/messaging/listener#onmessage)\nvirtual function.\n\nOverride `OnMessage`\n\nBy overriding the method\n[::firebase::messaging::Listener::OnMessage](/docs/reference/cpp/class/firebase/messaging/listener#onmessage),\nyou can perform actions based on the received message and get the message data: \n\n```c++\nvoid OnMessage(const ::firebase::messaging::Message& message) {\n LogMessage(TAG, \"From: %s\", message.from.c_str());\n LogMessage(TAG, \"Message ID: %s\", message.message_id.c_str());\n}\n```\n\nMessages can represent different kinds of incoming data. Most commonly,\nmessages are sent to the app after being initiated by the developer. Messages\nare also sent to you app to represent message sent events, message send error\nevents, and messages deleted events. These special events can be differentiated\nby checking the `Message::message_type` field.\n\nMessages Deleted\n\nSent to your app when the FCM server deletes pending messages.\n`Message::message_type` will be `\"deleted_messages\"`. Messages may be delete due\nto:\n\n1. Too many messages stored on the FCM server.\n\n This can occur when an app's servers send a bunch of non-collapsible\n messages to FCM servers while the device is offline.\n2. The device hasn't connected in a long time and the app server has\n recently (within the last 4 weeks) sent a message to the app on that\n device.\n\n It is recommended that the app do a full sync with the app\n server after receiving this call."]]