আপনি আপনার অ্যাপে প্যারামিটারগুলি সংজ্ঞায়িত করতে এবং ক্লাউডে তাদের মান আপডেট করতে Firebase Remote Config ব্যবহার করতে পারেন, যার ফলে আপনি অ্যাপ আপডেট বিতরণ না করেই আপনার অ্যাপের চেহারা এবং আচরণ পরিবর্তন করতে পারবেন।
Remote Config লাইব্রেরিটি অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সংরক্ষণ করতে, Remote Config ব্যাকএন্ড থেকে আপডেট করা প্যারামিটার মান আনতে এবং আপনার অ্যাপে কখন আনা মানগুলি উপলব্ধ করা হবে তা নিয়ন্ত্রণ করতে ব্যবহৃত হয়। আরও জানতে, রিমোট কনফিগ লোডিং কৌশলগুলি দেখুন।
ধাপ ১: আপনার অ্যাপে Firebase যোগ করুন
Remote Config ব্যবহার করার আগে, আপনাকে যা করতে হবে:
আপনার C++ প্রকল্পটি নিবন্ধন করুন এবং Firebase ব্যবহারের জন্য এটি কনফিগার করুন।
যদি আপনার C++ প্রকল্পটি ইতিমধ্যেই Firebase ব্যবহার করে, তাহলে এটি ইতিমধ্যেই Firebase-এর জন্য নিবন্ধিত এবং কনফিগার করা আছে।
আপনার C++ প্রজেক্টে Firebase C++ SDK যোগ করুন।
মনে রাখবেন যে আপনার C++ প্রজেক্টে Firebase যোগ করার ক্ষেত্রে Firebase কনসোল এবং আপনার খোলা C++ প্রজেক্ট উভয় ক্ষেত্রেই কাজ জড়িত (উদাহরণস্বরূপ, আপনি কনসোল থেকে Firebase কনফিগারেশন ফাইল ডাউনলোড করেন, তারপর সেগুলিকে আপনার C++ প্রজেক্টে স্থানান্তর করেন)।
ধাপ ২: আপনার অ্যাপে Remote Config যোগ করুন
অ্যান্ড্রয়েড
আপনার অ্যাপে Firebase যোগ করার পরে:
JNI পরিবেশ এবং কার্যকলাপের মধ্যে একটি ফায়ারবেস অ্যাপ তৈরি করুন:
app = ::firebase::App::Create(::firebase::AppOptions(), jni_env, activity);
Remote Config লাইব্রেরিটি আরম্ভ করুন, যেমনটি দেখানো হয়েছে:
::firebase::remote_config::Initialize(app);
আইওএস+
আপনার অ্যাপে Firebase যোগ করার পরে:
একটি ফায়ারবেস অ্যাপ তৈরি করুন:
app = ::firebase::App::Create(::firebase::AppOptions());
Remote Config লাইব্রেরিটি আরম্ভ করুন, যেমনটি দেখানো হয়েছে:
::firebase::remote_config::Initialize(app);
ধাপ ৩: অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সেট করুন
আপনি Remote Config অবজেক্টে ইন-অ্যাপ ডিফল্ট প্যারামিটার মান সেট করতে পারেন, যাতে আপনার অ্যাপটি Remote Config ব্যাকএন্ডের সাথে সংযোগ স্থাপনের আগে যেমনটি ইচ্ছা তেমন আচরণ করে এবং ব্যাকএন্ডে কোনওটি সেট না করা থাকলে ডিফল্ট মানগুলি উপলব্ধ থাকে।
অ্যারের আকার সহ একটি
ConfigKeyValue*
অবজেক্ট বা একটিConfigKeyValueVariant*
অবজেক্ট ব্যবহার করে প্যারামিটার নামের একটি সেট এবং ডিফল্ট প্যারামিটার মান নির্ধারণ করুন।If you have already configured Remote Config backend parameter values, you can download a file that contains these key/value pairs and use it to construct your
map
object. For more information, see Download Remote Config template defaults .Add these values to the Remote Config object using
SetDefaults()
.
Step 4: Get parameter values to use in your app
Now you can get parameter values from the Remote Config object. If you set values in the Remote Config backend, fetched them, and then activated them, those values are available to your app. Otherwise, you get the in-app parameter values configured using SetDefaults()
.
To get these values, call the method listed below that maps to the data type expected by your app, providing the parameter key as an argument:
Step 5: Set parameter values
- In the Firebase console , open your project.
- Select Remote Config from the menu to view the Remote Config dashboard.
- Define parameters with the same names as the parameters that you defined in your app. For each parameter, you can set a default value (which will eventually override the in-app default value) and conditional values. To learn more, see Remote Config parameters and conditions .
Step 6: Fetch and activate values
- To fetch parameter values from the Remote Config backend, call the
Fetch()
method. Any values that you set on the backend are fetched and cached in the Remote Config object. - To make fetched parameter values available to your app, call the
ActivateFetched()
Step 7: Listen for updates in real time
After you fetch parameter values, you can use real-time Remote Config to listen for updates from the Remote Config backend. Real-time Remote Config signals to connected devices when updates are available and automatically fetches the changes after you publish a new Remote Config version.
Real-time updates are supported by the Firebase C++ SDK v11.0.0+ and higher for Android and Apple platforms.
- In your app, call
AddOnConfigUpdateListener
to start listening for updates and automatically fetch any new or updated parameter values. The following example listens for updates and, whenActivate
is called, uses the newly fetched values to display an updated welcome message.
remote_config->AddOnConfigUpdateListener( [](firebase::remote_config::ConfigUpdate&& config_update, firebase::remote_config::RemoteConfigError remote_config_error) { if (remote_config_error != firebase::remote_config::kRemoteConfigErrorNone) { printf("Error listening for config updates: %d", remote_config_error); } // Search the `updated_keys` set for the key "welcome_message." // `updated_keys` represents the keys that have changed since the last // fetch. if (std::find(config_update.updated_keys.begin(), config_update.updated_keys.end(), "welcome_message") != config_update.updated_keys.end()) { remote_config->Activate().OnCompletion( [&](const firebase::Future& completed_future, void* user_data) { // The key "welcome_message" was found within `updated_keys` and // can be activated. if (completed_future.error() == 0) { DisplayWelcomeMessage(); } else { printf("Error activating config: %d", completed_future.error()); } }, nullptr); } });
The next time you publish a new version of your Remote Config , devices that are running your app and listening for changes will call the config update listener.
Next steps
If you haven't already, explore the Remote Config use cases , and take a look at some of the key concepts and advanced strategies documentation, including: