com.amanotes.gdk 0.2.37 → 0.2.38

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.38 - 2023-11-22]
4
+ - Improve Ads API
5
+ - Add Ad Quality
6
+
3
7
  ## [0.2.37 - 2023-11-21]
4
8
  - Improve GDK logs
5
9
  - Banner will not show when ad adapter is not ready
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -69,11 +69,23 @@ namespace Amanotes.Core
69
69
  public static IAdCallback OnAdResult(this IAdCallback ad, Action<bool> callback)
70
70
  {
71
71
  if (!MakeSureAdNotNull(ad)) return null;
72
- Ads.context.onResult -= callback;
73
- Ads.context.onResult += callback;
72
+ Ads.context.onAdResult -= callback;
73
+ Ads.context.onAdResult += callback;
74
74
  return ad;
75
75
  }
76
-
76
+
77
+ /// <summary>
78
+ /// Call right before the ad actually open (that means Ad has already been cached & available to show).
79
+ /// This callback will not be triggered in case Ad is not available or no internet
80
+ /// </summary>
81
+ public static IAdCallback OnBeforeAdOpen(this IAdCallback ad, Action callback)
82
+ {
83
+ if (!MakeSureAdNotNull(ad)) return null;
84
+ Ads.context.onBeforeAdOpen -= callback;
85
+ Ads.context.onBeforeAdOpen += callback;
86
+ return ad;
87
+ }
88
+
77
89
  private static bool MakeSureAdNotNull(IAdCallback ad)
78
90
  {
79
91
  bool isValid = (ad != null);
@@ -165,6 +177,8 @@ namespace Amanotes.Core
165
177
  internal static float _savedTimeScale = -1;
166
178
 
167
179
  internal static readonly AdsData localData = new AdsData().LoadJsonFromFile();
180
+
181
+ public static AdAdapterConfig adConfig => _adConfig;
168
182
  }
169
183
 
170
184
  public partial class Ads // Public
@@ -292,7 +306,22 @@ namespace Amanotes.Core
292
306
  else
293
307
  _adapter.rewardVideo.StopShowAd();
294
308
  }
295
-
309
+
310
+ /// <summary>
311
+ /// Capping for interstitial ad
312
+ /// - Time since last interstitial show success > interstitialCappingTime
313
+ /// - Time since last rewardedVideo show success > rewardVideoCappingTime (for interstitial)
314
+ /// </summary>
315
+ /// <param name="interstitialCappingTime"></param>
316
+ /// <param name="rewardedVideoCappingTime"></param>
317
+ /// <returns></returns>
318
+ public static bool IsCapped(float interstitialCappingTime = 0, float rewardedVideoCappingTime = 0)
319
+ {
320
+ bool interCapped = (interstitialCappingTime > 0) && TimeSinceLastInterstitialSucceed < interstitialCappingTime;
321
+ bool rewardCapped = (rewardedVideoCappingTime > 0) && TimeSinceLastVideoRewardSucceed < rewardedVideoCappingTime;
322
+ return interCapped || rewardCapped;
323
+ }
324
+
296
325
  public static int TimeSinceLastInterstitialSucceed => localData.TimeSinceLastShowSuccess(AdType.Interstitial);
297
326
  public static int TimeSinceLastVideoRewardSucceed => localData.TimeSinceLastShowSuccess(AdType.VideoReward);
298
327
  public static int TimeSinceLastAdSucceed => Math.Min(TimeSinceLastInterstitialSucceed, TimeSinceLastVideoRewardSucceed) ;
@@ -388,6 +417,7 @@ namespace Amanotes.Core.Internal
388
417
  public readonly Dictionary<string, object> userData;
389
418
  public AdCallback adCallback;
390
419
 
420
+ internal Action onBeforeAdOpen;
391
421
  internal Action onOpened;
392
422
  internal Action onRewardReceived;
393
423
  internal Action onClicked;
@@ -395,7 +425,7 @@ namespace Amanotes.Core.Internal
395
425
  internal Action onShowFailed;
396
426
  internal Action onClosed;
397
427
  internal Action<AdShowReadyStatus> onAdShowReadyStatus;
398
- internal Action<bool> onResult;
428
+ internal Action<bool> onAdResult;
399
429
 
400
430
  // Stats
401
431
  public float showCallAt;
@@ -638,8 +668,8 @@ namespace Amanotes.Core.Internal
638
668
  _showState = ShowAdsState.Showing;
639
669
  OnAdShowReadyStatus(true, AdShowReadyStatus.None);
640
670
 
641
- ShowAd();
642
671
  HandleBeforeAdShow();
672
+ ShowAd();
643
673
 
644
674
  ShowAdContext context = Ads.context;
645
675
  while (!context.potentiallyCompleted)
@@ -694,7 +724,7 @@ namespace Amanotes.Core.Internal
694
724
 
695
725
  // Extra callback
696
726
  Ads.context.showFinishAt = Time.realtimeSinceStartup;
697
- Ads.context.onResult?.Invoke(isSuccess);
727
+ Ads.context.onAdResult?.Invoke(isSuccess);
698
728
 
699
729
  var localData = Ads.localData;
700
730
  var stat = _isInterstitial ? localData.interstitial : localData.reward;
@@ -740,6 +770,7 @@ namespace Amanotes.Core.Internal
740
770
  Time.timeScale = 0;
741
771
  }
742
772
 
773
+ Ads.context.onBeforeAdOpen?.Invoke();
743
774
  Ads._adapter.HandleBeforeAdShow();
744
775
  }
745
776
 
package/Runtime/AmaGDK.cs CHANGED
@@ -14,7 +14,7 @@ namespace Amanotes.Core
14
14
  {
15
15
  public partial class AmaGDK : MonoBehaviour
16
16
  {
17
- public const string VERSION = "0.2.37";
17
+ public const string VERSION = "0.2.38";
18
18
 
19
19
  internal static AmaGDK _instance;
20
20
  internal static Status _status = Status.None;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.37",
3
+ "version": "0.2.38",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",