From 3c2cb93319affbe50689c4b4a911bf939b144976 Mon Sep 17 00:00:00 2001 From: SCastanedaMunoz Date: Mon, 12 Jun 2023 13:57:17 -0500 Subject: [PATCH 1/2] Updating CHANGELOG.md for 4.3.0 --- CHANGELOG.md | 9 +++++++++ com.chartboost.mediation/CHANGELOG.md | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bdbec46..cd4f7405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Changelog All notable changes to this project will be documented in this file using the standards as defined at [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0). +### Version 4.3.0 *(2023-06-22)* +Improvements: +- Added support for Rewarded Interstitials. This is available via `ChartboostMediation.LoadFullscreenAd()` and supported only in the latest adapters. Please check each adapter's changelog to confirm which partners support rewarded interstitials. +- Added new `ChartboostMediationFullscreenAd` APIs which combine and improve the interstitial and rewarded ad APIs. Previous interstitial and rewarded ad APIs are now deprecated. +- Added `LineItemName` and `LineItemId` to `BidInfo`. + +Bug Fixes: +- Added newly released networks into partner killswitch enum. + ## Version 4.2.3 *(2023-05-18)* Bug Fixes: - Fixed an issue with Unity-iOS Rewarded Ads hanging onto the ad instances for too long, potentially causing duplicate callback events. diff --git a/com.chartboost.mediation/CHANGELOG.md b/com.chartboost.mediation/CHANGELOG.md index 1bdbec46..cd4f7405 100644 --- a/com.chartboost.mediation/CHANGELOG.md +++ b/com.chartboost.mediation/CHANGELOG.md @@ -1,6 +1,15 @@ # Changelog All notable changes to this project will be documented in this file using the standards as defined at [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0). +### Version 4.3.0 *(2023-06-22)* +Improvements: +- Added support for Rewarded Interstitials. This is available via `ChartboostMediation.LoadFullscreenAd()` and supported only in the latest adapters. Please check each adapter's changelog to confirm which partners support rewarded interstitials. +- Added new `ChartboostMediationFullscreenAd` APIs which combine and improve the interstitial and rewarded ad APIs. Previous interstitial and rewarded ad APIs are now deprecated. +- Added `LineItemName` and `LineItemId` to `BidInfo`. + +Bug Fixes: +- Added newly released networks into partner killswitch enum. + ## Version 4.2.3 *(2023-05-18)* Bug Fixes: - Fixed an issue with Unity-iOS Rewarded Ads hanging onto the ad instances for too long, potentially causing duplicate callback events. From cec19ec1bc2d17aa2181f55f16bcc41c4854bb81 Mon Sep 17 00:00:00 2001 From: SCastanedaMunoz Date: Mon, 12 Jun 2023 14:01:59 -0500 Subject: [PATCH 2/2] Updating Documentation for Fullscreen API Usage. --- .../Assets/Demo/Demo.cs | 44 +++------ .../integration/delegate-usage.md | 95 +------------------ .../Documentation/integration/loading-ads.md | 73 ++++++++++---- .../Documentation/integration/showing-ads.md | 45 ++++----- .../ChartboostMediationAndroid.Callbacks.cs | 4 +- ...artboostMediationFullscreenAdLoadResult.cs | 16 ++-- 6 files changed, 104 insertions(+), 173 deletions(-) diff --git a/com.chartboost.mediation.demo/Assets/Demo/Demo.cs b/com.chartboost.mediation.demo/Assets/Demo/Demo.cs index eaa11233..9d58b354 100644 --- a/com.chartboost.mediation.demo/Assets/Demo/Demo.cs +++ b/com.chartboost.mediation.demo/Assets/Demo/Demo.cs @@ -124,31 +124,17 @@ public async void OnLoadFullscreenClick() var loadRequest = new ChartboostMediationFullscreenAdLoadRequest(fullscreenPlacementInputField.text, keywords); - loadRequest.DidClick += fullscreenAd => { - Log($"DidClick Name: {fullscreenAd.Request.PlacementName}"); - }; - - loadRequest.DidClose += (fullscreenAd, error) => - { - Log(!error.HasValue - ? $"DidClose Name: {fullscreenAd.Request.PlacementName}" - : $"DidClose Name: {fullscreenAd.Request.PlacementName}, Code: {error?.code}, Message: {error?.message}"); - }; - - loadRequest.DidReward += fullscreenAd => - { - Log($"DidReward Name: {fullscreenAd.Request.PlacementName}"); - }; - - loadRequest.DidRecordImpression += fullscreenAd => - { - Log($"DidImpressionRecorded Name: {fullscreenAd.Request.PlacementName}"); - }; - - loadRequest.DidExpire += fullscreenAd => - { - Log($"DidExpire Name: {fullscreenAd.Request.PlacementName}"); - }; + loadRequest.DidClick += fullscreenAd => Log($"DidClick Name: {fullscreenAd.Request.PlacementName}"); + + loadRequest.DidClose += (fullscreenAd, error) => Log(!error.HasValue + ? $"DidClose Name: {fullscreenAd.Request.PlacementName}" + : $"DidClose Name: {fullscreenAd.Request.PlacementName}, Code: {error?.code}, Message: {error?.message}"); + + loadRequest.DidReward += fullscreenAd => Log($"DidReward Name: {fullscreenAd.Request.PlacementName}"); + + loadRequest.DidRecordImpression += fullscreenAd => Log($"DidImpressionRecorded Name: {fullscreenAd.Request.PlacementName}"); + + loadRequest.DidExpire += fullscreenAd => Log($"DidExpire Name: {fullscreenAd.Request.PlacementName}"); var loadResult = await ChartboostMediation.LoadFullscreenAd(loadRequest); @@ -161,7 +147,7 @@ public async void OnLoadFullscreenClick() } // Loaded but AD is null? - _fullscreenAd = loadResult.AD; + _fullscreenAd = loadResult.Ad; if (_fullscreenAd == null) { Log("Fullscreen Ad is null but no error was found???"); @@ -171,12 +157,12 @@ public async void OnLoadFullscreenClick() // DidLoad _fullscreenAd.CustomData = DefaultFullscreenAdCustomData; var customData = _fullscreenAd.CustomData; - var adRequestId = _fullscreenAd.LoadId; + var adLoadId = _fullscreenAd.LoadId; var bidInfo = _fullscreenAd.WinningBidInfo; var placementName = _fullscreenAd?.Request?.PlacementName; - var requestId = loadResult.RequestId; + var loadId = loadResult.LoadId; var metrics = loadResult.Metrics; - Log($"Fullscreen: {placementName} Loaded with: \nAdRequestId {adRequestId} \nRequestID {requestId} \nBidInfo: {JsonConvert.SerializeObject(bidInfo, Formatting.Indented)} \n Metrics:{JsonConvert.SerializeObject(metrics, Formatting.Indented)} \n Custom Data: {customData}"); + Log($"Fullscreen: {placementName} Loaded with: \nAdRequestId {adLoadId} \nRequestID {loadId} \nBidInfo: {JsonConvert.SerializeObject(bidInfo, Formatting.Indented)} \n Metrics:{JsonConvert.SerializeObject(metrics, Formatting.Indented)} \n Custom Data: {customData}"); } public void OnInvalidateFullscreenClick() diff --git a/com.chartboost.mediation/Documentation/integration/delegate-usage.md b/com.chartboost.mediation/Documentation/integration/delegate-usage.md index c060ada4..d934f01e 100644 --- a/com.chartboost.mediation/Documentation/integration/delegate-usage.md +++ b/com.chartboost.mediation/Documentation/integration/delegate-usage.md @@ -13,7 +13,7 @@ Chartboost Mediation's delegate methods allow you to exercise a greater degree o The Chartboost Mediation Unity SDK implements its delegate functionality using C# style delegates and events. Before using any of the delegate methods, you should first subscribe to the relevant SDK events in your MonoBehaviour as demonstrated: -### Subscribing Delegates +### Subscribing Static Delegates ```c# private void OnEnable() { // Start Delegate @@ -28,21 +28,6 @@ private void OnEnable() { // Error Handling Delegate ChartboostMediation.UnexpectedSystemErrorDidOccur += UnexpectedSystemErrorDidOccur; - // Interstitial Ad Delegates - ChartboostMediation.DidLoadInterstitial += DidLoadInterstitial; - ChartboostMediation.DidShowInterstitial += DidShowInterstitial; - ChartboostMediation.DidCloseInterstitial += DidCloseInterstitial; - ChartboostMediation.DidClickInterstitial += DidClickInterstitial; - ChartboostMediation.DidRecordImpressionInterstitial += DidRecordImpressionInterstitial; - - // Rewarded Ad Delegates - ChartboostMediation.DidLoadRewarded += DidLoadRewarded; - ChartboostMediation.DidShowRewarded += DidShowRewarded; - ChartboostMediation.DidCloseRewarded += DidCloseRewarded; - ChartboostMediation.DidReceiveReward += DidReceiveReward; - ChartboostMediation.DidClickRewarded += DidClickRewarded; - ChartboostMediation.DidRecordImpressionRewarded += DidRecordImpressionRewarded; - // Banner Ad Delegates ChartboostMediation.DidLoadBanner += DidLoadBanner; ChartboostMediation.DidClickBanner += DidClickBanner; @@ -77,21 +62,6 @@ private void OnDisable() { // Error Handling Delegate ChartboostMediation.UnexpectedSystemErrorDidOccur -= UnexpectedSystemErrorDidOccur; - // Interstitial Ad Delegates - ChartboostMediation.DidLoadInterstitial -= DidLoadInterstitial; - ChartboostMediation.DidShowInterstitial -= DidShowInterstitial; - ChartboostMediation.DidCloseInterstitial -= DidCloseInterstitial; - ChartboostMediation.DidClickInterstitial -= DidClickInterstitial; - ChartboostMediation.DidRecordImpressionInterstitial -= DidRecordImpressionInterstitial; - - // Rewarded Ad Delegates - ChartboostMediation.DidLoadRewarded -= DidLoadRewarded; - ChartboostMediation.DidShowRewarded -= DidShowRewarded; - ChartboostMediation.DidCloseRewarded -= DidCloseRewarded; - ChartboostMediation.DidReceiveReward -= DidReceiveReward; - ChartboostMediation.DidClickRewarded -= DidClickRewarded; - ChartboostMediation.DidRecordImpressionRewarded -= DidRecordImpressionRewarded; - // Banner Ad Delegates ChartboostMediation.DidLoadBanner -= DidLoadBanner; ChartboostMediation.DidClickBanner -= DidClickBanner; @@ -99,7 +69,7 @@ private void OnDisable() { } ``` -## Example Delegate Methods +### Subscribing Delegates ### Lifecycle Delegates ```c# @@ -130,67 +100,6 @@ private static void UnexpectedSystemErrorDidOccur(string error) } ``` -### Interstitial Ad Delegates -```c# -private void DidLoadInterstitial(string placementName, string loadId, BidInfo info, string error) -{ - Debug.Log($"DidLoadInterstitial {placementName}, Price: ${info.Price:F4}, Auction Id: {info.AuctionId}, Partner Id: {info.PartnerId}. {error}"); -} - -private void DidShowInterstitial(string placementName, string error) -{ - Debug.Log($"DidShowInterstitial {placementName}: {error}"); -} - -private void DidCloseInterstitial(string placementName, string error) -{ - Debug.Log($"DidCloseInterstitial {placementName}: {error}"); -} - -private void DidClickInterstitial(string placementName, string error) -{ - Debug.Log($"DidClickInterstitial {placementName}: {error}"); -} - -private void DidRecordImpressionInterstitial(string placementName, string error) -{ - Log($"DidRecordImpressionInterstitial {placementName}: {error}"); -} -``` - -### Rewarded Ad Delegates -```c# -private void DidLoadRewarded(string placementName, string loadId, BidInfo info, string error) -{ - Debug.Log($"DidLoadRewarded {placementName}, Price: ${info.Price:F4}, Auction Id: {info.AuctionId}, Partner Id: {info.PartnerId}. {error}"); -} - -private void DidShowRewarded(string placementName, string error) -{ - Debug.Log($"DidShowRewarded {placementName}: {error}"); -} - -private void DidCloseRewarded(string placementName, string error) -{ - Debug.Log($"DidCloseRewarded {placementName}: {error}"); -} - -private void DidClickRewarded(string placementName, string error) -{ - Debug.Log($"DidClickRewarded {placementName}: {error}"); -} - -private void DidReceiveReward(string placementName, string error) -{ - Debug.Log($"DidReceiveReward {placementName}: {error}"); -} - -private void DidRecordImpressionRewarded(string placementName, string error) -{ - Log($"DidRecordImpressionRewarded {placementName}: {error}"); -} -``` - ### Banner Ad delegates ```c# private void DidLoadBanner(string placementName, string loadId, BidInfo info, string error) diff --git a/com.chartboost.mediation/Documentation/integration/loading-ads.md b/com.chartboost.mediation/Documentation/integration/loading-ads.md index 1cd438df..fcafc045 100644 --- a/com.chartboost.mediation/Documentation/integration/loading-ads.md +++ b/com.chartboost.mediation/Documentation/integration/loading-ads.md @@ -1,31 +1,62 @@ # Loading Ads -## Creating Interstitial & Rewarded Ad Objects +## Loading Fullscreen Placements -To show an Interstitial or Rewarded Ads, first declare a variable to hold a reference to either the Interstitial or Rewarded Chartboost Mediation Ad. Supply the corresponding Placement Name you set up on your dashboard as the argument for each of these functions: +Since Chartboost Mediation Unity SDK 4.3.X we have deprecated the previous approach for loading fullscreen placements. A new Fullscreen API has been provided for `interstitials`, `rewarded videos` and `rewarded interstitials`, the new API makes use of C# asycn/await methods in order to await for load and show. A detailed example on the load logic for fullscreen placements can be found below: ```c# -// Interstitial Ad -private ChartboostMediationInterstitialAd _interstitialAd; - -// Rewarded Ad -private ChartboostMediationRewardedAd _rewardedAd; +// Strong reference to cached ad. +private IChartboostMediationFullscreenAd _fullscreenPlacement; ... -_interstitialAd = ChartboostMediation.GetInterstitialAd(PLACEMENT_INTERSTITIAL); -_rewardedAd = ChartboostMediation.GetRewardedAd(PLACEMENT_REWARDED); -``` +// keywords are optional +var keywords = new Dictionary { { "i12_keyword1", "i12_value1" } }; -## Loading Interstitial & Rewarded Ads +// Create a Fullscreen Ad Load Request +var loadRequest = new ChartboostMediationFullscreenAdLoadRequest(FULLSCREEN_PLACEMENT, keywords); -You will need to create an instance for each Placement Name you want to use. Finally, make the call to load the ad: +// Subscribing Instance Delegates +loadRequest.DidClick += fullscreenAd => Log($"DidClick Name: {fullscreenAd.Request.PlacementName}"); -```c# -_interstitialAd.Load(); -_rewardedAd.Load(); +loadRequest.DidClose += (fullscreenAd, error) => +Debug.Log(!error.HasValue ? $"DidClose Name: {fullscreenAd.Request.PlacementName}" +: $"DidClose with Error. Name: {fullscreenAd.Request.PlacementName}, Code: {error?.code}, Message: {error?.message}"); + +loadRequest.DidReward += fullscreenAd => Log($"DidReward Name: {fullscreenAd.Request.PlacementName}"); + +loadRequest.DidRecordImpression += fullscreenAd => Log($"DidImpressionRecorded Name: {fullscreenAd.Request.PlacementName}"); + +loadRequest.DidExpire += fullscreenAd => Log($"DidExpire Name: {fullscreenAd.Request.PlacementName}"); + +// Await on FullscreenAd Load +var loadResult = await ChartboostMediation.LoadFullscreenAd(loadRequest); + + +// Failed to Load +if (loadResult.Error.HasValue) +{ + var error = loadResult.Error.Value; + Debug.Log($"Fullscreen Failed to Load: {error.code}, message: {error.message}"); + return; +} + +// Successful Load! + +// Set strong reference to cached ad +_fullscreenPlacement = loadResult.AD; + +// Set custom data before show +_fullscreenPlacement.CustomData = "CUSTOM DATA HERE!"; + +var placementName = _fullscreenAd?.Request?.PlacementName; +Debug.Log($"Fullscreen Placement Loaded with PlacementName: {placementName}") ``` -You can implement delegates in your class to receive notifications about the success or failure of the ad loading process for both Interstitial and Rewarded formats. See section [Delegate Usage](delegate-usage.md) for more details. +> **Note** \ +> The new fullscreen API supports multiple placement loads of the same placement. It is important to properly manage your ad instances if you are planning to create an Ad Queue system. + +> **Warning** \ +> The new fullscreen API utilizes instance based callbacks to notify information regarding the advertisement life-cycle. You must take this into account when migrating from the old API static callbacks. ## Creating Banner Ad Objects @@ -100,9 +131,17 @@ You can implement delegates in your class to receive notifications about the suc Sometimes, you may need to clear loaded ads on existing placements to request another ad (i.e. for an in-house programmatic auction). To do this: ```c# +// Old API _interstitialAd.ClearLoaded(); _rewardedAd.ClearLoaded(); + _bannerAd.ClearLoaded(); ``` -The clearLoaded API returns a boolean and indicates if the ad object has been cleared and is ready for another load call. +```c# +/// New fullscreen API +_fullscreenPlacement.Invalidate(); +``` + +> **Warning** \ +> `Invalidate` behaves similarly like `ClearLoaded` and `Destroy`. As such, once called, you must free your ad reference to avoid any possible issues. diff --git a/com.chartboost.mediation/Documentation/integration/showing-ads.md b/com.chartboost.mediation/Documentation/integration/showing-ads.md index 30fb6f7a..7ff1a2de 100644 --- a/com.chartboost.mediation/Documentation/integration/showing-ads.md +++ b/com.chartboost.mediation/Documentation/integration/showing-ads.md @@ -1,23 +1,28 @@ # Showing Ads -## Showing Interstitial and Rewarded Ads +## Showing Fullscreen Placements -When you are ready to show a Rewarded or Interstitial ad, you can check that it is ready to show and then display it like so: +Fullscreen Placements must be first loaded, see section [Loading Ads](loading-ads.md) for more information. -### Interstitial Ad +Similar to the new load API. The new Fullscreen API utilizes C# async/await in order to request ad show. See below for details on implementation: ```c# -// Showing an Interstitial Ad -if (_interstitialAd.ReadyToShow()) - _interstitialAd.Show(); -``` +if (_fullscreenPlacement == null) + return; -### Rewarded Ad +var adShowResult = await _fullscreenPlacement.Show(); +var error = adShowResult.error; -```c# -//Showing a Rewarded Ad -if (_rewardedAd.ReadyToShow()){ - _rewardedAd.show(); +// Failed to Show +if (adShowResult.error.HasValue) +{ + Debug.Log($"Fullscreen Failed to Show with Value: {error.Value.code}, {error.Value.message}"); + return; +} + +// Successful Show +var metrics = adShowResult.metrics; +Debug.Log($"Fullscreen Ad Did Show: {JsonConvert.SerializeObject(metrics, Formatting.Indented)}"); ``` ## Showing Banner Ads @@ -25,22 +30,15 @@ Banners are now automatically shown after load, see section [Loading Ads](loadin ## Releasing Chartboost Mediation Ads -To clear resources used by Chartboost Mediation Ads, you can use the destroy method associated with the respective Ad you have used. +To clear resources used by Chartboost Mediation Ads, you can use the methods associated with the respective Ad you have used. ```c# private void OnDestroy() { - if (_interstitialAd != null) - { - _interstitialAd.ClearLoaded(); - _interstitialAd.Destroy(); - Debug.Log("Destroyed an existing interstitial"); - } - if (_rewardedAd != null) + if (_fullscreenPlacement != null) { - _rewardedAd.ClearLoaded(); - _rewardedAd.Destroy(); - Debug.Log("Destroyed an existing rewarded"); + _fullscreenPlacement.Invalidate(); + Debug.Log("Invalidated an existing fullscreen"); } if (_bannerAd != null) { @@ -49,5 +47,4 @@ private void OnDestroy() Debug.Log("Destroyed an existing banner"); } } - ``` diff --git a/com.chartboost.mediation/Runtime/Platforms/Android/ChartboostMediationAndroid.Callbacks.cs b/com.chartboost.mediation/Runtime/Platforms/Android/ChartboostMediationAndroid.Callbacks.cs index dbc9c2b7..4cef3d13 100644 --- a/com.chartboost.mediation/Runtime/Platforms/Android/ChartboostMediationAndroid.Callbacks.cs +++ b/com.chartboost.mediation/Runtime/Platforms/Android/ChartboostMediationAndroid.Callbacks.cs @@ -76,9 +76,9 @@ private void onAdLoaded(AndroidJavaObject result) var nativeAd = result.Get("ad"); var ad = new ChartboostMediationFullscreenAdAndroid(nativeAd, CacheManager.GetFullScreenAdLoadRequest(hashCode())); - var requestIdentifier = result.Get("loadId"); + var loadId = result.Get("loadId"); var metrics = result.Get("metrics").JsonObjectToMetrics(); - _complete(new ChartboostMediationFullscreenAdLoadResult(ad, requestIdentifier, metrics)); + _complete(new ChartboostMediationFullscreenAdLoadResult(ad, loadId, metrics)); }); } } diff --git a/com.chartboost.mediation/Runtime/Requests/ChartboostMediationFullscreenAdLoadResult.cs b/com.chartboost.mediation/Runtime/Requests/ChartboostMediationFullscreenAdLoadResult.cs index 396611bb..9063d389 100644 --- a/com.chartboost.mediation/Runtime/Requests/ChartboostMediationFullscreenAdLoadResult.cs +++ b/com.chartboost.mediation/Runtime/Requests/ChartboostMediationFullscreenAdLoadResult.cs @@ -10,13 +10,13 @@ public struct ChartboostMediationFullscreenAdLoadResult /// Constructor for successful loads /// /// - /// + /// /// /// - public ChartboostMediationFullscreenAdLoadResult(IChartboostMediationFullscreenAd ad, string requestId, Metrics? metrics, ChartboostMediationError? error = null) + public ChartboostMediationFullscreenAdLoadResult(IChartboostMediationFullscreenAd ad, string loadId, Metrics? metrics, ChartboostMediationError? error = null) { - AD = ad; - RequestId = requestId; + Ad = ad; + LoadId = loadId; Metrics = metrics; Error = error; } @@ -26,15 +26,15 @@ public ChartboostMediationFullscreenAdLoadResult(IChartboostMediationFullscreenA /// public ChartboostMediationFullscreenAdLoadResult(ChartboostMediationError error) { - AD = null; - RequestId = string.Empty; + Ad = null; + LoadId = string.Empty; Metrics = null; Error = error; } - public IChartboostMediationFullscreenAd? AD { get; } + public IChartboostMediationFullscreenAd? Ad { get; } - public string RequestId { get; } + public string LoadId { get; } public Metrics? Metrics { get; }