আপনি আপনার অ্যাপের প্যারামিটারগুলি সংজ্ঞায়িত করতে এবং ক্লাউডে তাদের মানগুলি আপডেট করতে Firebase রিমোট কনফিগারেশন ব্যবহার করতে পারেন, যাতে আপনি কোনও অ্যাপ আপডেট বিতরণ না করেই আপনার অ্যাপের চেহারা এবং আচরণ পরিবর্তন করতে পারেন।
রিমোট কনফিগ লাইব্রেরি অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মানগুলি সঞ্চয় করতে, রিমোট কনফিগার ব্যাকএন্ড থেকে আপডেট করা প্যারামিটার মানগুলি আনতে এবং আপনার অ্যাপে যখন আনা মানগুলি উপলব্ধ করা হয় তখন নিয়ন্ত্রণ করতে ব্যবহৃত হয়৷ আরও জানতে, দূরবর্তী কনফিগার লোডিং কৌশল দেখুন।
ধাপ 1: আপনার অ্যাপে Firebase যোগ করুন
আপনি Remote Config ব্যবহার করার আগে, আপনাকে করতে হবে:
আপনার C++ প্রজেক্ট নিবন্ধন করুন এবং Firebase ব্যবহার করতে কনফিগার করুন।
যদি আপনার C++ প্রোজেক্ট ইতিমধ্যেই Firebase ব্যবহার করে, তাহলে এটি ইতিমধ্যেই Firebase-এর জন্য নিবন্ধিত এবং কনফিগার করা আছে।
আপনার C++ প্রকল্পে Firebase C++ SDK যোগ করুন।
মনে রাখবেন যে আপনার C++ প্রজেক্টে Firebase যোগ করার জন্য Firebase কনসোল এবং আপনার খোলা C++ প্রজেক্টের উভয় কাজ জড়িত থাকে (উদাহরণস্বরূপ, আপনি কনসোল থেকে Firebase কনফিগার ফাইলগুলি ডাউনলোড করেন, তারপর সেগুলিকে আপনার C++ প্রকল্পে নিয়ে যান)।
ধাপ 2: আপনার অ্যাপে রিমোট কনফিগ যোগ করুন
অ্যান্ড্রয়েড
আপনি আপনার অ্যাপে Firebase যোগ করার পর:
একটি ফায়ারবেস অ্যাপ তৈরি করুন, JNI পরিবেশ এবং কার্যকলাপে পাস করে:
app = ::firebase::App::Create(::firebase::AppOptions(), jni_env, activity);
রিমোট কনফিগারেশন লাইব্রেরি শুরু করুন, যেমন দেখানো হয়েছে:
::firebase::remote_config::Initialize(app);
iOS+
আপনি আপনার অ্যাপে Firebase যোগ করার পর:
একটি ফায়ারবেস অ্যাপ তৈরি করুন:
app = ::firebase::App::Create(::firebase::AppOptions());
রিমোট কনফিগ লাইব্রেরি শুরু করুন, যেমন দেখানো হয়েছে:
::firebase::remote_config::Initialize(app);
ধাপ 3: অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সেট করুন
আপনি রিমোট কনফিগারেশন অবজেক্টে অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সেট করতে পারেন, যাতে আপনার অ্যাপটি রিমোট কনফিগার ব্যাকএন্ডের সাথে সংযোগ করার আগে উদ্দেশ্য অনুযায়ী আচরণ করে এবং ব্যাকএন্ডে কোনোটি সেট না থাকলে ডিফল্ট মানগুলি উপলব্ধ থাকে।
একটি
std::map<const char*, const char*>
অবজেক্ট বা একটিstd::map<const char*, firebase::Variant>
অবজেক্ট ব্যবহার করে প্যারামিটার নামের একটি সেট এবং ডিফল্ট প্যারামিটার মান নির্ধারণ করুন।আপনি যদি ইতিমধ্যেই রিমোট কনফিগ ব্যাকএন্ড প্যারামিটার মানগুলি কনফিগার করে থাকেন, তাহলে আপনি একটি ফাইল ডাউনলোড করতে পারেন যাতে এই কী/মান জোড়া রয়েছে এবং এটি আপনার
map
অবজেক্ট তৈরি করতে ব্যবহার করতে পারেন। আরও তথ্যের জন্য, দূরবর্তী কনফিগার টেমপ্লেট ডিফল্ট ডাউনলোড দেখুন।SetDefaults()
ব্যবহার করে রিমোট কনফিগারেশন অবজেক্টে এই মানগুলি যোগ করুন।
ধাপ 4: আপনার অ্যাপে ব্যবহার করার জন্য প্যারামিটার মান পান
এখন আপনি দূরবর্তী কনফিগার অবজেক্ট থেকে প্যারামিটার মান পেতে পারেন। আপনি যদি রিমোট কনফিগার ব্যাকএন্ডে মান সেট করেন, সেগুলি আনেন এবং তারপরে সেগুলি সক্রিয় করেন, সেই মানগুলি আপনার অ্যাপে উপলব্ধ। অন্যথায়, আপনি SetDefaults()
ব্যবহার করে কনফিগার করা অ্যাপ-মধ্যস্থ প্যারামিটার মানগুলি পাবেন।
এই মানগুলি পেতে, নীচে তালিকাভুক্ত পদ্ধতিতে কল করুন যা আপনার অ্যাপের দ্বারা প্রত্যাশিত ডেটা টাইপের সাথে মানচিত্র করে, একটি যুক্তি হিসাবে প্যারামিটার কী প্রদান করে:
ধাপ 5: Firebase কনসোলে আপনার অ্যাপ কানেক্ট করুন
Firebase কনসোলে , আপনার Firebase প্রকল্পে আপনার অ্যাপ যোগ করুন।
ধাপ 6: প্যারামিটার মান সেট করুন
- Firebase কনসোলে , আপনার প্রকল্প খুলুন।
- রিমোট কনফিগার ড্যাশবোর্ড দেখতে মেনু থেকে রিমোট কনফিগ নির্বাচন করুন।
- আপনি আপনার অ্যাপে যে প্যারামিটারগুলি সংজ্ঞায়িত করেছেন তার মতো একই নামের প্যারামিটারগুলিকে সংজ্ঞায়িত করুন৷ 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 7: 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 8: 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.
পরবর্তী পদক্ষেপ
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: