संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Firebase Remote Config इवेंट के जवाब में, फ़ंक्शन को ट्रिगर किया जा सकता है. इनमें कॉन्फ़िगरेशन के नए वर्शन का पब्लिश होना या पुराने वर्शन पर वापस लौटना शामिल है.
इस गाइड में, Remote Config बैकग्राउंड फ़ंक्शन बनाने का तरीका बताया गया है. यह फ़ंक्शन, टेंप्लेट के दो वर्शन के बीच अंतर करता है.
रिमोट कॉन्फ़िगरेशन फ़ंक्शन को ट्रिगर करना
Remote Config इवेंट के लिए हैंडलर तय करने के लिए, functions.remoteConfig मॉड्यूल के onUpdate() फ़ंक्शन का इस्तेमाल करें.
TemplateVersion से मिले TemplateVersion ऑब्जेक्ट में, टेंप्लेट अपडेट के लिए मुख्य मेटाडेटा फ़ील्ड होते हैं. जैसे, वर्शन नंबर और अपडेट का समय.onUpdate
अपडेट करने वाले उपयोगकर्ता का ईमेल भी वापस पाया जा सकता है. साथ ही, उसका नाम और अगर उपलब्ध हो, तो इमेज भी वापस पाई जा सकती है.
यहां Remote Config फ़ंक्शन का एक उदाहरण दिया गया है. यह फ़ंक्शन, अपडेट किए गए हर वर्शन और उसकी जगह इस्तेमाल किए गए वर्शन के बीच का अंतर दिखाता है. यह फ़ंक्शन, टेंप्लेट ऑब्जेक्ट के versionNumber फ़ील्ड की जांच करता है. साथ ही, यह मौजूदा (हाल ही में अपडेट किया गया) वर्शन और उससे एक वर्शन पहले का नंबर वापस लाता है:
इस सैंपल में, json-diff और request-promise मॉड्यूल का इस्तेमाल किया गया है. इससे अंतर का पता लगाया जा सकता है और टेंप्लेट ऑब्जेक्ट पाने के लिए अनुरोध बनाया जा सकता है. Remote Config क्लाइंट लॉजिक और Firebase Cloud Messaging को शामिल करने वाले सैंपल के लिए, रीयल टाइम में रिमोट कॉन्फ़िगरेशन के अपडेट लागू करना लेख पढ़ें.
[[["समझने में आसान है","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-09 (UTC) को अपडेट किया गया."],[],[],null,["\u003cbr /\u003e\n\nYou can trigger a function in response to\n[Firebase Remote Config](/docs/remote-config) events, including\nthe publication of a new config version or the rollback to an older version.\nThis guide describes how to create a Remote Config background function\nthat performs a diff of two template versions.\n\nTrigger a Remote Config function\n\nTo define a handler for Remote Config events, use the\n[`functions.remoteConfig`](/docs/reference/functions/firebase-functions.remoteconfig)\nmodule's `onUpdate()` function.\nThe `TemplateVersion` object returned by\n`onUpdate` contains the key metadata\nfields for a template update such as the version number and time of the update.\nYou can also retrieve the email for the user who made the update, with name\nand an image if available.\n\nHere's an example of a Remote Config function that\nreturns a diff of each updated version and the version it replaced. The function\nexamines the `versionNumber` field of the template object and retrieves the\ncurrent (newly updated) version together with the version one number lower: \n\n```gdscript\nexports.showConfigDiff = functions.remoteConfig.onUpdate(versionMetadata =\u003e {\n return admin.credential.applicationDefault().getAccessToken()\n .then(accessTokenObj =\u003e {\n return accessTokenObj.access_token;\n })\n .then(accessToken =\u003e {\n const currentVersion = versionMetadata.versionNumber;\n const templatePromises = [];\n templatePromises.push(getTemplate(currentVersion, accessToken));\n templatePromises.push(getTemplate(currentVersion - 1, accessToken));\n\n return Promise.all(templatePromises);\n })\n .then(results =\u003e {\n const currentTemplate = results[0];\n const previousTemplate = results[1];\n\n const diff = jsonDiff.diffString(previousTemplate, currentTemplate);\n\n functions.logger.log(diff);\n\n return null;\n }).catch(error =\u003e {\n functions.logger.error(error);\n return null;\n });\n});https://github.com/firebase/functions-samples/blob/c4fde45b65fab584715e786ce3264a6932d996ec/Node-1st-gen/remote-config-diff/functions/index.js#L25-L51\n```\n\nThis sample uses the [`json-diff`](https://www.npmjs.com/package/json-diff) and\n[`request-promise`](https://www.npmjs.com/package/request-promise) modules to\ncreate the diff and build the request to get the template object. For a sample\nthat incorporates Remote Config client logic as well as Firebase Cloud Messaging,\nsee [Propagate Remote Config updates in real time](/docs/remote-config/propagate-updates-realtime)."]]