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

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


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

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

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


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

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

আপনার অ্যাপ্লিকেশন কোডে Remote Config ব্যবহার করার আগে, আপনার প্রোজেক্ট বিল্ড ফাইলে Remote Config এসডিকে এবং Google Analytics জন্য ফায়ারবেস এসডিকে উভয়ই যুক্ত করুন।

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

আপনার পডফাইলে নিম্নলিখিত পডগুলি যোগ এবং ইনস্টল করুন:

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

অ্যান্ড্রয়েড

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

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

ঐক্য

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

  • FirebaseAnalytics.unitypackage
  • FirebaseRemoteConfig.unitypackage

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

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

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

সুইফট

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

উদ্দেশ্য-সি

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)

ঐক্য

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 ভ্যালুটি আগে থেকে ফেচ করা প্রয়োজন, যাতে আপনার অ্যাপ বুঝতে পারে বিজ্ঞাপনটি দেখাবে কি না।

সুইফট

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

উদ্দেশ্য-সি

[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()
        }

ঐক্য

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

আপনার অ্যাপটি এখন Remote Config প্যারামিটারটি পরিচালনা করার জন্য প্রস্তুত, যা আপনি এই টিউটোরিয়ালের শুরুতে এ/বি টেস্ট সেটআপের সময় তৈরি করেছিলেন।

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

অ্যাপ ইনস্ট্যান্সটি নতুন রিওয়ার্ডেড ইন্টারস্টিশিয়াল অ্যাড ইউনিটটি দেখাবে (প্যারামিটার ভ্যালু true ) নাকি দেখাবে না (প্যারামিটার ভ্যালু false ) তা নির্ধারণ করতে loadAdUnit() ফাংশনে আগে থেকে আনা Remote Config ভ্যালুটি ব্যবহার করুন।

সুইফট

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.
  }
}

উদ্দেশ্য-সি

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

ঐক্য

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 প্যারামিটারের মান যাচাই করার প্রয়োজন হবে। উদাহরণস্বরূপ, ব্যবহারকারী বর্তমান বিজ্ঞাপনটি দেখা শেষ করার পর সেটি পুনরায় লোড করা হবে কিনা, তা আপনি সিদ্ধান্ত নিতে পারেন।

প্যারামিটারের মানের যেকোনো পরিবর্তন পাওয়ার জন্য প্রথমে fetch এবং activate কলগুলো করা উচিত — উদাহরণস্বরূপ, যদি আপনি কোনো এক্সপেরিমেন্ট শেষ করার বা নতুন করে তৈরি করার সিদ্ধান্ত নেন।

সেখান থেকে, আপনি নিম্নলিখিত কলগুলি ব্যবহার করে প্যারামিটারটির মান সর্বদা পরীক্ষা করতে পারেন:

সুইফট

remoteConfig["showNewAdKey"].boolValue

উদ্দেশ্য-সি

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

Java

mFirebaseRemoteConfig.getBoolean(SHOW_NEW_AD_KEY)

Kotlin

remoteConfig.getBoolean(SHOW_NEW_AD_KEY)

ঐক্য

remoteConfig.GetValue("SHOW_NEW_AD_KEY").BooleanValue

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




: Firebase কনসোলে একটি A/B টেস্ট সেট আপ করুন। ধাপ ৪ : A/B টেস্ট শুরু করুন এবং পরীক্ষার ফলাফল পর্যালোচনা করুন