টিউটোরিয়াল: নতুন AdMob বিজ্ঞাপন ফর্ম্যাট গ্রহণ করা হয়েছে কিনা তা পরীক্ষা করা

ধাপ ৩: আপনার অ্যাপের কোডে Remote Config প্যারামিটার ভ্যালু ম্যানেজ করা


ভূমিকা: Firebase ব্যবহার করে নতুন AdMob বিজ্ঞাপন ফর্ম্যাট প্রয়োগ করা
ধাপ ১: পরীক্ষা করার জন্য নতুন বিজ্ঞাপন ইউনিট ভ্যারিয়েন্ট তৈরি করতে AdMob ব্যবহার করুন
ধাপ ২: Firebase কনসোলে একটি A/B পরীক্ষা সেট-আপ করুন

ধাপ ৩: আপনার অ্যাপের কোডে Remote Config প্যারামিটার ভ্যালু ম্যানেজ করুন

ধাপ ৪: A/B পরীক্ষা শুরু করুন এবং Firebase কনসোলে পরীক্ষার ফলাফল পর্যালোচনা করুন
ধাপ ৫: নতুন বিজ্ঞাপন ফর্ম্যাট রিলিজ করবেন কিনা সেই ব্যাপারে সিদ্ধান্ত নিন


শেষ ধাপের শেষে, আপনি একটি Remote Config প্যারামিটার (SHOW_NEW_AD_KEY) তৈরি করেছেন। এই ধাপে, আপনার অ্যাপের কোডে এমন লজিক যোগ করবেন যা সেই প্যারামিটারের ভ্যালুর উপর ভিত্তি করে আপনার অ্যাপ কী দেখাবে — true (নতুন বিজ্ঞাপন দেখাও) বনাম false (নতুন বিজ্ঞাপন দেখাবে না)।

প্রয়োজনীয় SDK যোগ করুন

আপনার অ্যাপ্লিকেশন কোডে Remote Config ব্যবহার করার আগে, আপনার প্রোজেক্ট বিল্ড ফাইলে Remote Config SDK এবং Google Analytics-এর জন্য Firebase SDK দুটিই যোগ করুন।

Apple প্ল্যাটফর্ম

আপনার podfile-এ নিম্নলিখিত পড যোগ করুন ও ইনস্টল করুন:

pod 'Google-Mobile-Ads-SDK'
pod 'Firebase/Analytics'
pod 'Firebase/RemoteConfig'

Android

আপনার build.gradle ফাইলে নিম্নলিখিত লাইব্রেরি নির্ভরতা যোগ করুন:

implementation 'com.google.android.gms:play-services-ads:25.5.0'
implementation 'com.google.firebase:firebase-analytics:23.2.0'
implementation 'com.google.firebase:firebase-config:23.1.0'

Unity

Firebase Unity SDK ডাউনলোড ও ইনস্টল করুন, তারপর আপনার প্রোজেক্টে নিম্নলিখিত Unity প্যাকেজ যোগ করুন:

  • FirebaseAnalytics.unitypackage
  • FirebaseRemoteConfig.unitypackage

Remote Config ইনস্ট্যান্স কনফিগার করুন

Remote Config প্যারামিটার ভ্যালু ব্যবহার করতে, Remote Config ইনস্ট্যান্স কনফিগার করুন যাতে এটি ক্লায়েন্ট অ্যাপ ইনস্ট্যান্সের জন্য নতুন ভ্যালু ফেচ করতে পারে।

এই উদাহরণে, Remote Config প্রতি ঘণ্টায় একবার করে নতুন প্যারামিটার ভ্যালু চেক করার জন্য কনফিগার করা হয়েছে।

Swift

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

Objective-C

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

Java

mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
        .setMinimumFetchIntervalInSeconds(3600)
        .build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);

Kotlin

remoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
    minimumFetchIntervalInSeconds = 3600
}
remoteConfig.setConfigSettingsAsync(configSettings)

Unity

var remoteConfig = FirebaseRemoteConfig.DefaultInstance;
var configSettings = new ConfigSettings {
  MinimumFetchInternalInMilliseconds =
        (ulong)(new TimeSpan(1, 0, 0).TotalMilliseconds)
};
remoteConfig.SetConfigSettingsAsync(configSettings)
        .ContinueWithOnMainThread(task => {
          Debug.Log("Config settings confirmed");
}

Remote Config নিয়ে এসে অ্যাক্টিভেট করুন

Remote Config প্যারামিটার নিয়ে এসে অ্যাক্টিভেট করুন যাতে এটি নতুন প্যারামিটার ভ্যালু ব্যবহার করা শুরু করতে পারে।

আপনার অ্যাপের লোডিং ফেজে যত তাড়াতাড়ি সম্ভব এই কলটি করতে হবে কারণ এই কলটি অ্যাসিঙ্ক্রোনাস এবং আপনার Remote Config ভ্যালু প্রি-ফেচ করা প্রয়োজন যাতে আপনার অ্যাপ বুঝতে পারে যে বিজ্ঞাপনটি দেখাতে হবে কিনা।

Swift

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.loadAdUnit()
}

Objective-C

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

Java

mFirebaseRemoteConfig.fetchAndActivate()
        .addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
            @Override
            public void onComplete(@NonNull Task<Boolean> task) {
                if (task.isSuccessful()) {
                    boolean updated = task.getResult();
                    Log.d(TAG, "Config params updated: " + updated);
                } else {
                    Log.d(TAG, "Config params failed to update");
                }
                loadAdUnit();
            }
        });

Kotlin

remoteConfig.fetchAndActivate()
        .addOnCompleteListener(this) { task ->
            if (task.isSuccessful) {
                val updated = task.result
                Log.d(TAG, "Config params updated: $updated")
            } else {
                Log.d(TAG, "Config params failed to update")
            }
            loadAdUnit()
        }

Unity

remoteConfig.FetchAndActivateAsync().ContinueWithOnMainThread(task => {
  if (task.IsFaulted) {
    Debug.LogWarning("Config params failed to update");
  } else {
    Debug.Log("Config params updated: " + task.Result);
  }
  LoadAdUnit();
});

এই টিউটোরিয়ালে আগে A/B টেস্ট সেট-আপ করার সময় আপনি যে Remote Config প্যারামিটার তৈরি করেছিলেন, সেটি এখন আপনার অ্যাপ হ্যান্ডেল করতে পারবে ।

Remote Config প্যারামিটার ভ্যালু ব্যবহার করুন

অ্যাপ ইনস্ট্যান্সকে নতুন পুরস্কার প্রদানকারী ইন্টারস্টিশিয়াল বিজ্ঞাপন ইউনিট দেখাতে হবে (true-এর প্যারামিটার ভ্যালু) নাকি দেখানো যাবে না (false-এর প্যারামিটার ভ্যালু) তা নির্ধারণ করতে loadAdUnit() ফাংশনে প্রি-ফেচ করা Remote Config ভ্যালু ব্যবহার করুন।

Swift

private func loadAdUnit() {
  let showNewAdFormat = remoteConfig["users"].boolValue
  if showNewAdFormat {
      // Load Rewarded Interstitial Ad.
      // This should load your new implemented ad unit
      // as per AdMob instructions (the first step of this tutorial).
  } else {
    // Show the existing ad unit.
  }
}

Objective-C

- (void)loadAdUnit {
    BOOL showAds = self.remoteConfig[@"SHOW_NEW_AD_KEY"].boolValue;
    if (showAds) {
      // Load Rewarded Interstitial Ad.
      // This should load your new implemented ad unit
      // per AdMob instructions (the first step of this tutorial).
    } else {
      // Show the existing ad unit.
    }
}

Java

private void loadAdUnit() {
    boolean showNewAdFormat =
      mFirebaseRemoteConfig.getBoolean(SHOW_NEW_AD_KEY);

    if (showNewAdFormat) {
      // Load Rewarded Interstitial Ad.
      // This should load your new implemented ad unit
      // per AdMob instructions (the first step of this tutorial).
    } else {
      // Show the existing ad unit.
    }
}

Kotlin

private fun loadAdUnit() {
  var showNewAdFormat = remoteConfig.getBoolean(SHOW_NEW_AD_KEY)

  if (showNewAdFormat) {
      // Load Rewarded Interstitial Ad.
      // This should load your new implemented ad unit
      // per AdMob instructions (the first step of this tutorial).
    } else {
      // Show the existing ad unit.
    }
}

Unity

void LoadAdUnit() {
  bool showNewAdFormat =
      remoteConfig.GetValue("SHOW_NEW_AD_KEY").BooleanValue;

  if (showNewAdFormat) {
    // Load Rewarded Interstitial Ad (new implemented ad unit)
    // per AdMob instructions (the first step of this tutorial).
  } else {
    // Show the existing ad unit.
  }
}

প্যারামিটার ভ্যালুর জন্য অন্যান্য চেক যোগ করুন

আপনার অ্যাপ্লিকেশন কোডে এমন অন্যান্য জায়গা আছে যেখানে কোন বিজ্ঞাপন অভিজ্ঞতা লোড করা হবে তা নির্ধারণ করতে আপনাকে এই Remote Config প্যারামিটারের মান চেক করতে হবে। যেমন, ব্যবহারকারী বর্তমান বিজ্ঞাপনটি দেখা শেষ করার পরে আপনি সিদ্ধান্ত নিতে পারেন যে বিজ্ঞাপনটি আবার লোড করবেন কিনা।

কোনও প্যারামিটার ভ্যালু পরিবর্তন পেতে, প্রথমে ফেচ ও অ্যাক্টিভেট কল করতে হবে — যেমন, আপনি যদি কোনও নতুন পরীক্ষা শেষ করতে বা তৈরি করতে চান।

সেখান থেকে, আপনি সবসময় নিম্নলিখিত কল ব্যবহার করে প্যারামিটারের ভ্যালু চেক করতে পারবেন:

Swift

remoteConfig["showNewAdKey"].boolValue

Objective-C

self.remoteConfig[@"SHOW_NEW_AD_KEY"].boolValue;

Java

mFirebaseRemoteConfig.getBoolean(SHOW_NEW_AD_KEY)

Kotlin

remoteConfig.getBoolean(SHOW_NEW_AD_KEY)

Unity

remoteConfig.GetValue("SHOW_NEW_AD_KEY").BooleanValue

এইসব কল সবসময় কোনও অ্যাপ ইনস্ট্যান্সের জন্য একই ভ্যালু রিটার্ন করবে, এটি কন্ট্রোল গ্রুপে বা নতুন বিজ্ঞাপন ভ্যারিয়েন্ট গ্রুপে প্লেস করা হয়েছে কিনা তার উপর নির্ভর করে, যদি না Firebase কনসোলে কোনও পরিবর্তন করা হয়ে থাকে যা আগের কলে ফেচ ও অ্যাক্টিভেট করা হয়েছিল।




ধাপ ২: Firebase কনসোলে A/B টেস্ট সেট-আপ করুন ধাপ ৪: A/B টেস্ট শুরু করুন ও টেস্টের ফলাফল পর্যালোচনা করুন