com.amanotes.gdk 0.2.25 → 0.2.26
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 +9 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/IronSourceAdapter_v7.2.6.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +144 -115
- package/Runtime/AmaGDK.Config.cs +6 -7
- package/Runtime/AmaGDK.Internal.cs +4 -4
- package/Runtime/AmaGDK.WebUtils.cs +29 -2
- package/Runtime/AmaGDK.cs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.26 - 2023-10-30]
|
|
4
|
+
- Add Ads event tracking
|
|
5
|
+
- Check real internet connection
|
|
6
|
+
- Add onResult callback
|
|
7
|
+
- AFAdRevenue
|
|
8
|
+
- Fix DebugLog config
|
|
9
|
+
- Move SkAdNetwork Fetch to GameObject context menu
|
|
10
|
+
- Remove IS event publisher from Ad module
|
|
11
|
+
|
|
3
12
|
## [0.2.25 - 2023-10-25]
|
|
4
13
|
Update Ads module:
|
|
5
14
|
- OnRewardedAvailable
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -12,8 +12,7 @@ namespace Amanotes.Core
|
|
|
12
12
|
{
|
|
13
13
|
public static IAdCallback OnAdOpened(this IAdCallback ad, Action callback)
|
|
14
14
|
{
|
|
15
|
-
if (ad
|
|
16
|
-
return null;
|
|
15
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
17
16
|
Ads.context.onOpened -= callback;
|
|
18
17
|
Ads.context.onOpened += callback;
|
|
19
18
|
return ad;
|
|
@@ -21,8 +20,7 @@ namespace Amanotes.Core
|
|
|
21
20
|
|
|
22
21
|
public static IAdCallback OnRewardReceived(this IAdCallback ad, Action callback)
|
|
23
22
|
{
|
|
24
|
-
if (ad
|
|
25
|
-
return null;
|
|
23
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
26
24
|
Ads.context.onRewardReceived -= callback;
|
|
27
25
|
Ads.context.onRewardReceived += callback;
|
|
28
26
|
return ad;
|
|
@@ -30,8 +28,7 @@ namespace Amanotes.Core
|
|
|
30
28
|
|
|
31
29
|
public static IAdCallback OnAdClicked(this IAdCallback ad, Action callback)
|
|
32
30
|
{
|
|
33
|
-
if (ad
|
|
34
|
-
return null;
|
|
31
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
35
32
|
Ads.context.onClicked -= callback;
|
|
36
33
|
Ads.context.onClicked += callback;
|
|
37
34
|
return ad;
|
|
@@ -39,8 +36,7 @@ namespace Amanotes.Core
|
|
|
39
36
|
|
|
40
37
|
public static IAdCallback OnAdShowFailed(this IAdCallback ad, Action callback)
|
|
41
38
|
{
|
|
42
|
-
if (ad
|
|
43
|
-
return null;
|
|
39
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
44
40
|
Ads.context.onShowFailed -= callback;
|
|
45
41
|
Ads.context.onShowFailed += callback;
|
|
46
42
|
return ad;
|
|
@@ -48,8 +44,7 @@ namespace Amanotes.Core
|
|
|
48
44
|
|
|
49
45
|
public static IAdCallback OnAdShowSuccess(this IAdCallback ad, Action callback)
|
|
50
46
|
{
|
|
51
|
-
if (ad
|
|
52
|
-
return null;
|
|
47
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
53
48
|
Ads.context.onShowSuccess -= callback;
|
|
54
49
|
Ads.context.onShowSuccess += callback;
|
|
55
50
|
return ad;
|
|
@@ -57,24 +52,28 @@ namespace Amanotes.Core
|
|
|
57
52
|
|
|
58
53
|
public static IAdCallback OnAdClosed(this IAdCallback ad, Action callback)
|
|
59
54
|
{
|
|
60
|
-
if (ad
|
|
61
|
-
return null;
|
|
55
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
62
56
|
Ads.context.onClosed -= callback;
|
|
63
57
|
Ads.context.onClosed += callback;
|
|
64
58
|
return ad;
|
|
65
59
|
}
|
|
60
|
+
|
|
61
|
+
public static IAdCallback OnAdResult(this IAdCallback ad, Action<AdResult> callback)
|
|
62
|
+
{
|
|
63
|
+
if (!MakeSureAdNotNull(ad)) return null;
|
|
64
|
+
Ads.context.onResult -= callback;
|
|
65
|
+
Ads.context.onResult += callback;
|
|
66
|
+
return ad;
|
|
67
|
+
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
private static bool MakeSureAdNotNull(IAdCallback ad)
|
|
68
70
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
void RewardedVideoComplete()
|
|
71
|
+
bool isValid = (ad != null);
|
|
72
|
+
if (!isValid)
|
|
72
73
|
{
|
|
73
|
-
|
|
74
|
+
LogWarning("Something wrong:: no AdShowContext");
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
Ads.context.onClosed += RewardedVideoComplete;
|
|
77
|
-
return ad;
|
|
76
|
+
return isValid;
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
|
|
@@ -122,6 +121,7 @@ namespace Amanotes.Core
|
|
|
122
121
|
public bool enableRewarded = true;
|
|
123
122
|
public bool enableBanner = true;
|
|
124
123
|
public bool autoMute = true;
|
|
124
|
+
public bool autoTimeScale = true;
|
|
125
125
|
|
|
126
126
|
[Header("EDITOR")]
|
|
127
127
|
[Range(0f, 1f)] public float rewardAdShowSuccessRate = 1;
|
|
@@ -135,8 +135,8 @@ namespace Amanotes.Core
|
|
|
135
135
|
internal static AdAdapterConfig _adConfig;
|
|
136
136
|
internal static IAdAdapter _adapter;
|
|
137
137
|
internal static float _savedVolume = -1;
|
|
138
|
+
internal static float _savedTimeScale = -1;
|
|
138
139
|
|
|
139
|
-
public static readonly AdListener Events = new AdListener();
|
|
140
140
|
internal static readonly AdsData localData = new AdsData().LoadJsonFromFile();
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -267,6 +267,9 @@ namespace Amanotes.Core.Internal
|
|
|
267
267
|
AdLogic interstitial { get; }
|
|
268
268
|
AdLogic rewardVideo { get; }
|
|
269
269
|
|
|
270
|
+
void HandleBeforeAdShow();
|
|
271
|
+
void HandleAfterAdShow();
|
|
272
|
+
|
|
270
273
|
void ShowBanner(BannerPosition position);
|
|
271
274
|
void HideBanner();
|
|
272
275
|
}
|
|
@@ -314,11 +317,21 @@ namespace Amanotes.Core.Internal
|
|
|
314
317
|
Banner
|
|
315
318
|
}
|
|
316
319
|
|
|
320
|
+
public enum AdResult
|
|
321
|
+
{
|
|
322
|
+
None,
|
|
323
|
+
Success,
|
|
324
|
+
WifiAndCarrierDataDisable,
|
|
325
|
+
NoInternetAccess,
|
|
326
|
+
RequestTimeOut,
|
|
327
|
+
AdapterReturnError
|
|
328
|
+
}
|
|
329
|
+
|
|
317
330
|
public class ShowAdContext : IAdCallback
|
|
318
331
|
{
|
|
319
332
|
public readonly AdType adType;
|
|
320
333
|
public readonly string placementName;
|
|
321
|
-
public
|
|
334
|
+
public AdResult result = AdResult.None;
|
|
322
335
|
public readonly Dictionary<string, object> userData;
|
|
323
336
|
public AdCallback adCallback;
|
|
324
337
|
|
|
@@ -328,6 +341,8 @@ namespace Amanotes.Core.Internal
|
|
|
328
341
|
internal Action onShowSuccess;
|
|
329
342
|
internal Action onShowFailed;
|
|
330
343
|
internal Action onClosed;
|
|
344
|
+
|
|
345
|
+
internal Action<AdResult> onResult;
|
|
331
346
|
|
|
332
347
|
// Stats
|
|
333
348
|
public float showCallAt;
|
|
@@ -363,17 +378,17 @@ namespace Amanotes.Core.Internal
|
|
|
363
378
|
{
|
|
364
379
|
if (_loadState != LoadAdsState.None)
|
|
365
380
|
{
|
|
366
|
-
LogWarning("StartLoadAd() --> Invalid state: " + _loadState);
|
|
381
|
+
LogWarning("[Ad] StartLoadAd() --> Invalid state: " + _loadState);
|
|
367
382
|
return;
|
|
368
383
|
}
|
|
369
384
|
|
|
370
|
-
Log("StartLoadAd");
|
|
385
|
+
Log("[Ad] StartLoadAd");
|
|
371
386
|
_loadRoutine = _instance.StartCoroutine(LoadAdRoutine());
|
|
372
387
|
}
|
|
373
388
|
|
|
374
389
|
public void StopLoadAd()
|
|
375
390
|
{
|
|
376
|
-
Log("StopLoadAd");
|
|
391
|
+
Log("[Ad] StopLoadAd");
|
|
377
392
|
if (_loadState == LoadAdsState.Requesting)
|
|
378
393
|
{
|
|
379
394
|
_loadState = LoadAdsState.None;
|
|
@@ -388,19 +403,31 @@ namespace Amanotes.Core.Internal
|
|
|
388
403
|
{
|
|
389
404
|
if (isAdReady)
|
|
390
405
|
{
|
|
406
|
+
Log("[Ad] LoadAdRoutine skipped because isAdReady = true!");
|
|
391
407
|
_loadState = LoadAdsState.Ready;
|
|
392
408
|
yield break;
|
|
393
409
|
}
|
|
394
|
-
|
|
410
|
+
|
|
411
|
+
Log("[Ad] LoadAdRoutine start(): isAdReady = " + isAdReady);
|
|
395
412
|
while (true)
|
|
396
413
|
{
|
|
397
414
|
yield return wait1Sec;
|
|
398
415
|
|
|
399
|
-
if (!Ads.allowAdRequest)
|
|
400
|
-
|
|
416
|
+
if (!Ads.allowAdRequest)
|
|
417
|
+
{
|
|
418
|
+
Log("[Ad] LoadAdRoutine: allowAdRequest = false");
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (Ads._adConfig.checkInternet && !HasLocalNetworkConnection)
|
|
423
|
+
{
|
|
424
|
+
Log("[Ad] LoadAdRoutine: hasInternet = " + HasLocalNetworkConnection);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
401
427
|
|
|
402
428
|
_loadState = LoadAdsState.Requesting;
|
|
403
429
|
_isRequesting = true;
|
|
430
|
+
Log("[Ad] LoadAdRoutine: RequestAd()");
|
|
404
431
|
RequestAd();
|
|
405
432
|
|
|
406
433
|
int timeout = Ads._adConfig.adLoadTimeoutInSecs;
|
|
@@ -415,22 +442,24 @@ namespace Amanotes.Core.Internal
|
|
|
415
442
|
|
|
416
443
|
if (counter > timeout && timeout > 0) // timeout
|
|
417
444
|
{
|
|
445
|
+
Log("[Ad] LoadAdRoutine: RequestAd not responding (timeout) " + timeout + " secs");
|
|
418
446
|
continue;
|
|
419
447
|
}
|
|
420
448
|
|
|
421
449
|
// request should be completed here!
|
|
422
450
|
if (!isAdReady)
|
|
423
451
|
{
|
|
424
|
-
LogWarning("Request complete but failed!");
|
|
452
|
+
LogWarning($"[Ad] Request complete but failed! (load duration = {counter} secs)");
|
|
425
453
|
continue;
|
|
426
454
|
}
|
|
427
455
|
|
|
428
456
|
_loadState = LoadAdsState.Ready;
|
|
457
|
+
Log($"[Ad] LoadAdRoutine: Ad is ready! (load duration = {counter} secs)");
|
|
429
458
|
yield break;
|
|
430
459
|
}
|
|
431
460
|
}
|
|
432
461
|
|
|
433
|
-
bool
|
|
462
|
+
bool HasLocalNetworkConnection => Application.internetReachability != NetworkReachability.NotReachable;
|
|
434
463
|
|
|
435
464
|
// Override by actual Ad instance
|
|
436
465
|
protected abstract AdType adType { get; }
|
|
@@ -466,7 +495,7 @@ namespace Amanotes.Core.Internal
|
|
|
466
495
|
_loadState = LoadAdsState.None;
|
|
467
496
|
StartLoadAd();
|
|
468
497
|
}
|
|
469
|
-
|
|
498
|
+
HandleAfterAdShow();
|
|
470
499
|
if (_showAdRoutine == null) return;
|
|
471
500
|
_instance.StopCoroutine(_showAdRoutine);
|
|
472
501
|
_showAdRoutine = null;
|
|
@@ -474,6 +503,9 @@ namespace Amanotes.Core.Internal
|
|
|
474
503
|
|
|
475
504
|
IEnumerator ShowAdRoutine()
|
|
476
505
|
{
|
|
506
|
+
// Wait 1 frame so that all AdCallback to register
|
|
507
|
+
yield return null;
|
|
508
|
+
|
|
477
509
|
// Wait for Ad
|
|
478
510
|
if (!isAdReady)
|
|
479
511
|
{
|
|
@@ -483,14 +515,25 @@ namespace Amanotes.Core.Internal
|
|
|
483
515
|
_loadState = LoadAdsState.None;
|
|
484
516
|
}
|
|
485
517
|
|
|
486
|
-
if (Ads._adConfig.checkInternet
|
|
518
|
+
if (Ads._adConfig.checkInternet)
|
|
487
519
|
{
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
520
|
+
if (!HasLocalNetworkConnection)
|
|
521
|
+
{
|
|
522
|
+
_showState = ShowAdsState.ShowFail;
|
|
523
|
+
Ads.context.result = AdResult.WifiAndCarrierDataDisable;
|
|
524
|
+
ShowAdRoutineCompleted(false);
|
|
525
|
+
yield break;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
var hasInternet = false;
|
|
529
|
+
yield return WebUtils.CheckInternet(result => hasInternet = result);
|
|
530
|
+
if (!hasInternet)
|
|
531
|
+
{
|
|
532
|
+
_showState = ShowAdsState.ShowFail;
|
|
533
|
+
Ads.context.result = AdResult.NoInternetAccess;
|
|
534
|
+
ShowAdRoutineCompleted(false);
|
|
535
|
+
yield break;
|
|
536
|
+
}
|
|
494
537
|
}
|
|
495
538
|
|
|
496
539
|
if (_loadState != LoadAdsState.Requesting) StartLoadAd();
|
|
@@ -508,7 +551,7 @@ namespace Amanotes.Core.Internal
|
|
|
508
551
|
|
|
509
552
|
if (!isAdReady)
|
|
510
553
|
{
|
|
511
|
-
Ads.
|
|
554
|
+
Ads.context.result = AdResult.RequestTimeOut;
|
|
512
555
|
ShowAdRoutineCompleted(false);
|
|
513
556
|
yield break;
|
|
514
557
|
}
|
|
@@ -517,11 +560,7 @@ namespace Amanotes.Core.Internal
|
|
|
517
560
|
_showState = ShowAdsState.Showing;
|
|
518
561
|
// Ad should be ready here!
|
|
519
562
|
ShowAd();
|
|
520
|
-
|
|
521
|
-
{
|
|
522
|
-
Ads._savedVolume = AudioListener.volume;
|
|
523
|
-
AudioListener.volume = 0;
|
|
524
|
-
}
|
|
563
|
+
HandleBeforeAdShow();
|
|
525
564
|
|
|
526
565
|
ShowAdContext context = Ads.context;
|
|
527
566
|
while (!context.potentiallyCompleted)
|
|
@@ -573,8 +612,11 @@ namespace Amanotes.Core.Internal
|
|
|
573
612
|
}
|
|
574
613
|
|
|
575
614
|
_showState = isSuccess ? ShowAdsState.ShowSuccess : ShowAdsState.ShowFail;
|
|
615
|
+
// Extra callback
|
|
616
|
+
if (isSuccess) Ads.context.result = AdResult.Success;
|
|
617
|
+
Ads.context.onResult?.Invoke(Ads.context.result);
|
|
576
618
|
Ads.context.showFinishAt = Time.realtimeSinceStartup;
|
|
577
|
-
|
|
619
|
+
|
|
578
620
|
var localData = Ads.localData;
|
|
579
621
|
var stat = _isInterstitial ? localData.interstitial : localData.reward;
|
|
580
622
|
if (isSuccess)
|
|
@@ -590,19 +632,61 @@ namespace Amanotes.Core.Internal
|
|
|
590
632
|
}
|
|
591
633
|
|
|
592
634
|
localData.Save();
|
|
593
|
-
|
|
635
|
+
HandleAfterAdShow();
|
|
594
636
|
|
|
595
637
|
Log($"[Ad] {adType} ShowAdRoutineCompleted: {isSuccess}\n{JsonUtility.ToJson(Ads.context)}");
|
|
596
638
|
Ads.context = null;
|
|
597
639
|
_showState = ShowAdsState.None;
|
|
598
640
|
}
|
|
599
|
-
|
|
600
|
-
private void
|
|
641
|
+
|
|
642
|
+
private void HandleBeforeAdShow()
|
|
601
643
|
{
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
644
|
+
bool willSaveVolume = Ads._adConfig.autoMute
|
|
645
|
+
&& AudioListener.volume > 0
|
|
646
|
+
&& Ads._savedVolume < 0;
|
|
647
|
+
|
|
648
|
+
bool willSaveTimeScale = Ads._adConfig.autoTimeScale
|
|
649
|
+
&& Time.timeScale > 0
|
|
650
|
+
&& Ads._savedTimeScale < 0;
|
|
651
|
+
|
|
652
|
+
if (willSaveVolume)
|
|
653
|
+
{
|
|
654
|
+
Ads._savedVolume = AudioListener.volume;
|
|
655
|
+
AudioListener.volume = 0;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (willSaveTimeScale)
|
|
659
|
+
{
|
|
660
|
+
Ads._savedTimeScale = Time.timeScale;
|
|
661
|
+
Ads._savedTimeScale = Time.timeScale;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
Ads._adapter.HandleBeforeAdShow();
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
private void HandleAfterAdShow()
|
|
668
|
+
{
|
|
669
|
+
bool willRestoreVolume = Ads._adConfig.autoMute
|
|
670
|
+
&& AudioListener.volume == 0
|
|
671
|
+
&& Ads._savedVolume > 0;
|
|
672
|
+
|
|
673
|
+
bool willRestoreTimeScale = Ads._adConfig.autoTimeScale
|
|
674
|
+
&& Time.timeScale == 0
|
|
675
|
+
&& Ads._savedTimeScale > 0;
|
|
676
|
+
|
|
677
|
+
if (willRestoreVolume)
|
|
678
|
+
{
|
|
679
|
+
AudioListener.volume = Ads._savedVolume;
|
|
680
|
+
Ads._savedVolume = -1;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (willRestoreTimeScale)
|
|
684
|
+
{
|
|
685
|
+
Time.timeScale = Ads._savedTimeScale;
|
|
686
|
+
Ads._savedTimeScale = -1;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
Ads._adapter.HandleAfterAdShow();
|
|
606
690
|
}
|
|
607
691
|
|
|
608
692
|
// Default implementation
|
|
@@ -617,13 +701,8 @@ namespace Amanotes.Core.Internal
|
|
|
617
701
|
}
|
|
618
702
|
else
|
|
619
703
|
{
|
|
620
|
-
LogWarning("OnAdClosed() Something wrong - No AdContext");
|
|
704
|
+
LogWarning("[Ad] OnAdClosed() Something wrong - No AdContext");
|
|
621
705
|
}
|
|
622
|
-
|
|
623
|
-
if (_isInterstitial)
|
|
624
|
-
Ads.Events.OnInterstitialClosed?.Invoke();
|
|
625
|
-
else
|
|
626
|
-
Ads.Events.OnRewardedClosed?.Invoke();
|
|
627
706
|
}
|
|
628
707
|
|
|
629
708
|
protected void OnAdClicked()
|
|
@@ -637,14 +716,8 @@ namespace Amanotes.Core.Internal
|
|
|
637
716
|
}
|
|
638
717
|
else
|
|
639
718
|
{
|
|
640
|
-
LogWarning("OnAdClicked() Something wrong - No AdContext");
|
|
719
|
+
LogWarning("[Ad] OnAdClicked() Something wrong - No AdContext");
|
|
641
720
|
}
|
|
642
|
-
|
|
643
|
-
if (_isInterstitial)
|
|
644
|
-
Ads.Events.OnInterstitialClicked?.Invoke();
|
|
645
|
-
else
|
|
646
|
-
Ads.Events.OnRewardedClicked?.Invoke();
|
|
647
|
-
|
|
648
721
|
}
|
|
649
722
|
|
|
650
723
|
protected void OnAdShowFailed()
|
|
@@ -654,18 +727,13 @@ namespace Amanotes.Core.Internal
|
|
|
654
727
|
if (Ads.context != null)
|
|
655
728
|
{
|
|
656
729
|
Ads.context.adCallback |= AdCallback.Fail;
|
|
730
|
+
Ads.context.result = AdResult.AdapterReturnError;
|
|
657
731
|
Ads.context.onShowFailed?.Invoke();
|
|
658
732
|
}
|
|
659
733
|
else
|
|
660
734
|
{
|
|
661
|
-
LogWarning("OnAdShowFailed() Something wrong - No AdContext");
|
|
735
|
+
LogWarning("[Ad] OnAdShowFailed() Something wrong - No AdContext");
|
|
662
736
|
}
|
|
663
|
-
|
|
664
|
-
if (_isInterstitial)
|
|
665
|
-
Ads.Events.OnInterstitialShowFailed?.Invoke();
|
|
666
|
-
else
|
|
667
|
-
Ads.Events.OnRewardedShowFailed?.Invoke();
|
|
668
|
-
|
|
669
737
|
}
|
|
670
738
|
|
|
671
739
|
protected void OnAdShowSucceeded()
|
|
@@ -679,12 +747,8 @@ namespace Amanotes.Core.Internal
|
|
|
679
747
|
}
|
|
680
748
|
else
|
|
681
749
|
{
|
|
682
|
-
LogWarning("OnAdShowSucceeded() Something wrong - No AdContext");
|
|
750
|
+
LogWarning("[Ad] OnAdShowSucceeded() Something wrong - No AdContext");
|
|
683
751
|
}
|
|
684
|
-
|
|
685
|
-
if (_isInterstitial)
|
|
686
|
-
Ads.Events.OnInterstitialShowSucceeded?.Invoke();
|
|
687
|
-
|
|
688
752
|
}
|
|
689
753
|
|
|
690
754
|
protected void OnAdOpen()
|
|
@@ -698,13 +762,8 @@ namespace Amanotes.Core.Internal
|
|
|
698
762
|
}
|
|
699
763
|
else
|
|
700
764
|
{
|
|
701
|
-
LogWarning("OnAdOpen() Something wrong - No AdContext");
|
|
765
|
+
LogWarning("[Ad] OnAdOpen() Something wrong - No AdContext");
|
|
702
766
|
}
|
|
703
|
-
|
|
704
|
-
if (_isInterstitial)
|
|
705
|
-
Ads.Events.OnInterstitialOpened?.Invoke();
|
|
706
|
-
else
|
|
707
|
-
Ads.Events.OnRewardedOpened?.Invoke();
|
|
708
767
|
}
|
|
709
768
|
|
|
710
769
|
protected void OnAdReward()
|
|
@@ -718,11 +777,8 @@ namespace Amanotes.Core.Internal
|
|
|
718
777
|
}
|
|
719
778
|
else
|
|
720
779
|
{
|
|
721
|
-
LogWarning("OnAdReward() Something wrong - No AdContext");
|
|
780
|
+
LogWarning("[Ad] OnAdReward() Something wrong - No AdContext");
|
|
722
781
|
}
|
|
723
|
-
|
|
724
|
-
if (!_isInterstitial)
|
|
725
|
-
Ads.Events.OnRewardedReceived?.Invoke();
|
|
726
782
|
}
|
|
727
783
|
|
|
728
784
|
protected void OnAdLoadSuccess()
|
|
@@ -731,42 +787,15 @@ namespace Amanotes.Core.Internal
|
|
|
731
787
|
|
|
732
788
|
if (!_isRequesting)
|
|
733
789
|
{
|
|
734
|
-
LogWarning("Something wrong? OnAdReady called when no ad is loading!");
|
|
790
|
+
LogWarning("[Ad] Something wrong? OnAdReady called when no ad is loading! AdType=" + adType);
|
|
735
791
|
}
|
|
736
792
|
|
|
737
793
|
_isRequesting = false;
|
|
738
|
-
if (_isInterstitial)
|
|
739
|
-
Ads.Events.OnInterstitialLoadSucceeded?.Invoke();
|
|
740
794
|
}
|
|
741
795
|
|
|
742
796
|
protected void OnAdLoadFailed(string error)
|
|
743
797
|
{
|
|
744
798
|
Log($"[Ad] {adType} OnAdLoadFailed: {error}");
|
|
745
|
-
|
|
746
|
-
if (_isInterstitial)
|
|
747
|
-
Ads.Events.OnInterstitialLoadFailed?.Invoke(error);
|
|
748
799
|
}
|
|
749
800
|
}
|
|
750
|
-
|
|
751
|
-
public class AdListener
|
|
752
|
-
{
|
|
753
|
-
public Action OnRewardedAvailable;
|
|
754
|
-
public Action OnRewardedUnavailable;
|
|
755
|
-
public Action OnRewardedOpened;
|
|
756
|
-
public Action OnRewardedReceived;
|
|
757
|
-
public Action OnRewardedClicked;
|
|
758
|
-
public Action OnRewardedShowFailed;
|
|
759
|
-
public Action OnRewardedClosed;
|
|
760
|
-
|
|
761
|
-
public Action OnInterstitialOpened;
|
|
762
|
-
public Action OnInterstitialShowSucceeded;
|
|
763
|
-
public Action OnInterstitialShowFailed;
|
|
764
|
-
public Action OnInterstitialClicked;
|
|
765
|
-
public Action OnInterstitialClosed;
|
|
766
|
-
public Action OnInterstitialLoadSucceeded;
|
|
767
|
-
public Action<string> OnInterstitialLoadFailed;
|
|
768
|
-
|
|
769
|
-
public Action OnShowTimeout;
|
|
770
|
-
public Action<object> OnAdImpression;
|
|
771
|
-
}
|
|
772
801
|
}
|
package/Runtime/AmaGDK.Config.cs
CHANGED
|
@@ -82,20 +82,19 @@ namespace Amanotes.Core.Internal
|
|
|
82
82
|
}
|
|
83
83
|
#endif
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
[Flags]
|
|
85
|
+
|
|
87
86
|
public enum LogLevel
|
|
88
87
|
{
|
|
89
|
-
None
|
|
90
|
-
Error
|
|
91
|
-
Warning
|
|
92
|
-
Verbose
|
|
88
|
+
None,
|
|
89
|
+
Error,
|
|
90
|
+
Warning,
|
|
91
|
+
Verbose
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
[Serializable]
|
|
96
95
|
public partial class SDKConfig
|
|
97
96
|
{
|
|
98
|
-
public LogLevel logLevel = LogLevel.Warning
|
|
97
|
+
public LogLevel logLevel = LogLevel.Warning;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
[Serializable]
|
|
@@ -68,7 +68,7 @@ namespace Amanotes.Core.Internal
|
|
|
68
68
|
|
|
69
69
|
public static void LogWarningOnce(string message, string key = null)
|
|
70
70
|
{
|
|
71
|
-
if (
|
|
71
|
+
if (Config.common.logLevel < LogLevel.Warning) return;
|
|
72
72
|
if (string.IsNullOrEmpty(key)) key = message;
|
|
73
73
|
if (logWarningDict.Contains(key)) return;
|
|
74
74
|
logWarningDict.Add(key);
|
|
@@ -76,15 +76,15 @@ namespace Amanotes.Core.Internal
|
|
|
76
76
|
}
|
|
77
77
|
public static void LogWarning(string message)
|
|
78
78
|
{
|
|
79
|
-
if (
|
|
79
|
+
if (Config.common.logLevel >= LogLevel.Warning) Debug.LogWarning($"AmaGDK {message}");
|
|
80
80
|
}
|
|
81
81
|
public static void LogError(string message)
|
|
82
82
|
{
|
|
83
|
-
if (
|
|
83
|
+
if (Config.common.logLevel >= LogLevel.Error) Debug.LogError($"AmaGDK {message}");
|
|
84
84
|
}
|
|
85
85
|
public static void Log(string message)
|
|
86
86
|
{
|
|
87
|
-
if (
|
|
87
|
+
if (Config.common.logLevel == LogLevel.Verbose) Debug.Log($"AmaGDK {message}");
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -28,6 +28,7 @@ namespace Amanotes.Core.Internal
|
|
|
28
28
|
{
|
|
29
29
|
SetRequestHeader(kvp.Key, kvp.Value);
|
|
30
30
|
}
|
|
31
|
+
|
|
31
32
|
return this;
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -95,12 +96,14 @@ namespace Amanotes.Core.Internal
|
|
|
95
96
|
|
|
96
97
|
internal class WebUtils
|
|
97
98
|
{
|
|
98
|
-
public static Coroutine PostJson(string url, string jsonData, Action<bool, string> onComplete = null,
|
|
99
|
+
public static Coroutine PostJson(string url, string jsonData, Action<bool, string> onComplete = null,
|
|
100
|
+
Dictionary<string, string> headers = null)
|
|
99
101
|
{
|
|
100
102
|
return AmaGDK._instance.StartCoroutine(PostJsonCoroutine(url, jsonData, onComplete, headers));
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
private static IEnumerator PostJsonCoroutine(string url, string jsonData,
|
|
105
|
+
private static IEnumerator PostJsonCoroutine(string url, string jsonData,
|
|
106
|
+
Action<bool, string> onComplete = null, Dictionary<string, string> headers = null)
|
|
104
107
|
{
|
|
105
108
|
var webRequest = new UnityWebRequest(url, "POST");
|
|
106
109
|
if (headers != null)
|
|
@@ -125,5 +128,29 @@ namespace Amanotes.Core.Internal
|
|
|
125
128
|
onComplete?.Invoke(true, webRequest.downloadHandler.text);
|
|
126
129
|
}
|
|
127
130
|
}
|
|
131
|
+
|
|
132
|
+
public static void CheckInternetConnection(Action<bool> hasInternet)
|
|
133
|
+
{
|
|
134
|
+
AmaGDK._instance.StartCoroutine(CheckInternet(hasInternet));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static IEnumerator CheckInternet(Action<bool> hasInternet)
|
|
138
|
+
{
|
|
139
|
+
UnityWebRequest www = new UnityWebRequest(AmaGDK.Config.common.internetCheckUrl);
|
|
140
|
+
yield return www.SendWebRequest();
|
|
141
|
+
|
|
142
|
+
if (www.error != null && www.responseCode != 429) //429 = Too many requests
|
|
143
|
+
{
|
|
144
|
+
hasInternet?.Invoke(false);
|
|
145
|
+
yield break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
hasInternet?.Invoke(true);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public partial class SDKConfig
|
|
153
|
+
{
|
|
154
|
+
public string internetCheckUrl = "http://www.google.com";
|
|
128
155
|
}
|
|
129
156
|
}
|
package/Runtime/AmaGDK.cs
CHANGED