### Initialize Bidon SDK in Unity Source: https://docs.bidon.org/docs/sdk/unity/get-started Demonstrates how to import the Bidon namespace, register default adapters, set the base URL, and initialize the SDK within the Start method of a MonoBehaviour. ```csharp using Bidon.Mediation; private void Start(){ BidonSdk.Instance.RegisterDefaultAdapters(); // Bidon's server can either be self-hosted or managed by a third-party service. BidonSdk.Instance.SetBaseUrl("https://[YOUR_BIDON_SERVER_DOMAIN.com]"); BidonSdk.Instance.OnInitializationFinished += (sender, args) => { Debug.Log($"Is Initialized: {BidonSdk.Instance.IsInitialized()}"); }; BidonSdk.Instance.Initialize("APP_KEY"); } ``` -------------------------------- ### Initialize Bidon SDK Source: https://docs.bidon.org/llms-full.txt Initializes the Bidon SDK within a Unity Start method. It registers default adapters, sets the server domain, and handles the initialization completion callback. ```csharp using Bidon.Mediation; private void Start() { BidonSdk.Instance.RegisterDefaultAdapters(); BidonSdk.Instance.SetBaseUrl("https://[YOUR_BIDON_SERVER_DOMAIN.com]"); BidonSdk.Instance.OnInitializationFinished += (sender, args) => { Debug.Log($"Is Initialized: {BidonSdk.Instance.IsInitialized()}"); }; BidonSdk.Instance.Initialize("APP_KEY"); } ``` -------------------------------- ### Install Bidon Unity Adapter via Git URL Source: https://docs.bidon.org/llms-full.txt Instructions for installing the Bidon adapter for Unity using the Package Manager with a provided Git URL. This method requires Unity 2021.3.0+ and CocoaPods 1.12.0+. ```text https://github.com/bidon-io/applovin-mediation-bidon-adapter-unity.git#v0.8.0 ``` -------------------------------- ### User Segmentation Examples - Kotlin Source: https://docs.bidon.org/llms-full.txt Demonstrates how to set various user segmentation parameters using the Bidon SDK, including age, gender, custom attributes, level, in-app purchase amount, and paying status. ```kotlin BidonSdk.segment.setAge(25) BidonSdk.segment.setGender(Gender.FEMALE) BidonSdk.segment.setCustomAttributes(mapOf("custom_attribute" to "custom_value")) BidonSdk.segment.setLevel(5) BidonSdk.segment.setTotalInAppAmount(100.0) BidonSdk.segment.setPaying(true) ``` -------------------------------- ### Initialize and Load Banner Ads in iOS Source: https://docs.bidon.org/llms-full.txt Demonstrates how to instantiate a banner view, configure its delegate, and load an advertisement. It includes mandatory setup of the rootViewController and implementation of the delegate protocol for handling ad lifecycle events. ```swift class ViewController: UIViewController { var banner: Bidon.BannerView! func loadBanner() { banner = Bidon.BannerView( frame: CGRect, auctionKey: String? = nil ) banner.rootViewController = self banner.format = .banner banner.delegate = self banner.translatesAutoresizingMaskIntoConstraints = false view.addSubview(banner) NSLayoutConstraint.activate([ banner.heightAnchor.constraint(equalToConstant: 50), banner.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), banner.leftAnchor.constraint(equalTo: view.leftAnchor), banner.rightAnchor.constraint(equalTo: view.rightAnchor) ]) banner.loadAd(with: 0.1) } } extension ViewController: Bidon.AdViewDelegate { func adView(_ adView: UIView & Bidon.AdView, willPresentScreen ad: Bidon.Ad) {} func adView(_ adView: UIView & Bidon.AdView, didDismissScreen ad: Bidon.Ad) {} func adView(_ adView: UIView & Bidon.AdView, willLeaveApplication ad: Bidon.Ad) {} func adObject(_ adObject: Bidon.AdObject, didLoadAd ad: Bidon.Ad, auctionInfo: Bidon.AuctionInfo) {} func adObject(_ adObject: Bidon.AdObject, didFailToLoadAd error: Error, auctionInfo: Bidon.AuctionInfo) {} } ``` ```objc #import "ViewController.h" #import #import @interface ViewController() @property (nonatomic, strong) BDNBannerView *banner; @end @implementation ViewController - (void)createBanner { self.banner = [[BDNBannerView alloc] initWithFrame:CGRectZero auctionKey:@"AUCTION_KEY"]; self.banner.rootViewController = self; self.banner.format = BDNBannerFormatBanner; self.banner.delegate = self; self.banner.translatesAutoresizingMaskIntoConstraints = NO; [self.banner loadAdWith:0.1]; [self.view addSubview: self.banner]; [NSLayoutConstraint activateConstraints:@[ [self.banner.heightAnchor constraintEqualToConstant:50], [self.banner.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], [self.banner.leftAnchor constraintEqualToAnchor:self.view.leftAnchor], [self.banner.rightAnchor constraintEqualToAnchor:self.view.rightAnchor] ]]; } - (void)adObject:(id)adObject didLoadAd:(id)ad auctionInfo:(id)auctionInfo {} - (void)adObject:(id)adObject didFailToLoadAd:(NSError *)error auctionInfo:(id)auctionInfo {} - (void)adView:(UIView *)adView didDismissScreen:(id)ad {} - (void)adView:(UIView *)adView willLeaveApplication:(id)ad {} - (void)adView:(UIView *)adView willPresentScreen:(id)ad {} @end ``` -------------------------------- ### Bidon Server Setup Environment Variables Source: https://docs.bidon.org/llms-full.txt Lists the required environment variables for setting up a self-hosted Bidon instance using Docker Compose. These include MaxMind credentials, application secrets, and database passwords. ```env # MaxMind Credentials MAXMIND_ACCOUNT_ID=your-maxmind-account-id MAXMIND_LICENSE_KEY=your-maxmind-license-key # Application Secrets APP_SECRET=a-unique-application-secret SUPERUSER_LOGIN=your-superuser-login SUPERUSER_PASSWORD=your-superuser-password # Database Password PG_PASSWORD=your-postgresql-password # Demand Meta Credentials DEMAND_META_APP_SECRET=your-demand-meta-app-secret DEMAND_META_PLATFORM_ID=your-demand-meta-platform-id ``` -------------------------------- ### Integrate Bidon SDK via CocoaPods Source: https://docs.bidon.org/llms-full.txt Provides the Podfile configuration to include the Bidon SDK and various ad network adapters, followed by the command to install the dependencies. ```ruby source 'https://cdn.cocoapods.org/' pod 'Bidon', '~> 0.13.0' pod 'BidonAdapterAmazon' pod 'BidonAdapterAppLovin' pod 'BidonAdapterBidMachine' pod 'BidonAdapterBigoAds' pod 'BidonAdapterChartboost' pod 'BidonAdapterDTExchange' pod 'BidonAdapterGoogleAdManager' pod 'BidonAdapterGoogleMobileAds' pod 'BidonAdapterInMobi' pod 'BidonAdapterIronSource' pod 'BidonAdapterMetaAudienceNetwork' pod 'BidonAdapterMintegral' pod 'BidonAdapterMobileFuse' pod 'BidonAdapterMoloco' pod 'BidonAdapterMyTarget' pod 'BidonAdapterStartIo' pod 'BidonAdapterTaurusX' pod 'BidonAdapterUnityAds' pod 'BidonAdapterVungle' pod 'BidonAdapterYandex' ``` ```sh pod install --repo-update ``` -------------------------------- ### PostBidInterstitialAdController Initialization and Ad Handling (C#) Source: https://docs.bidon.org/llms-full.txt This C# code defines the PostBidInterstitialAdController, responsible for managing interstitial ads from two providers in a post-bid setup. It handles ad loading, event subscriptions, and logic for showing ads based on loaded status and eCPM. Dependencies include IInterstitialAdProvider and AdConfig. ```csharp using System; using System.Threading.Tasks; public class PostBidInterstitialAdController : IInterstitialAdController { public event EventHandler OnAdShowFailed; public event EventHandler OnAdClosed; private IInterstitialAdProvider FirstAdProvider { get; } private IInterstitialAdProvider SecondAdProvider { get; } private readonly double _defaultPriceFloor; private readonly PriceFloorIncrementStrategy _strategy; private readonly double _step; private int _interstitialAdLoadRetryAttempt; private double _firstAdProviderEcpm; private double _secondAdProviderEcpm; private bool _isFirstAdProviderLoaded; private bool _isSecondAdProviderLoaded; public PostBidInterstitialAdController(IInterstitialAdProvider firstProvider, IInterstitialAdProvider secondProvider) { AdHelper.Log("[PostBidInterstitialAdController] [Constructor] PostBidInterstitialAdController()"); FirstAdProvider = firstProvider; SecondAdProvider = secondProvider; _defaultPriceFloor = AdConfig.DefaultInterstitialAdPriceFloor; _strategy = AdConfig.InterstitialAdPriceFloorIncrementStrategy; _step = AdConfig.InterstitialAdPriceFloorIncrementStep; SubscribeToAdEvents(); FirstAdProvider?.LoadInterstitialAd(); } public bool IsLoaded() => _isFirstAdProviderLoaded || _isSecondAdProviderLoaded; public void ShowInterstitial(string placementName) { AdHelper.Log($"[PostBidInterstitialAdController] [Method] ShowInterstitial(placement: {placementName})"); if (!_isFirstAdProviderLoaded && !_isSecondAdProviderLoaded) { AdHelper.Log($"[PostBidInterstitialAdController] {FirstAdProvider?.Name} is NOT loaded, {SecondAdProvider?.Name} is NOT loaded, Skip Show"); } else if (_isFirstAdProviderLoaded && !_isSecondAdProviderLoaded) { AdHelper.Log($"[PostBidInterstitialAdController] {FirstAdProvider?.Name} is loaded, {SecondAdProvider?.Name} is NOT loaded, Show {FirstAdProvider?.Name} with placement: {placementName}"); FirstAdProvider?.NotifyWin(); SecondAdProvider?.NotifyLoss(FirstAdProvider?.Name, _firstAdProviderEcpm); _isSecondAdProviderLoaded = false; _secondAdProviderEcpm = 0d; FirstAdProvider?.ShowInterstitialAd(placementName); } else if (!_isFirstAdProviderLoaded && _isSecondAdProviderLoaded) { AdHelper.Log($"[PostBidInterstitialAdController] {FirstAdProvider?.Name} is NOT loaded, {SecondAdProvider?.Name} is loaded, Show {SecondAdProvider?.Name} with placement: {placementName}"); FirstAdProvider?.NotifyLoss(SecondAdProvider?.Name, _secondAdProviderEcpm); SecondAdProvider?.NotifyWin(); SecondAdProvider?.ShowInterstitialAd(placementName); } else { if (_firstAdProviderEcpm > _secondAdProviderEcpm) { AdHelper.Log($"[PostBidInterstitialAdController] {FirstAdProvider?.Name} is loaded(ecpm: {_firstAdProviderEcpm}), {SecondAdProvider?.Name} is loaded(ecpm: {_secondAdProviderEcpm}), Show {FirstAdProvider?.Name} with placement: {placementName}"); FirstAdProvider?.NotifyWin(); SecondAdProvider?.NotifyLoss(FirstAdProvider?.Name, _firstAdProviderEcpm); _isSecondAdProviderLoaded = false; _secondAdProviderEcpm = 0d; FirstAdProvider?.ShowInterstitialAd(placementName); } else { AdHelper.Log($"[PostBidInterstitialAdController] {FirstAdProvider?.Name} is loaded(ecpm: {_firstAdProviderEcpm}), {SecondAdProvider?.Name} is loaded(ecpm: {_secondAdProviderEcpm}), Show {SecondAdProvider?.Name} with placement: {placementName}"); FirstAdProvider?.NotifyLoss(SecondAdProvider?.Name, _secondAdProviderEcpm); SecondAdProvider?.NotifyWin(); SecondAdProvider?.ShowInterstitialAd(placementName); } } } private void SubscribeToAdEvents() { AdHelper.Log("[PostBidInterstitialAdController] [Method] SubscribeToAdEvents()"); if (FirstAdProvider == null) return; FirstAdProvider.OnAdLoaded += OnFirstAdProviderLoaded; FirstAdProvider.OnAdLoadFailed += OnFirstAdProviderLoadFailed; FirstAdProvider.OnAdShown += OnFirstAdProviderShown; FirstAdProvider.OnAdShowFailed += OnFirstAdProviderShowFailed; FirstAdProvider.OnAdClosed += OnFirstAdProviderClosed; FirstAdProvider.OnAdRevenueReceived += (sender, args) => AdHelper.LogAdRevenue(args.Info); if (SecondAdProvider == null) return; ``` -------------------------------- ### Initialize and Load Banner Ads in Kotlin Source: https://docs.bidon.org/llms-full.txt Demonstrates how to instantiate a BannerView, attach a BannerListener to handle ad lifecycle events, and load the ad with a specified price floor. Note that each BannerView instance is intended for a single load and display cycle. ```kotlin val banner = BannerView( context = context, auctionKey = "AUCTION_KEY" ) banner.setBannerListener(object : BannerListener { override fun onAdLoaded(ad: Ad, auctionInfo: AuctionInfo) {} override fun onAdLoadFailed(auctionInfo: AuctionInfo?, cause: BidonError) {} override fun onAdShowFailed(cause: BidonError) {} override fun onAdShown(ad: Ad) {} override fun onAdClicked(ad: Ad) {} override fun onAdExpired(ad: Ad) {} override fun onRevenuePaid(ad: Ad, adValue: AdValue) {} }) banner.setBannerFormat(BannerFormat.Banner) banner.loadAd(activity = activity, pricefloor = pricefloor) ``` -------------------------------- ### Get Segment UID - C# Source: https://docs.bidon.org/llms-full.txt Retrieves the unique identifier for the current user segment. This UID is assigned by the server and becomes available after the first SDK request. ```csharp Debug.Log($"Segment Uid: {BidonSdk.Instance.Segment.Uid}"); ``` -------------------------------- ### Initialize Bidon SDK (Swift) Source: https://docs.bidon.org/llms-full.txt Initializes the Bidon SDK in the application delegate. This includes registering default adapters, setting the base URL for the Bidon server, configuring the log level, and calling the main initialization method with the provided App Key. It's recommended to perform this in `application:didFinishLaunchingWithOptions:`. ```swift @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Register all available demand source adapters. BidonSdk.registerDefaultAdapters() // Bidon's server can either be self-hosted or managed by a third-party service. Please contact us at hi@bidon.org for a list of recommended managed service providers. BidonSdk.baseURL = "https://[YOUR_BIDON_SERVER_DOMAIN.com]" // Configure Bidon BidonSdk.logLevel = .debug // Initialize BidonSdk.initialize(appKey: "APP KEY") { // Load any ads } ⋮ ``` -------------------------------- ### Get Segment ID - Swift/Objective-C Source: https://docs.bidon.org/llms-full.txt Retrieve the unique segment ID assigned to a user segment by the server. This ID is available after the first SDK request and is used for targeted advertising. ```swift let segmentID = BidonSDK.segment.id ``` ```objc NSString *segmentID = [BDNSdk.segment id]; ``` -------------------------------- ### Initialize BannerProvider instance Source: https://docs.bidon.org/llms-full.txt Demonstrates how to instantiate the BannerProvider class, set the ad format, assign the root view controller, and set the delegate for ad lifecycle events. ```swift final class ViewController: UIViewController { lazy var provider: BannerProvider = { let provider = BannerProvider() provider.format = .banner provider.rootViewController = self provider.delegate = self return provider }() } ``` ```objc @interface ViewController () @property (nonatomic, strong) BDNBannerProvider *provider; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.provider = [[BDNBannerProvider alloc] init]; self.provider.format = BDNBannerFormatBanner; self.provider.rootViewController = self; self.provider.delegate = self; } ``` -------------------------------- ### Set and Get Test Mode - C# Source: https://docs.bidon.org/llms-full.txt Enables or disables the test mode for the Bidon SDK and checks if it is currently enabled. Test mode is useful for debugging and testing SDK functionality. ```csharp BidonSdk.Instance.SetTestMode(false); bool isEnabled = BidonSdk.Instance.IsTestModeEnabled(); ``` -------------------------------- ### Create Banner Ad Instance Source: https://docs.bidon.org/llms-full.txt Demonstrates how to instantiate a BidonBannerAd object, optionally using an auction key for specific configurations. ```csharp using Bidon.Mediation; // Basic instance var bidonBanner = new BidonBannerAd(); // Instance with Auction Key var bidonBanner = new BidonBannerAd("AUCTION_KEY"); ``` -------------------------------- ### Get Segment UID - Kotlin Source: https://docs.bidon.org/llms-full.txt Retrieves the unique segment identifier (UID) assigned to a user by the server. This UID is used for monitoring metrics and controlling advertisements for specific user categories. ```kotlin val segmentUid = BidonSdk.segment.segmentUid //e.x.: "1704325228273860608" – Snowflake ID ``` -------------------------------- ### Set and Get Log Level - C# Source: https://docs.bidon.org/llms-full.txt Sets the logging level for the Bidon SDK and retrieves the current log level. Different levels (e.g., Verbose) provide varying amounts of diagnostic information. ```csharp BidonSdk.Instance.SetLogLevel(BidonLogLevel.Verbose); var logLevel = BidonSdk.Instance.GetLogLevel(); ``` -------------------------------- ### Initialize Bidon and LevelPlay SDKs Source: https://docs.bidon.org/llms-full.txt Initializes both SDKs in the application lifecycle. Bidon should be initialized first to support parallel demand preloading, and initialization should occur only once. ```kotlin // Initialize Bidon SDK BidonSdk .registerDefaultAdapters() .setBaseUrl("https://your.bidon.server") .setInitializationCallback { /* Initialized */ } .initialize(context, "YOUR_BIDON_APP_KEY") // Initialize LevelPlay SDK LevelPlay.init( context = context, initRequest = LevelPlayInitRequest.Builder("YOUR_LEVEL_PLAY_APP_KEY").build(), listener = object : LevelPlayInitListener { override fun onInitFailed(error: LevelPlayInitError) { /* Initialization Failed */ } override fun onInitSuccess(configuration: LevelPlayConfiguration) { /* Initialized */ } } ) ``` -------------------------------- ### Initialize and Display Ads via AdManager Source: https://docs.bidon.org/llms-full.txt Demonstrates how to initialize the AdManager component and trigger the display of interstitial and rewarded video ads within a Unity scene. ```csharp // Get reference to AdManager component AdManager adManager = GetComponent(); // Initialize the AdManager adManager.Init(); // Show Interstitial Ad adManager.ShowInterstitial("PLACEMENT_NAME"); // Show Rewarded Video Ad adManager.ShowRewarded("PLACEMENT_NAME"); ``` -------------------------------- ### Set and Get Base URL - C# Source: https://docs.bidon.org/llms-full.txt Configures the base URL for the Bidon SDK's network requests and retrieves the currently set base URL. This is useful for directing SDK traffic to specific endpoints. ```csharp BidonSdk.Instance.SetBaseUrl("BASE_URL"); string baseUrl = BidonSdk.Instance.GetBaseUrl(); ``` -------------------------------- ### Initialize and Provide MAX SDK Ad Services in Unity Source: https://docs.bidon.org/llms-full.txt This class manages the initialization of the AppLovin MAX SDK using platform-specific ad unit IDs. It provides lazy-loaded implementations for rewarded and interstitial ad providers to ensure efficient resource management. ```csharp using System; using UnityEngine; public class MaxSdkProvider : ISdkProvider { public event EventHandler OnInitialized; private IRewardedAdProvider _rewardedAdProvider; private IInterstitialAdProvider _interstitialAdProvider; #if UNITY_IOS private const string MaxRewardedAdUnitId = "MAX_REWARDED_AD_UNIT_ID"; private const string MaxInterstitialAdUnitId = "MAX_INTERSTITIAL_AD_UNIT_ID"; #else private const string MaxRewardedAdUnitId = "MAX_REWARDED_AD_UNIT_ID"; private const string MaxInterstitialAdUnitId = "MAX_INTERSTITIAL_AD_UNIT_ID"; #endif public void Initialize() { Debug.Log("[Ads] [MaxSdkProvider] [Method] Initialize()"); MaxSdk.SetVerboseLogging(true); MaxSdk.SetMuted(true); MaxSdk.SetHasUserConsent(true); MaxSdkCallbacks.OnSdkInitializedEvent += _ => OnInitialized?.Invoke(this, EventArgs.Empty); MaxSdk.InitializeSdk(); } public IRewardedAdProvider GetRewardedAdProvider() { Debug.Log("[Ads] [MaxSdkProvider] [Method] GetRewardedAdProvider()"); return _rewardedAdProvider ??= new MaxRewardedAdProvider(MaxRewardedAdUnitId); } public IInterstitialAdProvider GetInterstitialAdProvider() { Debug.Log("[Ads] [MaxSdkProvider] [Method] GetInterstitialAdProvider()"); return _interstitialAdProvider ??= new MaxInterstitialAdProvider(MaxInterstitialAdUnitId); } } ``` -------------------------------- ### Initialize Bidon SDK (Objective-C) Source: https://docs.bidon.org/llms-full.txt Initializes the Bidon SDK using Objective-C. This mirrors the Swift initialization process by registering adapters, setting the server base URL, configuring the log level to debug, and calling the SDK's initialize method with the application key and a completion handler. ```objc #import @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Register all available demand source adapters. [BDNSdk registerDefaultAdapters]; // Bidon's server can either be self-hosted or managed by a third-party service. Please contact us at hi@bidon.org for a list of recommended managed service providers. [BDNSdk setBaseURL:@"https://[YOUR_BIDON_SERVER_DOMAIN.com]"]; // Configure Bidon [BDNSdk setLogLevel:BDNLoggerLevelDebug]; // Initialize [BDNSdk initializeWithAppKey:@"APP KEY" completion:^{ // Load any ads }]; ⋮ ``` -------------------------------- ### Set and Get AdType-Level Extra Data in Swift and Objective-C Source: https://docs.bidon.org/llms-full.txt Include ad type-specific data with ad requests by passing key-value pairs to an ad object. This allows for providing additional context or attributes for specific ad types like banners or interstitials, enhancing targeting and reporting. ```swift // Set extras values adObject.setExtraValue("SOME_STRING_VALUE", for: "SOME_STRING_KEY") adObject.setExtraValue(10.00, for: "SOME_NUMERIC_KEY") adObject.setExtraValue(true, for: "SOME_BOOLEAN_KEY") // Remove previous value adObject.setExtraValue(nil, for: "SOME_KEY_TO_REMOVE") // Get extras let extras: [String: AnyHashable]? = adObject.extras ``` ```objc // Set extras values [adObject setExtraValue:@"SOME_STRING_VALUE" for:@"SOME_STRING_KEY"]; [adObject setExtraValue:@10.00 for:@"SOME_NUMERIC_KEY"]; [adObject setExtraValue:@YES for:@"SOME_BOOLEAN_KEY"]; // Remove previous value [adObject setExtraValue:nil for:@"SOME_KEY_TO_REMOVE"]; // Get extras NSDictionary *extras = [adObject extras]; ``` -------------------------------- ### Manage Rewarded Ad Lifecycle in Kotlin Source: https://docs.bidon.org/llms-full.txt Demonstrates how to initialize, load, show, and destroy a rewarded ad instance. It includes setting up a listener to handle ad events such as loading, displaying, clicking, and revenue callbacks. ```kotlin val rewarded = RewardedAd(auctionKey = "AUCTION_KEY") rewarded.setRewardedListener(object : RewardedListener { override fun onAdLoaded(ad: Ad, auctionInfo: AuctionInfo) {} override fun onAdLoadFailed(auctionInfo: AuctionInfo?, cause: BidonError) {} override fun onAdShowFailed(cause: BidonError) {} override fun onAdShown(ad: Ad) {} override fun onAdClicked(ad: Ad) {} override fun onAdClosed(ad: Ad) {} override fun onAdExpired(ad: Ad) {} override fun onUserRewarded(ad: Ad, reward: Reward?) {} override fun onRevenuePaid(ad: Ad, adValue: AdValue) {} }) rewarded.loadAd(activity = activity, pricefloor = pricefloor) if (rewarded.isReady()) { rewarded.showAd(activity = this) } rewarded.destroyAd() ``` -------------------------------- ### Configure SDK Settings Source: https://docs.bidon.org/llms-full.txt Configures global SDK settings including logging verbosity and test mode for development environments. ```kotlin BidonSdk.setLoggerLevel(Logger.Level.Verbose) BidonSdk.setTestMode(isTestMode = true) ``` -------------------------------- ### Initialize LevelPlay SDK Source: https://docs.bidon.org/llms-full.txt Initializes the LevelPlay SDK using the provided App ID. It subscribes to initialization success and failure events. This method should be called once during application startup. Dependencies include the UnityMainThreadDispatcher for event posting. ```csharp using System; using Unity.Services.LevelPlay; public class LevelPlaySdkProvider : ISdkProvider { public event EventHandler OnInitialized; private IBannerAdProvider _bannerAdProvider; private IRewardedAdProvider _rewardedAdProvider; private IInterstitialAdProvider _interstitialAdProvider; private string LevelPlayAppId = "LEVELPLAY_APP_KEY"; public void Initialize() { AdHelper.Log("[LevelPlaySdkProvider] [Method] Initialize()"); LevelPlay.OnInitSuccess += OnInitializationCompleted; LevelPlay.OnInitFailed += OnInitializationFailed; LevelPlay.Init(LevelPlayAppId); } public IBannerAdProvider GetBannerAdProvider() { AdHelper.Log("[LevelPlaySdkProvider] [Method] GetBannerAdProvider()"); return _bannerAdProvider ??= new LevelPlayBannerAdProvider(RemoteConfig.LevelPlayBannerAdUnitId); } public IRewardedAdProvider GetRewardedAdProvider() { AdHelper.Log("[LevelPlaySdkProvider] [Method] GetRewardedAdProvider()"); return _rewardedAdProvider ??= new LevelPlayRewardedAdProvider(RemoteConfig.LevelPlayRewardedAdUnitId); } public IInterstitialAdProvider GetInterstitialAdProvider() { AdHelper.Log("[LevelPlaySdkProvider] [Method] GetInterstitialAdProvider()"); return _interstitialAdProvider ??= new LevelPlayInterstitialAdProvider(RemoteConfig.LevelPlayInterstitialAdUnitId); } private void OnInitializationCompleted(LevelPlayConfiguration configuration) { AdHelper.Log("[LevelPlaySdkProvider] [Method] OnInitializationCompleted()"); UnityMainThreadDispatcher.Post(_ => OnInitialized?.Invoke(this, EventArgs.Empty)); } private void OnInitializationFailed(LevelPlayInitError error) { AdHelper.Log($"[LevelPlaySdkProvider] [Method] OnInitializationFailed(error: {error})"); UnityMainThreadDispatcher.Post(_ => OnInitialized?.Invoke(this, EventArgs.Empty)); } } ``` -------------------------------- ### Set and Get SDK-Level Extra Data (C#) Source: https://docs.bidon.org/llms-full.txt Illustrates how to attach SDK-level extra data to ad requests using SetExtraData and retrieve all current extras using GetExtraData. Supported value types include bool, char, int, long, float, double, and string. Passing null removes the KeyValuePair. ```csharp BidonSdk.Instance.SetExtraData("sdk_extra_bool_key", 0.423d); var extras = BidonSdk.Instance.GetExtraData(); ``` -------------------------------- ### Set and Get SDK-Level Extra Data in Swift and Objective-C Source: https://docs.bidon.org/llms-full.txt Attach SDK-level data to ad requests using key-value pairs. This feature allows for enhanced ad targeting and analytics by including information related to SDK configuration, version, or user details. Supports setting string, numeric, and boolean values, as well as removing existing values. ```swift // Set extras values BidonSdk.setExtraValue("SOME_STRING_VALUE", for: "SOME_STRING_KEY") BidonSdk.setExtraValue(10.00, for: "SOME_NUMERIC_KEY") BidonSdk.setExtraValue(true, for: "SOME_BOOLEAN_KEY") // Remove previous value BidonSdk.setExtraValue(nil, for: "SOME_KEY_TO_REMOVE") // Get extras let extras: [String: AnyHashable]? = BidonSdk.extras ``` ```objc // Set extras values [BDNSdk setExtraValue:@"SOME_STRING_VALUE" for:@"SOME_STRING_KEY"]; [BDNSdk setExtraValue:@10.00 for:@"SOME_NUMERIC_KEY"]; [BDNSdk setExtraValue:@YES for:@"SOME_BOOLEAN_KEY"]; // Remove previous value [BDNSdk setExtraValue:nil for:@"SOME_KEY_TO_REMOVE"]; // Get extras NSDictionary *extras = [BDNSdk extras]; ``` -------------------------------- ### Initialize Bidon SDK Source: https://docs.bidon.org/llms-full.txt Initializes the Bidon SDK within an Android MainActivity. It supports registering adapters, setting a custom base URL, and defining an initialization callback. ```kotlin BidonSdk .registerDefaultAdapters() .setBaseUrl("https://[YOUR_BIDON_SERVER_DOMAIN.com]") .setInitializationCallback { // Bidon is initialized and ready to work } .initialize( context = this@MainActivity, appKey = "APP_KEY", ) ``` -------------------------------- ### Initialize AdManager Source: https://docs.bidon.org/llms-full.txt Initializes the AdManager, which is necessary before displaying ads. It utilizes an instance-based approach and provides an event to confirm successful initialization. ```csharp AdManager.Instance.Init(); AdManager.Instance.OnInitializedEvent += () => Debug.Log("AdManager initialized"); ``` -------------------------------- ### MaxInterstitialAdProvider C# Implementation Source: https://docs.bidon.org/llms-full.txt This C# class, MaxInterstitialAdProvider, implements the IInterstitialAdProvider interface to handle interstitial ads using the MAX SDK. It manages ad loading, display, and callbacks for various ad events such as loading, failure, showing, and closing. It requires the Unity engine and the MAX SDK to be integrated. ```csharp // ReSharper disable CheckNamespace using System; using UnityEngine; public class MaxInterstitialAdProvider : IInterstitialAdProvider { public string Name => "max"; public event EventHandler OnAdLoaded; public event EventHandler OnAdLoadFailed; public event EventHandler OnAdShown; public event EventHandler OnAdShowFailed; public event EventHandler OnAdClosed; private string MaxInterstitialAdUnitId { get; } public MaxInterstitialAdProvider(string adUnitId) { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Constructor] MaxInterstitialAdProvider()") MaxInterstitialAdUnitId = adUnitId; SubscribeToInterstitialAdEvents(); } public void LoadInterstitialAd(double priceFloor = 0d) { Debug.Log($"[Ads] [MaxInterstitialAdProvider] [Method] LoadInterstitialAd(priceFloor: {priceFloor})") MaxSdk.LoadInterstitial(MaxInterstitialAdUnitId); } public void NotifyLoss(string winnerDemandId, double price) { Debug.Log($"[Ads] [MaxInterstitialAdProvider] [Method] NotifyLoss(winner: {winnerDemandId}, price: {price})") } public void NotifyWin() { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Method] NotifyWin()") } public void ShowInterstitialAd(string placementName) { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Method] ShowInterstitialAd()") MaxSdk.ShowInterstitial(MaxInterstitialAdUnitId, placementName); } private void SubscribeToInterstitialAdEvents() { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Method] SubscribeToInterstitialAdEvents()") MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnMaxInterstitialAdLoaded; MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnMaxInterstitialAdLoadFailed; MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnMaxInterstitialAdShown; MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnMaxInterstitialAdShowFailed; MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnMaxInterstitialAdClosed; } private void OnMaxInterstitialAdLoaded(string adUnitId, MaxSdkBase.AdInfo adInfo) { double price = AdHelper.GetRoundedPrice(adInfo.Revenue * 1000); Debug.Log($"[Ads] [MaxInterstitialAdProvider] [Callback] OnAdLoaded(price: {price})") OnAdLoaded?.Invoke(this, price); } private void OnMaxInterstitialAdLoadFailed(string adUnitId, MaxSdkBase.ErrorInfo errorInfo) { Debug.Log($"[Ads] [MaxInterstitialAdProvider] [Callback] OnAdLoadFailed(cause: {errorInfo.Code})") OnAdLoadFailed?.Invoke(this, errorInfo.Code.ToString()); } private void OnMaxInterstitialAdShown(string adUnitId, MaxSdkBase.AdInfo adInfo) { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Callback] OnAdShown()") OnAdShown?.Invoke(this, EventArgs.Empty); } private void OnMaxInterstitialAdShowFailed(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo) { Debug.Log($"[Ads] [MaxInterstitialAdProvider] [Callback] OnAdShowFailed(cause: {errorInfo.Code})") OnAdShowFailed?.Invoke(this, errorInfo.Code.ToString()); } private void OnMaxInterstitialAdClosed(string adUnitId, MaxSdkBase.AdInfo adInfo) { Debug.Log("[Ads] [MaxInterstitialAdProvider] [Callback] OnAdClosed()") OnAdClosed?.Invoke(this, EventArgs.Empty); } } ``` -------------------------------- ### Initialize Bidon SDK Source: https://docs.bidon.org/llms-full.txt Initializes the Bidon SDK in your Android application, sets the server URL, and registers adapters. ```APIDOC ## SDK Initialization ### Description Initializes the Bidon SDK within the MainActivity. This is required before any ad operations. ### Method Kotlin SDK Method ### Parameters - **context** (Activity) - Required - The current activity context. - **appKey** (String) - Required - The unique key from the Bidon dashboard. ### Request Example ```kotlin BidonSdk .setBaseUrl("https://[YOUR_BIDON_SERVER_DOMAIN.com]") .initialize(context = this@MainActivity, appKey = "APP_KEY") ``` ``` -------------------------------- ### Manage Ad Provider Lifecycle and Events in C# Source: https://docs.bidon.org/llms-full.txt This snippet demonstrates how to handle ad provider callbacks including loading, showing, and closing events. It implements logic to switch between providers based on eCPM and handles failures with retry mechanisms. ```csharp private async void LoadFirstAdProviderAfterDelay(int time) { AdHelper.Log($"[PostBidRewardedAdController] [Method] LoadFirstAdProviderAfterDelay(time: {time})"); await Task.Delay(time * 1000); FirstAdProvider?.LoadRewardedAd(); } private void OnFirstAdProviderLoaded(object sender, double ecpm) { AdHelper.Log($"[PostBidRewardedAdController] [Callback] OnFirstAdProviderLoaded(ecpm: {ecpm})"); _firstAdProviderEcpm = ecpm; _isFirstAdProviderLoaded = true; _rewardedAdLoadRetryAttempt = 0; SecondAdProvider?.LoadRewardedAd(AdHelper.GetIncrementedPriceFloor(_firstAdProviderEcpm, _defaultPriceFloor, _strategy, _step)); } private void OnSecondAdProviderLoadFailed(object sender, string cause) { AdHelper.Log($"[PostBidRewardedAdController] [Callback] OnSecondAdProviderLoadFailed(cause: {cause})"); _secondAdProviderEcpm = 0d; _isSecondAdProviderLoaded = false; if (_isFirstAdProviderLoaded) return; _rewardedAdLoadRetryAttempt++; int retryDelay = (int)Math.Pow(2, Math.Min(6, _rewardedAdLoadRetryAttempt)); LoadFirstAdProviderAfterDelay(retryDelay); } ``` -------------------------------- ### Declare Bidon and LevelPlay SDK Dependencies in Gradle Source: https://docs.bidon.org/llms-full.txt Configure your project's build.gradle file to include the necessary Maven repositories for both Bidon and LevelPlay SDKs. Then, declare the core SDKs and their respective adapters in your module's dependencies. Ensure all required adapters are included for complete demand and optimal fill rates. ```kotlin repositories { maven { url = uri("https://android-sdk.is.com/") } // LevelPlay artifacts maven { url = uri("https://artifactory.bidon.org/bidon") } // Bidon artifacts } dependencies { // LevelPlay core implementation("com.unity3d.ads-mediation:mediation-sdk:8.10.0") // Include all required LevelPlay adapters (e.g., AdColony, Vungle, Unity) // Bidon core implementation("org.bidon:bidon-sdk:0.13.0") // Exclude Bidon adapters that you do not use in your application implementation("org.bidon:admob-adapter:+") implementation("org.bidon:amazon-adapter:+") implementation("org.bidon:applovin-adapter:+") implementation("org.bidon:bidmachine-adapter:+") implementation("org.bidon:bigoads-adapter:+") implementation("org.bidon:chartboost-adapter:+") implementation("org.bidon:dtexchange-adapter:+") implementation("org.bidon:gam-adapter:+") implementation("org.bidon:inmobi-adapter:+") implementation("org.bidon:meta-adapter:+") implementation("org.bidon:mintegral-adapter:+") implementation("org.bidon:mobilefuse-adapter:+") implementation("org.bidon:unityads-adapter:+") implementation("org.bidon:vkads-adapter:+") implementation("org.bidon:vungle-adapter:+") implementation("org.bidon:yandex-adapter:+") } ``` -------------------------------- ### LevelPlay Interstitial Ad Provider Implementation (C#) Source: https://docs.bidon.org/llms-full.txt This C# code implements the LevelPlayInterstitialAdProvider, handling the loading, showing, and event callbacks for LevelPlay interstitial ads. It includes methods for initialization, ad loading, ad display, and managing ad events like loading, failure, showing, and closing. Dependencies include Unity Services LevelPlay SDK. ```csharp using System; using Unity.Services.LevelPlay; public class LevelPlayInterstitialAdProvider : IInterstitialAdProvider { public string Name { get => "levelplay"; } public event EventHandler OnAdLoaded; public event EventHandler OnAdLoadFailed; public event EventHandler OnAdShown; public event EventHandler OnAdShowFailed; public event EventHandler OnAdClosed; public event EventHandler OnAdRevenueReceived; private string LevelPlayInterstitialAdUnitId { get; } private LevelPlayInterstitialAd InterstitialAd { get; set; } public LevelPlayInterstitialAdProvider(string adUnitId) { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Constructor] LevelPlayInterstitialAdProvider()") LevelPlayInterstitialAdUnitId = adUnitId; InstantiateInterstitialAd(); } public void LoadInterstitialAd(double priceFloor = 0d) { AdHelper.Log($"[LevelPlayInterstitialAdProvider] [Method] LoadInterstitialAd(priceFloor: {priceFloor})"); InterstitialAd?.LoadAd(); } public void NotifyLoss(string winnerDemandId, double ecpm) { AdHelper.Log($"[LevelPlayInterstitialAdProvider] [Method] NotifyLoss(winner: {winnerDemandId}, ecpm: {ecpm})"); InstantiateInterstitialAd(); } public void NotifyWin() { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Method] NotifyWin()") } public void ShowInterstitialAd(string placementName) { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Method] ShowInterstitialAd()") InterstitialAd?.ShowAd(placementName); } private void InstantiateInterstitialAd() { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Method] InstantiateInterstitialAd()") if (InterstitialAd != null) { UnsubscribeFromInterstitialAdEvents(InterstitialAd); InterstitialAd.DestroyAd(); } InterstitialAd = new LevelPlayInterstitialAd(LevelPlayInterstitialAdUnitId); SubscribeToInterstitialAdEvents(InterstitialAd); } private void SubscribeToInterstitialAdEvents(LevelPlayInterstitialAd ad) { if (ad == null) return; AdHelper.Log("[LevelPlayInterstitialAdProvider] [Method] SubscribeToInterstitialAdEvents()") ad.OnAdLoaded += OnLevelPlayInterstitialAdLoaded; ad.OnAdLoadFailed += OnLevelPlayInterstitialAdLoadFailed; ad.OnAdDisplayed += OnLevelPlayInterstitialAdDisplayed; ad.OnAdDisplayFailed += OnLevelPlayInterstitialAdDisplayFailed; ad.OnAdClosed += OnLevelPlayInterstitialAdClosed; } private void UnsubscribeFromInterstitialAdEvents(LevelPlayInterstitialAd ad) { if (ad == null) return; AdHelper.Log("[LevelPlayInterstitialAdProvider] [Method] UnsubscribeFromInterstitialAdEvents()") ad.OnAdLoaded -= OnLevelPlayInterstitialAdLoaded; ad.OnAdLoadFailed -= OnLevelPlayInterstitialAdLoadFailed; ad.OnAdDisplayed -= OnLevelPlayInterstitialAdDisplayed; ad.OnAdDisplayFailed -= OnLevelPlayInterstitialAdDisplayFailed; ad.OnAdClosed -= OnLevelPlayInterstitialAdClosed; } private void OnLevelPlayInterstitialAdLoaded(LevelPlayAdInfo adInfo) { double ecpm = AdHelper.GetRoundedEcpm((adInfo.Revenue ?? 0d) * 1000); AdHelper.Log($"[LevelPlayInterstitialAdProvider] [Callback] OnLevelPlayInterstitialAdLoaded(ecpm: {ecpm}). Revenue is {adInfo.Revenue}"); OnAdLoaded?.Invoke(this, ecpm); } private void OnLevelPlayInterstitialAdLoadFailed(LevelPlayAdError error) { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Callback] OnLevelPlayInterstitialAdLoadFailed()") OnAdLoadFailed?.Invoke(this, error.ToString()); } private void OnLevelPlayInterstitialAdDisplayed(LevelPlayAdInfo adInfo) { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Callback] OnLevelPlayInterstitialAdDisplayed()") OnAdShown?.Invoke(this, EventArgs.Empty); var info = new AdInfo { AdType = "Interstitial", AdUnitId = adInfo.AdUnitId, CurrencyCode = "USD", MediationId = Name, NetworkAdUnitId = adInfo.InstanceId, NetworkName = adInfo.AdNetwork, Revenue = adInfo.Revenue ?? 0d, RevenuePrecision = adInfo.Precision, }; OnAdRevenueReceived?.Invoke(this, new AdRevenueReceivedEventArgs(info)); } private void OnLevelPlayInterstitialAdDisplayFailed(LevelPlayAdDisplayInfoError infoError) { AdHelper.Log("[LevelPlayInterstitialAdProvider] [Callback] OnLevelPlayInterstitialAdDisplayFailed()") InstantiateInterstitialAd(); ``` -------------------------------- ### Initialize and Load Interstitial Ads in Kotlin Source: https://docs.bidon.org/llms-full.txt Shows the instantiation of an InterstitialAd object, setting up an InterstitialListener for callbacks, and triggering the load process. Like banners, these instances are single-use. ```kotlin val interstitial = InterstitialAd(auctionKey = "AUCTION_KEY") interstitial.setInterstitialListener(object : InterstitialListener { override fun onAdLoaded(ad: Ad, auctionInfo: AuctionInfo) {} override fun onAdLoadFailed(auctionInfo: AuctionInfo?, cause: BidonError) {} override fun onAdShowFailed(cause: BidonError) {} override fun onAdShown(ad: Ad) {} override fun onAdClicked(ad: Ad) {} override fun onAdClosed(ad: Ad) {} override fun onAdExpired(ad: Ad) {} override fun onRevenuePaid(ad: Ad, adValue: AdValue) {} }) interstitial.loadAd(activity = activity, pricefloor = pricefloor) ``` -------------------------------- ### AdHelper Class for Price Calculations (C#) Source: https://docs.bidon.org/llms-full.txt Provides utility methods and properties for ad-related price calculations, including rounding prices and defining threshold and price floor values for rewarded and interstitial ads. Uses C# static properties and methods. ```csharp // ReSharper disable CheckNamespace using System; public static class AdHelper { public static double GetRoundedPrice(double price) => Math.Round(price, 10); public static double RewardedAdThreshold { get; set; } = 1.2d; public static double InterstitialAdThreshold { get; set; } = 0.01d; public static double RewardedAdPriceFloor => RewardedAdThreshold - 0.01d; public static double InterstitialAdPriceFloor => InterstitialAdThreshold - 0.01d; } ``` -------------------------------- ### Add Bidon SDK and Ad Network Adapters to Android Project Source: https://docs.bidon.org/llms-full.txt This code demonstrates how to add the core Bidon SDK and various ad network adapters to your Android application's `build.gradle.kts` file. It includes the main SDK library and a comprehensive list of adapters for different demand sources. ```kotlin dependencies { // Bidon SDK Library implementation("org.bidon:bidon-sdk:${androidVersion}") // Available Demand Sources (AdNetworks) implementation("org.bidon:admob-adapter:+") implementation("org.bidon:amazon-adapter:+") implementation("org.bidon:applovin-adapter:+") implementation("org.bidon:bidmachine-adapter:+") implementation("org.bidon:bigoads-adapter:+") implementation("org.bidon:chartboost-adapter:+") implementation("org.bidon:dtexchange-adapter:+") implementation("org.bidon:gam-adapter:+") implementation("org.bidon:inmobi-adapter:+") implementation("org.bidon:ironsource-adapter:+") implementation("org.bidon:meta-adapter:+") implementation("org.bidon:mintegral-adapter:+") implementation("org.bidon:mobilefuse-adapter:+") implementation("org.bidon:moloco-adapter:+") implementation("org.bidon:startio-adapter:+") implementation("org.bidon:taurusx-adapter:+") implementation("org.bidon:unityads-adapter:+") implementation("org.bidon:vkads-adapter:+") implementation("org.bidon:vungle-adapter:+") implementation("org.bidon:yandex-adapter:+") } ```