[M] MAX SDK callback Test

This commit is contained in:
2024-08-09 18:35:08 +08:00
parent 45a213084e
commit 6332ff9055
2 changed files with 29 additions and 16 deletions

View File

@@ -51,11 +51,6 @@ public class SDKTest : MonoBehaviour
void Init()
{
TYSdkFacade.Instance.Init();
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) =>
{
Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}");
};
MaxSdk.InitializeSdk();
TDAnalytics.Init("0caf287574bd4a9bb08be8995705ef6f", "https://122-slg-online01.qijihdhk.com:8991");
AppsFlyer.setIsDebug(true);
@@ -66,6 +61,8 @@ public class SDKTest : MonoBehaviour
#endif
AppsFlyer.startSDK();
AppsFlyerAdRevenue.start();
InitializeRewardedAds();
}
int retryAttempt;
@@ -81,6 +78,12 @@ public class SDKTest : MonoBehaviour
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) =>
{
Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}");
};
MaxSdk.InitializeSdk();
}
private async void OnLogin(EAccoutType accoutType)
@@ -154,12 +157,15 @@ public class SDKTest : MonoBehaviour
private void LoadAd()
{
MaxSdk.LoadRewardedAd("427b872c314ad1f3");
Debug.Log($"[AD LOG] LoadAd {AD_ID}");
MaxSdk.LoadRewardedAd(AD_ID);
}
private void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad loaded. ID: {adInfo.AdUnitIdentifier}";
string msg = $"[AD LOG]Rewarded ad loaded. ID: {adInfo.AdUnitIdentifier}";
_messageTxt.text = msg;
Debug.Log(msg);
retryAttempt = 0;
}
@@ -170,7 +176,9 @@ public class SDKTest : MonoBehaviour
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
_messageTxt.text = $"Rewarded ad failed to load. ID: {adUnitId}. Reason: {errorInfo.Message}. Attempt: {retryAttempt}. Delay: {retryDelay}s.";
string msg = $"[AD LOG]Rewarded ad failed to load. ID: {adUnitId}. Reason: {errorInfo.Message}. Attempt: {retryAttempt}. Delay: {retryDelay}s.";
_messageTxt.text = msg;
Debug.Log(msg);
Invoke("LoadAd", (float)retryDelay);
}
@@ -180,7 +188,9 @@ public class SDKTest : MonoBehaviour
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
_messageTxt.text = $"Rewarded ad failed to display. ID: {adUnitId}. Reason: {errorInfo.Message}";
string msg = $"[AD LOG]Rewarded ad failed to display. ID: {adUnitId}. Reason: {errorInfo.Message}";
_messageTxt.text = msg;
Debug.Log(msg);
LoadAd();
}
@@ -189,18 +199,24 @@ public class SDKTest : MonoBehaviour
private void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad is hidden. Pre-load the next ad
_messageTxt.text = $"Rewarded ad hidden. ID: {adUnitId}.";
string msg = $"[AD LOG]Rewarded ad hidden. ID: {adUnitId}.";
_messageTxt.text = msg;
Debug.Log(msg);
LoadAd();
}
private void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad received reward. ID: {adUnitId}. Type: {reward}. Amount: {reward.Amount}";
string msg = $"[AD LOG]Rewarded ad received reward. ID: {adUnitId}. Type: {reward}. Amount: {reward.Amount}";
_messageTxt.text = msg;
Debug.Log(msg);
}
private void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad revenue paid. ID: {adUnitId}.";
string msg = $"[AD LOG]Rewarded ad revenue paid. ID: {adUnitId}.";
_messageTxt.text = msg;
Debug.Log(msg);
}
/*