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

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



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

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

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

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

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

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

implementation 'com.google.android.gms:play-services-ads:24.0.0'
implementation 'com.google.firebase:firebase-analytics:22.3.0'
implementation 'com.google.firebase:firebase-config:22.1.0'

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

  • 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;
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
        .setMinimumFetchIntervalInSeconds(3600)
        .build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);
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];
}];
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();
            }
        });
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();
});

আপনার অ্যাপ এখন এই টিউটোরিয়ালের আগে সেট আপ করা A/B পরীক্ষার সময় তৈরি করা 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.
    }
}
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.
    }
}
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 প্যারামিটারের মান পরীক্ষা করতে হবে। উদাহরণস্বরূপ, ব্যবহারকারী বর্তমানটি দেখা শেষ করার পরে আপনি একটি বিজ্ঞাপন পুনরায় লোড করবেন কিনা তা নির্ধারণ করতে পারেন৷

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

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

remoteConfig["showNewAdKey"].boolValue
self.remoteConfig[@"SHOW_NEW_AD_KEY"].boolValue;
mFirebaseRemoteConfig.getBoolean(SHOW_NEW_AD_KEY)
remoteConfig.getBoolean(SHOW_NEW_AD_KEY)
remoteConfig.GetValue("SHOW_NEW_AD_KEY").BooleanValue

এই কলগুলি সর্বদা একটি অ্যাপ ইন্সট্যান্সের জন্য একই মান ফেরত দেবে এটি নিয়ন্ত্রণ গোষ্ঠী বা নতুন বিজ্ঞাপন ভেরিয়েন্ট গ্রুপে রাখা হয়েছে কিনা তার উপর নির্ভর করে, যদি না পূর্ববর্তী কলগুলিতে আনা এবং সক্রিয় করা Firebase কনসোলে কোনো পরিবর্তন করা না হয়।




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