com.amanotes.gdk 0.2.39 → 0.2.41

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,8 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.41 - 2023-11-28]
4
+ - Add more state callbacks for AdShowReadyStatus
5
+ - Fix not wait for RewardCancel event (not exist any more)
6
+ - Timeout for Adapter init should be 1s
7
+
8
+ ## [0.2.40 - 2023-11-27]
9
+ - Fix ShowAdTimeout = 0 should not wait for Ad
10
+
3
11
  ## [0.2.39 - 2023-11-27]
4
12
  - Fix variable name and variable value of "ChangeDevMode"
5
- - Fix Timeout = 0 should cancel the wait for Ad
13
+ - Load Ad timeout should cancel
6
14
 
7
15
  ## [0.2.38 - 2023-11-22]
8
16
  - Improve Ads API
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -407,7 +407,9 @@ namespace Amanotes.Core.Internal
407
407
  None,
408
408
  Wifi3GDisabled,
409
409
  NoInternet,
410
- TimeOut
410
+ WaitForAd,
411
+ TimeOut,
412
+ Ready,
411
413
  }
412
414
 
413
415
  public class ShowAdContext : IAdCallback
@@ -634,31 +636,47 @@ namespace Amanotes.Core.Internal
634
636
  ShowAdRoutineCompleted(false);
635
637
  yield break;
636
638
  }
637
-
638
- var hasInternet = false;
639
- yield return WebUtils.CheckInternet(result => hasInternet = result);
640
- if (!hasInternet)
639
+
640
+ int timeout = Ads._adConfig.adShowTimeoutInSecs;
641
+ if (timeout == 0) // do not wait for Ad
641
642
  {
642
643
  _showState = ShowAdsState.ShowFail;
643
- OnAdShowReadyStatus(false, AdShowReadyStatus.NoInternet);
644
+ OnAdShowReadyStatus(false, AdShowReadyStatus.TimeOut);
644
645
  ShowAdRoutineCompleted(false);
645
646
  yield break;
646
647
  }
647
-
648
- if (_loadState != LoadAdsState.Requesting) StartLoadAd();
648
+
649
649
  _showState = ShowAdsState.WaitForAd;
650
- int timeout = Ads._adConfig.adShowTimeoutInSecs;
650
+ OnAdShowReadyStatus(false, AdShowReadyStatus.WaitForAd);
651
+
652
+ if (_loadState != LoadAdsState.Requesting) StartLoadAd();
651
653
  var counter = 0;
652
-
653
- while (counter < timeout || timeout == 0)
654
+ bool? hasInternet = null;
655
+ _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
656
+
657
+ while (counter < timeout || timeout == -1)
654
658
  {
655
659
  yield return wait1Sec;
656
660
  counter++;
657
- if (_loadState == LoadAdsState.Ready) break;
658
- }
659
661
 
662
+ // finish checking internet & result is false
663
+ if (hasInternet == false)
664
+ {
665
+ Log("[Ad] Stop WaitForAd : No internet!");
666
+ _showState = ShowAdsState.ShowFail;
667
+ OnAdShowReadyStatus(false, AdShowReadyStatus.NoInternet);
668
+ ShowAdRoutineCompleted(false);
669
+ yield break;
670
+ }
671
+
672
+ if (_loadState != LoadAdsState.Ready) continue;
673
+ Log("[Ad] WaitForAd success after " + counter + " | timeout = " + timeout + " secs");
674
+ break;
675
+ }
676
+
660
677
  if (!isAdReady)
661
678
  {
679
+ Log("[Ad] WaitForAd failed (timeout) " + counter + " | timeout = " + timeout + " secs");
662
680
  OnAdShowReadyStatus(false, AdShowReadyStatus.TimeOut);
663
681
  ShowAdRoutineCompleted(false);
664
682
  yield break;
@@ -666,8 +684,7 @@ namespace Amanotes.Core.Internal
666
684
  }
667
685
 
668
686
  _showState = ShowAdsState.Showing;
669
- OnAdShowReadyStatus(true, AdShowReadyStatus.None);
670
-
687
+ OnAdShowReadyStatus(true, AdShowReadyStatus.Ready);
671
688
  HandleBeforeAdShow();
672
689
  ShowAd();
673
690
 
@@ -693,13 +710,9 @@ namespace Amanotes.Core.Internal
693
710
 
694
711
  if (context.hasClosed)
695
712
  {
696
- while (!context.hasFailedOrCancelled && !context.hasReward)
697
- {
698
- Log($"[Ad] {adType} Waiting for [cancel] or [reward]");
699
- yield return null;
700
- }
701
-
702
- ShowAdRoutineCompleted(!context.hasFailedOrCancelled);
713
+ // wait 1 frame in case hasReward callback after onClose
714
+ if (!context.hasReward) yield return null;
715
+ ShowAdRoutineCompleted(context.hasReward);
703
716
  yield break;
704
717
  }
705
718
 
@@ -871,6 +884,7 @@ namespace Amanotes.Core.Internal
871
884
  OnAdShowNotReady(status);
872
885
  } else
873
886
  {
887
+ Ads.context.onAdShowReadyStatus?.Invoke(AdShowReadyStatus.Ready);
874
888
  OnAdShowReady();
875
889
  }
876
890
  }
package/Runtime/AmaGDK.cs CHANGED
@@ -15,7 +15,7 @@ namespace Amanotes.Core
15
15
  {
16
16
  public partial class AmaGDK : MonoBehaviour
17
17
  {
18
- public const string VERSION = "0.2.39";
18
+ public const string VERSION = "0.2.41";
19
19
 
20
20
  internal static AmaGDK _instance;
21
21
  internal static Status _status = Status.None;
@@ -69,7 +69,7 @@ namespace Amanotes.Core
69
69
  yield return StartCoroutine(User.Init());
70
70
 
71
71
  float time = 0;
72
- float timeout = 10;
72
+ float timeout = 1;
73
73
 
74
74
  var counter = 0;
75
75
  const int INIT_TOLERANCE = 10 * 60;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",