Firebase is back at Google I/O on May 10! Register now

Firebase রিমোট কনফিগারেশন দিয়ে শুরু করুন

সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।


আপনি আপনার অ্যাপের প্যারামিটারগুলি সংজ্ঞায়িত করতে এবং ক্লাউডে তাদের মানগুলি আপডেট করতে Firebase রিমোট কনফিগারেশন ব্যবহার করতে পারেন, যাতে আপনি কোনও অ্যাপ আপডেট বিতরণ না করেই আপনার অ্যাপের চেহারা এবং আচরণ পরিবর্তন করতে পারেন। এই নির্দেশিকাটি আপনাকে শুরু করার ধাপগুলির মধ্যে দিয়ে চলে এবং কিছু নমুনা কোড প্রদান করে, যার সবকটিই Firebase/quickstart-ios GitHub সংগ্রহস্থল থেকে ক্লোন বা ডাউনলোড করার জন্য উপলব্ধ।

ধাপ 1: আপনার অ্যাপে রিমোট কনফিগ যোগ করুন

  1. Apple প্ল্যাটফর্মের জন্য Firebase SDK ইনস্টল করুন

  2. সিঙ্গলটন রিমোট কনফিগার অবজেক্ট তৈরি করুন, যেমনটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে:

    সুইফট

    remoteConfig = RemoteConfig.remoteConfig()
    let settings = RemoteConfigSettings()
    settings.minimumFetchInterval = 0
    remoteConfig.configSettings = settings

    উদ্দেশ্য গ

    self.remoteConfig = [FIRRemoteConfig remoteConfig];
    FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] init];
    remoteConfigSettings.minimumFetchInterval = 0;
    self.remoteConfig.configSettings = remoteConfigSettings;

এই অবজেক্টটি অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সংরক্ষণ করতে, রিমোট কনফিগার ব্যাকএন্ড থেকে আপডেট করা প্যারামিটার মানগুলি আনতে এবং আপনার অ্যাপে যখন আনা মানগুলি উপলব্ধ করা হয় তখন নিয়ন্ত্রণ করতে ব্যবহৃত হয়।

বিকাশের সময়, এটি একটি অপেক্ষাকৃত কম ন্যূনতম আনার ব্যবধান সেট করার পরামর্শ দেওয়া হয়। আরও তথ্যের জন্য থ্রটলিং দেখুন।

ধাপ 2: অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সেট করুন

আপনি রিমোট কনফিগ অবজেক্টে অ্যাপ-মধ্যস্থ ডিফল্ট প্যারামিটার মান সেট করতে পারেন, যাতে আপনার অ্যাপটি রিমোট কনফিগ ব্যাকএন্ডের সাথে সংযোগ করার আগে উদ্দেশ্য অনুযায়ী আচরণ করে এবং যাতে ব্যাকএন্ডে কোনোটি সেট না থাকলে ডিফল্ট মান উপলব্ধ থাকে।

  1. একটি NSDictionary অবজেক্ট বা একটি plist ফাইল ব্যবহার করে প্যারামিটার নামের একটি সেট এবং ডিফল্ট প্যারামিটার মান নির্ধারণ করুন।

    আপনি যদি ইতিমধ্যে রিমোট কনফিগার ব্যাকএন্ড প্যারামিটার মানগুলি কনফিগার করে থাকেন তবে আপনি একটি জেনারেট করা plist ফাইল ডাউনলোড করতে পারেন যাতে সমস্ত ডিফল্ট মান রয়েছে এবং এটি আপনার Xcode প্রকল্পে সংরক্ষণ করতে পারেন।

    বিশ্রাম

    curl --compressed -D headers -H "Authorization: Bearer token -X GET https://firebaseremoteconfig.googleapis.com/v1/projects/my-project-id/remoteConfig:downloadDefaults?format=PLIST -o RemoteConfigDefaults.plist
    

    ফায়ারবেস কনসোল

    1. প্যারামিটার ট্যাবে, মেনু খুলুন এবং ডিফল্ট মান ডাউনলোড করুন নির্বাচন করুন।

    2. যখন অনুরোধ করা হয়, iOS এর জন্য .plist সক্ষম করুন, তারপর ফাইল ডাউনলোড করুন ক্লিক করুন।

  2. setDefaults: নিম্নলিখিত উদাহরণটি একটি plist ফাইল থেকে অ্যাপ-মধ্যস্থ ডিফল্ট মান সেট করে:

    সুইফট

    remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")

    উদ্দেশ্য গ

    [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"];

ধাপ 3: আপনার অ্যাপে ব্যবহার করার জন্য প্যারামিটার মান পান

এখন আপনি দূরবর্তী কনফিগার অবজেক্ট থেকে প্যারামিটার মান পেতে পারেন। আপনি যদি পরে রিমোট কনফিগ ব্যাকএন্ডে মানগুলি সেট করেন, সেগুলি আনুন এবং তারপরে সেগুলি সক্রিয় করুন, সেই মানগুলি আপনার অ্যাপে উপলব্ধ। অন্যথায়, আপনি setDefaults: এই মানগুলি পেতে, configValueForKey: পদ্ধতিতে কল করুন, একটি যুক্তি হিসাবে প্যারামিটার কী প্রদান করে।

ধাপ 4: প্যারামিটার মান সেট করুন

Using the Firebase console or the Remote Config backend APIs , you can create new backend default values that override the in-app values according to your desired conditional logic or user targeting. This section walks you through the Firebase console steps to create these values.

  1. In the Firebase console , open your project.
  2. Select Remote Config from the menu to view the Remote Config dashboard.
  3. 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 you can also set conditional values. To learn more, see Remote Config Parameters and Conditions .

Step 5: Fetch and activate values

To fetch parameter values from Remote Config, call the fetchWithCompletionHandler: or fetchWithExpirationDuration:completionHandler: method. Any values that you set on the backend are fetched and cached in the Remote Config object.

For cases where you want to fetch and activate values in one call, use fetchAndActivateWithCompletionHandler: .

This example fetches values from the Remote Config backend (not cached values) and calls activateWithCompletionHandler: to make them available to the app:

সুইফট

remoteConfig.fetch { (status, error) -> Void in
  if status == .success {
    print("Config fetched!")
    self.remoteConfig.activate { changed, error in
      // ...
    }
  } else {
    print("Config not fetched")
    print("Error: \(error?.localizedDescription ?? "No error available.")")
  }
  self.displayWelcome()
}

উদ্দেশ্য গ

[self.remoteConfig fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) {
    if (status == FIRRemoteConfigFetchStatusSuccess) {
        NSLog(@"Config fetched!");
      [self.remoteConfig activateWithCompletion:^(BOOL changed, NSError * _Nullable error) {
        if (error != nil) {
          NSLog(@"Activate error: %@", error.localizedDescription);
        } else {
          dispatch_async(dispatch_get_main_queue(), ^{
            [self displayWelcome];
          });
        }
      }];
    } else {
        NSLog(@"Config not fetched");
        NSLog(@"Error %@", error.localizedDescription);
    }
}];

Because these updated parameter values affect the behavior and appearance of your app, you should activate the fetched values at a time that ensures a smooth experience for your user, such as the next time that the user opens your app. See Remote Config loading strategies for more information and examples.

Step 6: 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.

  1. 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 when activateWithCompletionHandler is called, uses the newly fetched values to display an updated welcome message.

    সুইফট

    remoteConfig.addOnConfigUpdateListener { configUpdate, error in
      guard let configUpdate, error == nil else {
        print("Error listening for config updates: \(error)")
      }
    
      print("Updated keys: \(configUpdate.updatedKeys)")
    
      self.remoteConfig.activate { changed, error in
        guard error == nil else { return self.displayError(error) }
        DispatchQueue.main.async {
          self.displayWelcome()
        }
      }
    }
    

    উদ্দেশ্য গ

    __weak __typeof__(self) weakSelf = self;
    [self.remoteConfig addOnConfigUpdateListener:^(FIRRemoteConfigUpdate * _Nonnull configUpdate, NSError * _Nullable error) {
      if (error != nil) {
        NSLog(@"Error listening for config updates %@", error.localizedDescription);
      } else {
        NSLog(@"Updated keys: %@", configUpdate.updatedKeys);
    
        __typeof__(self) strongSelf = weakSelf;
        [strongSelf.remoteConfig activateWithCompletion:^(BOOL changed, NSError * _Nullable error) {
          if (error != nil) {
            NSLog(@"Activate error %@", error.localizedDescription);
          }
    
          dispatch_async(dispatch_get_main_queue(), ^{
            [strongSelf displayWelcome];
          });
        }];
      }
    }];
    
  2. 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 completion handler.

Throttling

If an app fetches too many times in a short time period, fetch calls are throttled and the SDK returns FIRRemoteConfigFetchStatusThrottled . Before SDK version 6.3.0, the limit was 5 fetch requests in a 60 minute window (newer versions have more permissive limits).

During app development, you might want to refresh the cache very frequently (many times per hour) to let you rapidly iterate as you develop and test your app. To accommodate rapid iteration on a project with numerous developers, you can temporarily add a FIRRemoteConfigSettings property with a low minimum fetch interval ( MinimumFetchInterval ) in your app.

The default and recommended production fetch interval for Remote Config is 12 hours, which means that configs won't be fetched from the backend more than once in a 12 hour window, regardless of how many fetch calls are actually made. Specifically, the minimum fetch interval is determined in this following order:

  1. The parameter in fetch(long)
  2. The parameter in FIRRemoteConfigSettings.MinimumFetchInterval
  3. The default value of 12 hours

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: