Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static Dictionary<string, PreloadConfiguration> GetConfigurations()
/// Returns a preloaded ad and removes it from the cache.
/// </summary>
/// <param name="preloadId">
/// The ad's preload ID.
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The preloaded ad for the given preload ID, or null if no ad is available.
Expand All @@ -146,6 +146,26 @@ public static InterstitialAd DequeueAd(string preloadId)
return new InterstitialAd(client);
}

/// <summary>
/// Returns the ResponseInfo of a preloaded ad for the given preload ID without
/// dequeuing it, or null if no ad is available.
/// </summary>
/// <param name="preloadId">
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
/// </returns>
public static ResponseInfo PeekAdResponseInfo(string preloadId)
{
var responseInfoClient = _client.PeekAdResponseInfo(preloadId);
if (responseInfoClient == null)
{
return null;
}
return new ResponseInfo(responseInfoClient);
}

/// <summary>
/// Get the number of ads available for the given preload ID.
/// </summary>
Expand Down
22 changes: 21 additions & 1 deletion source/plugin/Assets/GoogleMobileAds/Api/RewardedAdPreloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static Dictionary<string, PreloadConfiguration> GetConfigurations()
/// Returns a preloaded ad and removes it from the cache.
/// </summary>
/// <param name="preloadId">
/// The ad's preload ID.
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The preloaded ad for the given preload ID, or null if no ad is available.
Expand All @@ -145,6 +145,26 @@ public static RewardedAd DequeueAd(string preloadId)
return new RewardedAd(client);
}

/// <summary>
/// Returns the ResponseInfo of a preloaded ad for the given preload ID without
/// dequeuing it, or null if no ad is available.
/// </summary>
/// <param name="preloadId">
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
/// </returns>
public static ResponseInfo PeekAdResponseInfo(string preloadId)
{
var responseInfoClient = _client.PeekAdResponseInfo(preloadId);
if (responseInfoClient == null)
{
return null;
}
return new ResponseInfo(responseInfoClient);
}

/// <summary>
/// Get the number of ads available for the given preload ID.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
/// Returns a preloaded ad and removes it from the cache.
/// </summary>
/// <param name="preloadId">
/// The ad's preload ID.
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The preloaded ad for the given preload ID, or null if no ad is available.
Expand All @@ -76,6 +76,18 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
/// </remarks>
IInterstitialClient DequeueAd(string preloadId);

/// <summary>
/// Returns the ResponseInfo of an ad available for the given preload ID without
/// dequeuing it, or null if no ad is available.
/// </summary>
/// <param name="preloadId">
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
/// </returns>
IResponseInfoClient PeekAdResponseInfo(string preloadId);

/// <summary>
/// Get the number of ads available for the given preload ID.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
/// Returns a preloaded ad and removes it from the cache.
/// </summary>
/// <param name="preloadId">
/// The ad's preload ID.
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The preloaded ad for the given preload ID, or null if no ad is available.
Expand All @@ -76,6 +76,18 @@ bool Preload(string preloadId, PreloadConfiguration preloadConfiguration,
/// </remarks>
IRewardedAdClient DequeueAd(string preloadId);

/// <summary>
/// Returns the ResponseInfo of an ad available for the given preload ID without
/// dequeuing it, or null if no ad is available.
/// </summary>
/// <param name="preloadId">
/// A string identifier used to preload the ads for that configuration.
/// </param>
/// <returns>
/// The ResponseInfo of the preloaded ad for the given preload ID, or null if no ad is available.
/// </returns>
IResponseInfoClient PeekAdResponseInfo(string preloadId);

/// <summary>
/// Get the number of ads available for the given preload ID.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public IInterstitialClient DequeueAd(string preloadId)
return interstitialClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
UnityEngine.Debug.LogError(
"PeekAdResponseInfo API is not available on the Legacy version of Google Mobile Ads Android SDK.");
return null;
}

public int GetNumAdsAvailable(string preloadId)
{
return _unityInterstitialPreloader.Call<int>("getNumAdsAvailable", preloadId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public IInterstitialClient DequeueAd(string preloadId) {
return interstitialAdClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId) {
// TODO: Implement Android Peek API
return null;
}

public int GetNumAdsAvailable(string preloadId) {
return _unityInterstitialAdPreloader.Call<int>("getNumAdsAvailable", preloadId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public IRewardedAdClient DequeueAd(string preloadId) {
return rewardedAdClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId) {
// TODO: Implement Android Peek API
return null;
}

public int GetNumAdsAvailable(string preloadId) {
return _unityRewardedAdPreloader.Call<int>("getNumAdsAvailable", preloadId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public IRewardedAdClient DequeueAd(string preloadId)
return rewardedAdClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
UnityEngine.Debug.LogError(
"PeekAdResponseInfo API is not available on the Legacy version of Google Mobile Ads Android SDK.");
return null;
}

public int GetNumAdsAvailable(string preloadId)
{
return _unityRewardedAdPreloader.Call<int>("getNumAdsAvailable", preloadId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ public IInterstitialClient DequeueAd(string preloadId)
return null;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
Queue<InterstitialClient> queue;
if (_bufferedAds.TryGetValue(preloadId, out queue) && queue.Count > 0)
{
InterstitialClient adClient = queue.Peek();
return adClient.GetResponseInfoClient();
}
return null;
}

public int GetNumAdsAvailable(string preloadId)
{
Queue<InterstitialClient> queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ public IRewardedAdClient DequeueAd(string preloadId)
return null;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
Queue<RewardedAdClient> queue;
if (_bufferedAds.TryGetValue(preloadId, out queue) && queue.Count > 0)
{
RewardedAdClient adClient = queue.Peek();
return adClient.GetResponseInfoClient();
}
return null;
}

public int GetNumAdsAvailable(string preloadId)
{
Queue<RewardedAdClient> queue;
Expand Down
8 changes: 8 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ internal static extern IntPtr GADURewardedAdPreloaderDequeueAd(IntPtr rewardedAd
string preloadId,
IntPtr appOpenAdClientPtr);

[DllImport("__Internal")]
internal static extern IntPtr GADURewardedAdPreloaderPeekAdResponseInfo(
IntPtr rewardedAdPreloader, string preloadId);

[DllImport("__Internal")]
internal static extern int GADURewardedAdPreloaderGetNumAdsAvailable(
IntPtr rewardedAdPreloader, string preloadId);
Expand Down Expand Up @@ -414,6 +418,10 @@ internal static extern bool GADUInterstitialAdPreloaderIsAdAvailable(
internal static extern IntPtr GADUInterstitialAdPreloaderDequeueAd(
IntPtr interstitialAdPreloader, string preloadId, IntPtr appOpenAdClientPtr);

[DllImport("__Internal")]
internal static extern IntPtr GADUInterstitialAdPreloaderPeekAdResponseInfo(
IntPtr interstitialAdPreloader, string preloadId);

[DllImport("__Internal")]
internal static extern int GADUInterstitialAdPreloaderGetNumAdsAvailable(
IntPtr interstitialAdPreloader, string preloadId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ public IInterstitialClient DequeueAd(string preloadId)
return interstitialAdClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
if (InterstitialAdPreloaderPtr == IntPtr.Zero)
{
return null;
}
var responseInfoPtr = Externs.GADUInterstitialAdPreloaderPeekAdResponseInfo(
InterstitialAdPreloaderPtr, preloadId);
if (responseInfoPtr == IntPtr.Zero)
{
return null;
}
return new ResponseInfoClient(responseInfoPtr);
}

public int GetNumAdsAvailable(string preloadId)
{
if (InterstitialAdPreloaderPtr == IntPtr.Zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ public IRewardedAdClient DequeueAd(string preloadId)
return rewardedAdClient;
}

public IResponseInfoClient PeekAdResponseInfo(string preloadId)
{
if (RewardedAdPreloaderPtr == IntPtr.Zero)
{
return null;
}
var responseInfoPtr = Externs.GADURewardedAdPreloaderPeekAdResponseInfo(
RewardedAdPreloaderPtr, preloadId);
if (responseInfoPtr == IntPtr.Zero)
{
return null;
}
return new ResponseInfoClient(responseInfoPtr);
}

public int GetNumAdsAvailable(string preloadId)
{
if (RewardedAdPreloaderPtr == IntPtr.Zero)
Expand Down
34 changes: 34 additions & 0 deletions source/plugin/Assets/Plugins/iOS/GADUInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,23 @@ GADUTypeRewardedAdRef GADURewardedAdPreloaderDequeueAd(
return nil;
}

GADUTypeResponseInfoRef GADURewardedAdPreloaderPeekAdResponseInfo(
GADUTypeRewardedAdPreloaderClientRef rewardedAdPreloader, const char *preloadId) {
GADURewardedAdPreloader *internalRewardedAdPreloader =
(__bridge GADURewardedAdPreloader *)rewardedAdPreloader;
if (!internalRewardedAdPreloader) {
return nil;
}
GADResponseInfo *responseInfo =
[internalRewardedAdPreloader adResponseInfoWithPreloadID:GADUStringFromUTF8String(preloadId)];
if (responseInfo) {
GADUObjectCache *cache = GADUObjectCache.sharedInstance;
cache[responseInfo.gadu_referenceKey] = responseInfo;
return (__bridge GADUTypeResponseInfoRef)responseInfo;
}
return nil;
}

unsigned long GADURewardedAdPreloaderGetNumAdsAvailable(
GADUTypeRewardedAdPreloaderClientRef rewardedAdPreloader, const char *preloadId) {
GADURewardedAdPreloader *internalRewardedAdPreloader =
Expand Down Expand Up @@ -1155,6 +1172,23 @@ GADUTypeInterstitialRef GADUInterstitialAdPreloaderDequeueAd(
return nil;
}

GADUTypeResponseInfoRef GADUInterstitialAdPreloaderPeekAdResponseInfo(
GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader, const char *preloadId) {
GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
(__bridge GADUInterstitialAdPreloader *)interstitialAdPreloader;
if (!internalInterstitialAdPreloader) {
return nil;
}
GADResponseInfo *responseInfo = [internalInterstitialAdPreloader
adResponseInfoWithPreloadID:GADUStringFromUTF8String(preloadId)];
if (responseInfo) {
GADUObjectCache *cache = GADUObjectCache.sharedInstance;
cache[responseInfo.gadu_referenceKey] = responseInfo;
return (__bridge GADUTypeResponseInfoRef)responseInfo;
}
return nil;
}

unsigned long GADUInterstitialAdPreloaderGetNumAdsAvailable(
GADUTypeInterstitialAdPreloaderClientRef interstitialAdPreloader, const char *preloadId) {
GADUInterstitialAdPreloader *internalInterstitialAdPreloader =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
interstitialAdClient:(_Nonnull GADUTypeInterstitialClientRef *_Nonnull)
interstitialAdClient;

/// Returns the response info of a preloaded interstitial ad for the given preload ID without
/// removing the ad from the queue. Returns nil if an ad is not available.
- (nullable GADResponseInfo *)adResponseInfoWithPreloadID:(nonnull NSString *)preloadID;

/// Returns the corresponding configuration for the given preload ID.
- (nullable GADUPreloadConfigurationV2 *)configurationWithPreloadID:(nonnull NSString *)preloadID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ - (nullable GADUInterstitial *)adWithPreloadID:(nonnull NSString *)preloadID
return nil;
}

- (nullable GADResponseInfo *)adResponseInfoWithPreloadID:(nonnull NSString *)preloadID {
return [GADInterstitialAdPreloader.sharedInstance adResponseInfoWithPreloadID:preloadID];
}

- (nullable GADUPreloadConfigurationV2 *)configurationWithPreloadID:(nonnull NSString *)preloadID {
GADPreloadConfigurationV2 *config =
[GADInterstitialAdPreloader.sharedInstance configurationWithPreloadID:preloadID];
Expand Down
3 changes: 3 additions & 0 deletions source/plugin/Assets/Plugins/iOS/GADURewardedAdPreloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
/// available.
- (nullable GADRewardedAd *)adWithPreloadID:(nonnull NSString *)preloadID rewardedAdClient:(_Nonnull GADUTypeRewardedAdClientRef *_Nonnull)rewardedAdClient;

/// Returns the responseInfo of a preloaded rewarded ad for the given preload ID.
- (nullable GADResponseInfo *)adResponseInfoWithPreloadID:(nonnull NSString *)preloadID;

/// Returns the corresponding configuration for the given preload ID.
- (nullable GADUPreloadConfigurationV2 *)configurationWithPreloadID:(nonnull NSString *)preloadID;

Expand Down
4 changes: 4 additions & 0 deletions source/plugin/Assets/Plugins/iOS/GADURewardedAdPreloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ - (nullable GADURewardedAd *)adWithPreloadID:(nonnull NSString *)preloadID rewar
return nil;
}

- (nullable GADResponseInfo *)adResponseInfoWithPreloadID:(nonnull NSString *)preloadID {
return [GADRewardedAdPreloader.sharedInstance adResponseInfoWithPreloadID:preloadID];
}

- (nullable GADUPreloadConfigurationV2 *)configurationWithPreloadID:(nonnull NSString *)preloadID {
GADPreloadConfigurationV2 *config = [GADRewardedAdPreloader.sharedInstance configurationWithPreloadID:preloadID];
if (!config) {
Expand Down