با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
محیط سرور و FCM شما
سمت سرور Firebase Cloud Messaging از دو جزء تشکیل شده است:
پشتیبان FCM ارائه شده توسط Google.
سرور برنامه شما یا سایر محیط های سرور قابل اعتمادی که منطق سرور شما در آن اجرا می شود، مانند Cloud Functions برای Firebase یا سایر محیط های ابری تحت مدیریت Google.
سرور برنامه یا محیط سرور مورد اعتماد شما درخواستهای پیام را به پشتیبان FCM میفرستد، که سپس پیامها را به برنامههای مشتری در حال اجرا در دستگاههای کاربران هدایت میکند.
الزامات برای محیط سرور قابل اعتماد
محیط سرور برنامه شما باید معیارهای زیر را داشته باشد:
قادر به ارسال درخواست های پیام با فرمت مناسب به باطن FCM .
قادر به رسیدگی به درخواست ها و ارسال مجدد آنها با استفاده از پشتوانه نمایی.
قادر به ذخیره ایمن اعتبار مجوز سرور و نشانه های ثبت مشتری.
انتخاب گزینه سرور
شما باید در مورد راهی برای تعامل با سرورهای FCM تصمیم بگیرید: یا با استفاده از Firebase Admin SDK یا پروتکل خام. Firebase Admin SDK به دلیل پشتیبانی از زبانهای برنامهنویسی محبوب و روشهای راحت آن برای مدیریت احراز هویت و مجوز، روش پیشنهادی است.
گزینه های تعامل با سرورهای FCM شامل موارد زیر است:
Firebase Admin SDK که از Node ، Java ، Python ، C# و Go پشتیبانی می کند.
FCMAPI FCM HTTP v1 را برای توسعه دهندگانی که پروتکل سرور خام را ترجیح می دهند ارائه می دهد.
برای ارسال پیام، سرور برنامه یک درخواست POST با یک سربرگ HTTP و یک بدنه HTTP متشکل از جفتهای مقدار کلید JSON صادر میکند. برای جزئیات بیشتر در مورد گزینههای سرصفحه و بدنه، به ساخت درخواستهای ارسال سرور برنامه مراجعه کنید
تاریخ آخرین بهروزرسانی 2025-08-15 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-15 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\nYour server environment and FCM\n\nThe server side of Firebase Cloud Messaging consists of two components:\n\n- The **FCM backend** provided by Google.\n- Your **app server** or other **trusted server environment** where your server logic runs, such as [Cloud Functions for Firebase](/docs/functions) or other cloud environments managed by Google.\n\n\u003cbr /\u003e\n\nYour app server or trusted server environment sends message requests to the FCM\nbackend, which then routes messages to client apps running on users' devices.\n\nRequirements for the trusted server environment\n\nYour app server environment must meet the following criteria:\n\n- Able to send properly formatted message requests to the FCM backend.\n- Able to handle requests and resend them using [exponential back-off.](https://developers.google.com/api-client-library/java/google-http-java-client/backoff)\n- Able to securely store server authorization credentials and client registration tokens.\n\nChoosing a server option\n\nYou'll need to decide on a way to interact with FCM servers: either using the\n[Firebase Admin SDK](/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm) or the raw protocol.\nBecause of its support across popular programming languages and its convenience methods for\nhandling authentication and authorization, the Firebase Admin SDK is the recommended method.\n\nOptions for interacting with FCM servers include the following:\n\n- The Firebase Admin SDK, which has support for [Node](/docs/reference/admin/node/firebase-admin.messaging), [Java](/docs/reference/admin/java/reference/com/google/firebase/messaging/package-summary), [Python](/docs/reference/admin/python/firebase_admin.messaging), [C#](/docs/reference/admin/dotnet/namespace/firebase-admin/messaging), and [Go](//godoc.org/firebase.google.com/go/messaging).\n- The [FCM HTTP v1 API](/docs/reference/fcm/rest/v1/projects.messages), a REST API with secure authorization and flexible [cross-platform messaging capabilities](/docs/cloud-messaging/send-message#customize_messages_across_platforms) (the Firebase Admin SDK is based on this protocol and provides all of its inherent advantages).\n\nFirebase Admin SDK for FCM\n\nThe Admin FCM API handles authenticating with the backend and facilitates sending\nmessages and managing topic subscriptions. With the Firebase Admin SDK, you can:\n\n- Send messages to individual devices\n- Send messages to topics and condition statements that match one or more topics.\n- Subscribe and unsubscribe devices to and from topics\n- Construct message payloads tailored to different target platforms\n\nThe Admin Node.js SDK provides\nmethods for sending messages to device groups.\n\nTo set up the Firebase Admin SDK, see [Add the\nFirebase Admin SDK to Your Server](/docs/admin/setup). If you already have a Firebase project,\nstart with [Add the SDK](/docs/admin/setup#add-sdk). Also, make sure to enable the\nCloud Messaging API in the\n[Cloud Messaging settings page](//console.firebase.google.com/project/_/settings/cloudmessaging/)\nfor your project. Then, once the Firebase Admin SDK is installed, you can start writing logic to\n[build send requests](/docs/cloud-messaging/send-message).\n| The Firebase Admin SDK provides an API for subscribing and unsubscribing devices to and from FCM topics. These operations can subscribe or unsubscribe up to 1000 device registration tokens at a time. For more information, see [Manage topics from the server](/docs/cloud-messaging/manage-topics).\n\nFCM server protocol\n\nFCM provides the [FCM HTTP v1 API](/docs/reference/fcm/rest/v1/projects.messages) for developers who prefer a raw server protocol.\n\nTo send a message, the app server issues a POST request with\nan HTTP header and an HTTP body comprised of JSON key value pairs.\nFor details on the header and body options, see\n[Build App Server Send Requests](/docs/cloud-messaging/send-message)"]]