Uygulamanızın ilk başlatılmasında FCM SDK, istemci uygulaması örneği için bir kayıt jetonu oluşturur. Tek cihazları hedeflemek veya FCM için cihaz grupları oluşturmak istiyorsanız bu jetona erişmeniz gerekir.
İletiler, farklı türlerdeki gelen verileri temsil edebilir. En yaygın olarak, iletiler geliştirici tarafından başlatıldıktan sonra uygulamaya gönderilir. Mesaj gönderme etkinliklerini, mesaj gönderme hatası etkinliklerini ve silinen mesaj etkinliklerini temsil etmek için uygulamanıza da mesajlar gönderilir. Bu özel etkinlikler, Message::message_type alanı kontrol edilerek ayırt edilebilir.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-09-03 UTC."],[],[],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."]]