संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
पब्लिश/सब्सक्राइब मॉडल पर आधारित, FCM की विषय के हिसाब से मैसेज भेजने की सुविधा का इस्तेमाल करके, उन सभी डिवाइसों पर एक मैसेज भेजा जा सकता है जिन्होंने किसी विषय के लिए ऑप्ट-इन किया है. विषय के हिसाब से मैसेज लिखने की सुविधा उपलब्ध होती है. साथ ही, FCM मैसेज को सही डिवाइसों तक पहुंचाने और उन्हें डिलीवर करने का काम करता है.
उदाहरण के लिए, ज्वार-भाटे का पूर्वानुमान लगाने वाले किसी स्थानीय ऐप्लिकेशन के उपयोगकर्ता, "ज्वारीय धाराओं की सूचनाएं" विषय के लिए ऑप्ट-इन कर सकते हैं. इसके बाद, उन्हें तय किए गए इलाकों में खारे पानी में मछली पकड़ने के लिए सबसे सही स्थितियों की सूचनाएं मिलेंगी. खेल-कूद से जुड़े किसी ऐप्लिकेशन के उपयोगकर्ता, अपनी पसंदीदा टीमों के लाइव गेम के स्कोर के अपने-आप अपडेट पाने के लिए सदस्यता ले सकते हैं.
विषयों के बारे में इन बातों का ध्यान रखें:
विषय के हिसाब से मैसेज भेजने की सुविधा, मौसम या सार्वजनिक तौर पर उपलब्ध अन्य जानकारी जैसे कॉन्टेंट के लिए सबसे सही है.
विषय के हिसाब से मैसेज, लेटेंसी के बजाय थ्रूपुट के लिए ऑप्टिमाइज़ किए जाते हैं. किसी एक डिवाइस या डिवाइसों के छोटे ग्रुप को तेज़ी से और सुरक्षित तरीके से मैसेज डिलीवर करने के लिए, मैसेज को रजिस्ट्रेशन टोकन के हिसाब से टारगेट करें, न कि विषयों के हिसाब से.
अगर आपको हर उपयोगकर्ता के लिए, एक से ज़्यादा डिवाइसों पर मैसेज भेजने हैं, तो इस्तेमाल के उन मामलों के लिए डिवाइस ग्रुप मैसेजिंग का इस्तेमाल करें.
विषय के हिसाब से मैसेज भेजने की सुविधा, हर विषय के लिए असीमित सदस्यताओं के साथ काम करती है. हालांकि, FCM इन मामलों में सीमाएं लागू करता है:
किसी ऐप्लिकेशन के एक इंस्टेंस को ज़्यादा से ज़्यादा 2,000 विषयों के लिए सदस्यता ली जा सकती है.
अगर ऐप्लिकेशन इंस्टेंस की सदस्यता लेने के लिए, एक साथ कई इंस्टेंस इंपोर्ट करने की सुविधा का इस्तेमाल किया जा रहा है, तो हर अनुरोध में ज़्यादा से ज़्यादा 1,000 ऐप्लिकेशन इंस्टेंस शामिल किए जा सकते हैं.
हर प्रोजेक्ट के लिए, नई सदस्यताओं की संख्या सीमित होती है. अगर कम समय में सदस्यता के लिए बहुत ज़्यादा अनुरोध भेजे जाते हैं, तो FCM सर्वर 429 RESOURCE_EXHAUSTED ("कोटा खत्म हो गया") वाला जवाब देंगे. एक्स्पोनेंशियल बैकऑफ़ के साथ फिर से कोशिश करें.
क्लाइंट ऐप्लिकेशन को किसी विषय की सदस्यता लेना
क्लाइंट ऐप्लिकेशन, किसी भी मौजूदा विषय की सदस्यता ले सकते हैं या वे कोई नया विषय बना सकते हैं. जब कोई क्लाइंट ऐप्लिकेशन, किसी नए विषय के नाम की सदस्यता लेता है (ऐसा नाम जो आपके Firebase प्रोजेक्ट के लिए पहले से मौजूद नहीं है), तो FCM में उस नाम का एक नया विषय बन जाता है. इसके बाद, कोई भी क्लाइंट उसकी सदस्यता ले सकता है.
किसी विषय की सदस्यता लेने के लिए, विषय का नाम लेकर subscribeToTopic() को कॉल करें. यह तरीका, Future दिखाता है. सदस्यता लेने की प्रोसेस पूरी होने पर, यह Future रिज़ॉल्व हो जाता है:
सदस्यता छोड़ने के लिए, विषय के नाम के साथ unsubscribeFromTopic() पर कॉल करें.
subscribeToTopic() और unsubscribeFromTopic(), वेब क्लाइंट के लिए उपलब्ध नहीं हैं. वेब उपयोगकर्ताओं के लिए सदस्यताएं मैनेज करने का तरीका जानने के लिए, वेब/JavaScript पर विषयों को मैसेज भेजना लेख पढ़ें.
[[["समझने में आसान है","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,["\u003cbr /\u003e\n\nBased on the publish/subscribe model, FCM topic messaging allows you to send a message\nto multiple devices that have opted in to a particular topic. You compose topic messages as\nneeded, and FCM handles routing and delivering the message reliably to the right\ndevices.\n\nFor example, users of a local tide\nforecasting app could opt in to a \"tidal currents alerts\" topic and receive\nnotifications of optimal saltwater fishing conditions in specified areas. Users of a sports app\ncould subscribe to automatic updates in live game scores for their favorite\nteams.\n\nSome things to keep in mind about topics:\n\n- Topic messaging is best suited for content such as weather, or other publicly\n available information.\n\n- Topic messages are **optimized for throughput rather than latency** . For fast,\n secure delivery to single devices or small groups of devices,\n [target messages to registration tokens](/docs/cloud-messaging/send-message#send_messages_to_specific_devices),\n not topics.\n\n- If you need to send messages to multiple devices *per user* , consider\n [device group messaging](/docs/cloud-messaging/send-message#send_messages_to_device_groups)\n for those use cases.\n\n- Topic messaging supports unlimited subscriptions for each topic. However, FCM\n enforces limits in these areas:\n\n - One app instance can be subscribed to no more than 2000 topics.\n - If you are using [batch import](https://developers.google.com/instance-id/reference/server#manage_relationship_maps_for_multiple_app_instances) to subscribe app instances, each request is limited to 1000 app instances.\n - The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a `429 RESOURCE_EXHAUSTED` (\"quota exceeded\") response. Retry with exponential backoff.\n\nSubscribe the client app to a topic\n\nClient apps can subscribe to any existing topic, or they can create a new\ntopic. When a client app subscribes to a new topic name (one that does\nnot already exist for your Firebase project), a new topic of that name is\ncreated in FCM and any client can subsequently subscribe to it.\n\nTo subscribe to a topic, call `subscribeToTopic()` with the topic name. This method\nreturns a `Future`, which resolves when the subscription succeeded: \n\n await FirebaseMessaging.instance.subscribeToTopic(\"topic\");\n\nTo unsubscribe, call `unsubscribeFromTopic()` with the topic name.\n\n`subscribeToTopic()` and `unsubscribeFromTopic()` are not supported for web\nclients. To learn how to manage subscriptions for web users, see\n[Send messages to topics on Web/JavaScript](https://firebase.google.com/docs/cloud-messaging/js/topic-messaging).\n\nNext steps\n\n- Learn how to [send topic messages](/docs/cloud-messaging/send-message#send-messages-to-topics).\n- Learn how to [Manage topic subscriptions on the server](/docs/cloud-messaging/manage-topics)."]]