fix:1、接入外部sdk
This commit is contained in:
@@ -6,6 +6,7 @@ using AppsFlyerSDK;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.NetKit;
|
||||
using SRKZBz0SDK;
|
||||
|
||||
// using AppsFlyerSDK;
|
||||
|
||||
@@ -26,30 +27,48 @@ namespace RedHotRoast
|
||||
|
||||
public static string rewardedADUnitID = "13c3601021e6a8b9";
|
||||
|
||||
|
||||
private const float RevenueThreshold = 0;
|
||||
|
||||
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
// 注册 ab事件,0或1,0为自然量版本,1为激励版本
|
||||
SRKZBz0SDK_Utility.Instance.RegistIosParam((i =>
|
||||
{
|
||||
InitializeRewardedAds();
|
||||
InitializeInterstitialAds();
|
||||
};
|
||||
SuperApplication.Instance.attribution = i == 0 ? "organic" : "non_organic";
|
||||
Debug.Log($"ios ab param : {i} attribution=== {SuperApplication.Instance.attribution}");
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
|
||||
}));
|
||||
|
||||
|
||||
MaxSdk.SetSdkKey(SDKKey);
|
||||
|
||||
// var loginModel = GameHelper.GetLoginModel();
|
||||
// user_id = loginModel.uid.ToString();
|
||||
// MaxSdk.SetUserId(loginModel.uid.ToString());
|
||||
// MaxSdk.SetIsAgeRestrictedUser(false);
|
||||
MaxSdk.SetHasUserConsent(true);
|
||||
MaxSdk.SetDoNotSell(false);
|
||||
|
||||
MaxSdk.InitializeSdk();
|
||||
void GameConfig(bool result, string config)
|
||||
{
|
||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
}
|
||||
// SDK初始化方法
|
||||
SRKZBz0SDK_Utility.Instance.Init(null, null, GameConfig);
|
||||
|
||||
#endif
|
||||
// MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
|
||||
// {
|
||||
// InitializeRewardedAds();
|
||||
// InitializeInterstitialAds();
|
||||
// };
|
||||
//
|
||||
//
|
||||
// MaxSdk.SetSdkKey(SDKKey);
|
||||
//
|
||||
// // var loginModel = GameHelper.GetLoginModel();
|
||||
// // user_id = loginModel.uid.ToString();
|
||||
// // MaxSdk.SetUserId(loginModel.uid.ToString());
|
||||
// // MaxSdk.SetIsAgeRestrictedUser(false);
|
||||
// MaxSdk.SetHasUserConsent(true);
|
||||
// MaxSdk.SetDoNotSell(false);
|
||||
//
|
||||
// MaxSdk.InitializeSdk();
|
||||
|
||||
// MaxSdk.ShowMediationDebugger();
|
||||
// #if !UNITY_EDITOR
|
||||
@@ -65,22 +84,42 @@ namespace RedHotRoast
|
||||
|
||||
#region 插屏广告相关
|
||||
public static UnityAction<bool> onInterstitialAdCompleted = null;
|
||||
|
||||
public static bool CheckInterstitialReady()
|
||||
{
|
||||
return SRKZBz0SDK_Utility.Instance.IsInterReady();
|
||||
}
|
||||
public static void ShowInterstitial(string placement = "DefaultInterstitial",
|
||||
UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
|
||||
|
||||
if (CheckInterstitialReady())
|
||||
{
|
||||
// Debug.Log($"广告已经准备好,播放");
|
||||
MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
|
||||
onInterstitialAdCompleted = onCompleted;
|
||||
|
||||
Debug.Log($"广告已经准备好,播放");
|
||||
SRKZBz0SDK_Utility.Instance.ShowInter(placement, () =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log($"广告未准备好,不播放");
|
||||
|
||||
Debug.Log($"广告未准备好,不播放");
|
||||
onCompleted?.Invoke(false);
|
||||
}
|
||||
|
||||
// if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
|
||||
// {
|
||||
// // Debug.Log($"广告已经准备好,播放");
|
||||
// MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
|
||||
// onInterstitialAdCompleted = onCompleted;
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Debug.Log($"广告未准备好,不播放");
|
||||
//
|
||||
// onCompleted?.Invoke(false);
|
||||
// }
|
||||
}
|
||||
|
||||
static int retryAttemptInterstitial;
|
||||
@@ -158,6 +197,11 @@ namespace RedHotRoast
|
||||
public static UnityAction<bool> onVideoAdCompleted = null;
|
||||
private static string _placement = "";
|
||||
private static Coroutine _waitForVideoAd = null;
|
||||
|
||||
public static bool CheckRewardedReady()
|
||||
{
|
||||
return SRKZBz0SDK_Utility.Instance.IsVideoReady();
|
||||
}
|
||||
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
onVideoAdCompleted = onCompleted;
|
||||
@@ -168,18 +212,38 @@ namespace RedHotRoast
|
||||
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.watch_ad_people);
|
||||
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.Rewarded_videos_trigger_number);
|
||||
|
||||
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
if (CheckRewardedReady())
|
||||
{
|
||||
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
SRKZBz0SDK_Utility.Instance.ShowRewardVideo(_placement, b =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(b);
|
||||
}, ()=>
|
||||
{
|
||||
Debug.Log($"激励广告关闭");
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, ADEventTrack.Property.afterRewardAdShow);
|
||||
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_waitForVideoAd != null)
|
||||
{
|
||||
CrazyAsyKit.StopCoroutine(_waitForVideoAd);
|
||||
}
|
||||
_waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
|
||||
onVideoAdCompleted?.Invoke(false);
|
||||
}
|
||||
// if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
// {
|
||||
// MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (_waitForVideoAd != null)
|
||||
// {
|
||||
// CrazyAsyKit.StopCoroutine(_waitForVideoAd);
|
||||
// }
|
||||
// _waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
|
||||
// }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user