com.puzzlescapegames.admob_native 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,8 +12,8 @@ MonoBehaviour:
|
|
|
12
12
|
m_Script: {fileID: 11500000, guid: a187246822bbb47529482707f3e0eff8, type: 3}
|
|
13
13
|
m_Name: GoogleMobileAdsSettings
|
|
14
14
|
m_EditorClassIdentifier:
|
|
15
|
-
adMobAndroidAppId:
|
|
16
|
-
adMobIOSAppId:
|
|
15
|
+
adMobAndroidAppId: ca-app-pub-3940256099942544/2247696110
|
|
16
|
+
adMobIOSAppId: ca-app-pub-3940256099942544/3986624511
|
|
17
17
|
enableKotlinXCoroutinesPackagingOption: 1
|
|
18
18
|
enableGradleBuildPreProcessor: 1
|
|
19
19
|
disableOptimizeInitialization: 0
|
package/Runtime/NativeAdMob.cs
CHANGED
|
@@ -6,18 +6,36 @@ namespace PuzzlescapeGames.AdMobNative
|
|
|
6
6
|
{
|
|
7
7
|
public sealed class NativeAdMob
|
|
8
8
|
{
|
|
9
|
+
public event Action< AdValue > OnAdPaid;
|
|
10
|
+
public event Action OnAdClicked;
|
|
11
|
+
public event Action OnAdImpressionRecorded;
|
|
12
|
+
public event Action OnAdFullScreenContentOpened;
|
|
13
|
+
public event Action OnAdFullScreenContentClosed;
|
|
14
|
+
|
|
15
|
+
public event Action OnShowingChanged;
|
|
16
|
+
|
|
17
|
+
public bool IsShowing { get; private set; }
|
|
18
|
+
public bool IsReady => _nativeOverlayAd != null;
|
|
19
|
+
|
|
20
|
+
private string _adUnitId;
|
|
21
|
+
private NativeOverlayAd _nativeOverlayAd;
|
|
22
|
+
|
|
23
|
+
public NativeAdMob( string adUnitId = null )
|
|
24
|
+
{
|
|
25
|
+
_adUnitId = adUnitId;
|
|
26
|
+
|
|
27
|
+
if ( _adUnitId == null || string.IsNullOrEmpty( _adUnitId ) )
|
|
28
|
+
{
|
|
9
29
|
#if UNITY_ANDROID
|
|
10
|
-
|
|
30
|
+
_adUnitId = "ca-app-pub-3940256099942544/2247696110";
|
|
11
31
|
#elif UNITY_IPHONE
|
|
12
|
-
|
|
32
|
+
_adUnitId = "ca-app-pub-3940256099942544/3986624511";
|
|
13
33
|
#else
|
|
14
|
-
|
|
34
|
+
_adUnitId = "unused";
|
|
15
35
|
#endif
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
}
|
|
37
|
+
}
|
|
18
38
|
|
|
19
|
-
private NativeOverlayAd _nativeOverlayAd;
|
|
20
|
-
|
|
21
39
|
public void LoadAd( Action callback = null )
|
|
22
40
|
{
|
|
23
41
|
DestroyAd();
|
|
@@ -48,6 +66,11 @@ namespace PuzzlescapeGames.AdMobNative
|
|
|
48
66
|
// The operation completed successfully.
|
|
49
67
|
Debug.Log( "[Native] AdMob Native Overlay ad loaded with response : " + ad.GetResponseInfo() );
|
|
50
68
|
_nativeOverlayAd = ad;
|
|
69
|
+
_nativeOverlayAd.OnAdPaid += AdPaidHandler;
|
|
70
|
+
_nativeOverlayAd.OnAdClicked += AdClickedHandler;
|
|
71
|
+
_nativeOverlayAd.OnAdImpressionRecorded += AdImpressionRecordedHandler;
|
|
72
|
+
_nativeOverlayAd.OnAdFullScreenContentOpened += AdFullScreenContentOpenedHandler;
|
|
73
|
+
_nativeOverlayAd.OnAdFullScreenContentClosed += AdFullScreenContentClosedHandler;
|
|
51
74
|
|
|
52
75
|
callback?.Invoke();
|
|
53
76
|
} );
|
|
@@ -69,6 +92,8 @@ namespace PuzzlescapeGames.AdMobNative
|
|
|
69
92
|
{
|
|
70
93
|
Debug.Log( "[Native] AdMob Showing Native Overlay ad." );
|
|
71
94
|
_nativeOverlayAd.Show();
|
|
95
|
+
|
|
96
|
+
IsShowing = true;
|
|
72
97
|
}
|
|
73
98
|
}
|
|
74
99
|
|
|
@@ -78,6 +103,8 @@ namespace PuzzlescapeGames.AdMobNative
|
|
|
78
103
|
{
|
|
79
104
|
Debug.Log( "[Native] AdMob Hiding Native Overlay ad." );
|
|
80
105
|
_nativeOverlayAd.Hide();
|
|
106
|
+
|
|
107
|
+
IsShowing = false;
|
|
81
108
|
}
|
|
82
109
|
}
|
|
83
110
|
|
|
@@ -85,10 +112,42 @@ namespace PuzzlescapeGames.AdMobNative
|
|
|
85
112
|
{
|
|
86
113
|
if ( _nativeOverlayAd != null )
|
|
87
114
|
{
|
|
115
|
+
IsShowing = false;
|
|
116
|
+
|
|
88
117
|
Debug.Log( "[Native] AdMob Destroying native overlay ad." );
|
|
118
|
+
_nativeOverlayAd.OnAdPaid -= AdPaidHandler;
|
|
119
|
+
_nativeOverlayAd.OnAdClicked -= AdClickedHandler;
|
|
120
|
+
_nativeOverlayAd.OnAdImpressionRecorded -= AdImpressionRecordedHandler;
|
|
121
|
+
_nativeOverlayAd.OnAdFullScreenContentOpened -= AdFullScreenContentOpenedHandler;
|
|
122
|
+
_nativeOverlayAd.OnAdFullScreenContentClosed -= AdFullScreenContentClosedHandler;
|
|
89
123
|
_nativeOverlayAd.Destroy();
|
|
90
124
|
_nativeOverlayAd = null;
|
|
91
125
|
}
|
|
92
126
|
}
|
|
127
|
+
|
|
128
|
+
private void AdPaidHandler( AdValue e )
|
|
129
|
+
{
|
|
130
|
+
OnAdPaid?.Invoke( e );
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private void AdClickedHandler()
|
|
134
|
+
{
|
|
135
|
+
OnAdClicked?.Invoke();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private void AdImpressionRecordedHandler()
|
|
139
|
+
{
|
|
140
|
+
OnAdImpressionRecorded?.Invoke();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private void AdFullScreenContentOpenedHandler()
|
|
144
|
+
{
|
|
145
|
+
OnAdFullScreenContentOpened?.Invoke();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private void AdFullScreenContentClosedHandler()
|
|
149
|
+
{
|
|
150
|
+
OnAdFullScreenContentClosed?.Invoke();
|
|
151
|
+
}
|
|
93
152
|
}
|
|
94
153
|
}
|