Skip to content

Commit 2f48f36

Browse files
Mobile Ads Developer Relationscopybara-github
authored andcommitted
Add PlacementId to InterstitialAd.
PiperOrigin-RevId: 802374779
1 parent 0f0ef22 commit 2f48f36

File tree

15 files changed

+148
-11
lines changed

15 files changed

+148
-11
lines changed

source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ public class InterstitialAd
5858
/// </summary>
5959
public event Action<AdError> OnAdFullScreenContentFailed;
6060

61+
/// <summary>
62+
/// A long integer provided by the AdMob UI for the configured placement.
63+
/// To ensure this placement ID is included in reporting, set a value before showing the ad.
64+
/// </summary>
65+
public long PlacementId
66+
{
67+
get
68+
{
69+
return _client != null ? _client.PlacementId : 0;
70+
}
71+
72+
set
73+
{
74+
if (_client != null)
75+
{
76+
_client.PlacementId = value;
77+
}
78+
}
79+
}
80+
6181
protected internal IInterstitialClient _client;
6282
protected internal bool _canShowAd;
6383

source/plugin/Assets/GoogleMobileAds/Common/IInterstitialClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public interface IInterstitialClient
3838
// Ad event fired when an ad has been clicked.
3939
event Action OnAdClicked;
4040

41+
// A long integer provided by the AdMob UI for the configured placement.
42+
long PlacementId { get; set; }
43+
4144
// Creates an interstitial ad.
4245
void CreateInterstitialAd();
4346

source/plugin/Assets/GoogleMobileAds/Platforms/Android/AdManagerInterstitialClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class AdManagerInterstitialClient : AndroidJavaProxy, IAdManagerInterstit
4141

4242
public event Action OnAdClicked;
4343

44+
// Placement ID is not supported for AdManagerInterstitialAd.
45+
public long PlacementId { get; set; }
46+
4447
private AndroidJavaObject _androidAdmanagerInterstitialAd;
4548

4649
public AdManagerInterstitialClient() :

source/plugin/Assets/GoogleMobileAds/Platforms/Android/InterstitialClient.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ public InterstitialClient() : base(Utils.UnityInterstitialAdCallbackClassName)
4949

5050
public event Action OnAdClicked;
5151

52+
// A long integer provided by the AdMob UI for the configured placement.
53+
public long PlacementId
54+
{
55+
get
56+
{
57+
return this.androidInterstitialAd.Call<long>("getPlacementId");
58+
}
59+
set
60+
{
61+
this.androidInterstitialAd.Call("setPlacementId", value);
62+
}
63+
}
64+
5265
#region IGoogleMobileAdsInterstitialClient implementation
5366

5467
// Creates an interstitial ad.

source/plugin/Assets/GoogleMobileAds/Platforms/Unity/AdManagerInterstitialClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public class AdManagerInterstitialClient : InterstitialClient, IAdManagerInterst
2626

2727
#if GMA_PREVIEW_FEATURES
2828

29+
// Placement ID is not supported for AdManagerInterstitialAd.
30+
public new long PlacementId { get; set; }
31+
2932
public IAdManagerInterstitialClient PollAdManagerAd(string adUnitId)
3033
{
3134
Debug.Log("Preloaded ads are not supported on the Unity editor platform.");

source/plugin/Assets/GoogleMobileAds/Platforms/Unity/InterstitialClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class InterstitialClient : BaseAdClient, IInterstitialClient
4141

4242
public event Action OnAdClicked;
4343

44+
// A long integer provided by the AdMob UI for the configured placement.
45+
public long PlacementId { get; set; }
46+
4447
private Dictionary<AdSize, string> prefabAds = new Dictionary<AdSize, string>() {
4548
{new AdSize (768,1024), "PlaceholderAds/Interstitials/768x1024" },
4649
{new AdSize (1024,768), "PlaceholderAds/Interstitials/1024x768"}

source/plugin/Assets/GoogleMobileAds/Platforms/iOS/AdManagerInterstitialClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ internal delegate void GADUInterstitialAdDidRecordImpressionCallback(
8181

8282
public event Action OnAdClicked;
8383

84+
// Placement ID is not supported for AdManagerInterstitialAd.
85+
public long PlacementId { get; set; }
86+
8487
private IntPtr _interstitialClientPtr;
8588

8689
private IntPtr _interstitialPtr;

source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,14 @@ internal static extern void GADUInterstitialPreloadedAdWithAdUnitID(IntPtr inter
621621
internal static extern IntPtr GADULoadInterstitialAd(IntPtr interstitialAd, string adUnitID,
622622
IntPtr request);
623623

624-
[DllImport("__Internal")]
625-
internal static extern string GADUGetInterstitialAdUnitID(IntPtr interstitialAd);
624+
[DllImport("__Internal")]
625+
internal static extern string GADUGetInterstitialAdUnitID(IntPtr interstitialAd);
626+
627+
[DllImport("__Internal")]
628+
internal static extern long GADUGetInterstitialAdPlacementID(IntPtr interstitialAd);
629+
630+
[DllImport("__Internal")]
631+
internal static extern void GADUSetInterstitialAdPlacementID(IntPtr interstitialAd, long placementId);
626632

627633
[DllImport("__Internal")]
628634
internal static extern void GADUSetInterstitialCallbacks(

source/plugin/Assets/GoogleMobileAds/Platforms/iOS/InterstitialClient.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ internal delegate void GADUInterstitialPaidEventCallback(
6969

7070
public event Action OnAdClicked;
7171

72+
// A long integer provided by the AdMob UI for the configured placement.
73+
public long PlacementId
74+
{
75+
get
76+
{
77+
return Externs.GADUGetInterstitialAdPlacementID(InterstitialPtr);
78+
}
79+
set
80+
{
81+
Externs.GADUSetInterstitialAdPlacementID(InterstitialPtr, value);
82+
}
83+
}
84+
7285
// This property should be used when setting the interstitialPtr.
7386
private IntPtr InterstitialPtr
7487
{

source/plugin/Assets/PlayServicesResolver.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)