com.puzzlescapegames.admob_native 1.0.10 → 1.0.12

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.
@@ -0,0 +1,70 @@
1
+ using GoogleMobileAds.Api;
2
+ using System;
3
+ using UnityEngine;
4
+
5
+ namespace PuzzlescapeGames.AdMobNative
6
+ {
7
+ public sealed class InterstitialAdMob
8
+ {
9
+ private string _adUnitId;
10
+ private InterstitialAd _interstitialAd;
11
+
12
+ public InterstitialAdMob( string adUnitId = null )
13
+ {
14
+ _adUnitId = adUnitId;
15
+
16
+ if ( _adUnitId == null || string.IsNullOrEmpty( _adUnitId ) )
17
+ {
18
+ #if UNITY_ANDROID
19
+ _adUnitId = "ca-app-pub-3940256099942544/1033173712";
20
+ #elif UNITY_IPHONE
21
+ _adUnitId = "ca-app-pub-3940256099942544/4411468910";
22
+ #else
23
+ _adUnitId = "unused";
24
+ #endif
25
+ Debug.LogWarning( "[Native] AdMob Native Interstitial ad unit id is not set. Using default: " + _adUnitId );
26
+ }
27
+ }
28
+
29
+ public void LoadAd( Action< bool > callback = null )
30
+ {
31
+ DestroyAd();
32
+
33
+ Debug.Log( "[Native] AdMob Loading interstitial ad." );
34
+
35
+ // Create our request used to load the ad.
36
+ var adRequest = new AdRequest();
37
+
38
+ InterstitialAd.Load( _adUnitId, adRequest, ( InterstitialAd ad, LoadAdError error ) =>
39
+ {
40
+ if ( error != null )
41
+ {
42
+ callback?.Invoke( false );
43
+ return;
44
+ }
45
+
46
+ _interstitialAd = ad;
47
+
48
+ callback?.Invoke( true );
49
+ } );
50
+ }
51
+
52
+ public void ShowAd()
53
+ {
54
+ if (_interstitialAd != null && _interstitialAd.CanShowAd())
55
+ {
56
+ Debug.Log( "[Native] AdMob Showing interstitial ad." );
57
+
58
+ _interstitialAd.Show();
59
+ }
60
+ }
61
+
62
+ public void DestroyAd()
63
+ {
64
+ if ( _interstitialAd != null )
65
+ {
66
+ _interstitialAd.Destroy();
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: b32f381fe8724e7e8e11fc2eefe619d0
3
+ timeCreated: 1771920400
@@ -33,6 +33,7 @@ namespace PuzzlescapeGames.AdMobNative
33
33
  #else
34
34
  _adUnitId = "unused";
35
35
  #endif
36
+ Debug.LogWarning( "[Native] AdMob Native Overlay ad unit id is not set. Using default: " + _adUnitId );
36
37
  }
37
38
  }
38
39
 
@@ -1,3 +1,3 @@
1
1
  {
2
- "name": "Puzzlescape.AdMov"
2
+ "name": "Puzzlescape.AdMob"
3
3
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "com.puzzlescapegames.admob_native",
3
3
  "displayName" : "Puzzlescape Games AdMob Native",
4
- "version" : "1.0.10",
4
+ "version" : "1.0.12",
5
5
  "author" : "Puzzlescape Games",
6
6
  "description" : "AdMob Native.",
7
7
  "repository": {