fix:1、接入外部sdk

This commit is contained in:
2026-05-20 14:29:11 +08:00
parent aca0e4d1af
commit d8b41f25ba
890 changed files with 45707 additions and 1095 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e595ff25130d84811aae9bbe30751d78
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
using UnityEngine;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Api.Constant;
public class AdHelper
{
public static void ShowBannerAd(AndroidJavaObject bannerAd)
{
ShowBannerAd(bannerAd, BigoPosition.Bottom);
}
public static void ShowBannerAd(AndroidJavaObject bannerAd, BigoPosition position)
{
if (bannerAd == null) return;
var adView = bannerAd.Call<AndroidJavaObject>("adView");
SetViewPosition(adView, position);
}
public static void ShowNativeAd(AndroidJavaObject nativeAd)
{
ShowNativeAd(nativeAd, BigoPosition.Bottom);
}
public static void RemoveAdView()
{
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
new AndroidJavaClass("sg.bigo.ads.AdHelper").CallStatic("removeAdView", activity);
}
public static void ShowNativeAd(AndroidJavaObject nativeAd, BigoPosition position)
{
if (nativeAd == null) return;
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
var adView = new AndroidJavaClass("sg.bigo.ads.AdHelper").CallStatic<AndroidJavaObject>("renderNativeAdView", activity, nativeAd, "layout_bigo_native_ad");
SetViewPosition(adView, position);
}
public static void SetViewPosition(AndroidJavaObject adView, BigoPosition position)
{
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
int positionInt;
switch (position)
{
case BigoPosition.Top:
positionInt = 48;
break;
case BigoPosition.Middle:
positionInt = 16;
break;
case BigoPosition.Bottom:
default:
positionInt = 80;
break;
}
new AndroidJavaClass("sg.bigo.ads.AdHelper").CallStatic("addAdView", activity, adView, positionInt);
}
public abstract class Task : AndroidJavaProxy
{
public Task() : base("java.lang.Runnable")
{
}
public abstract void run();
}
public static void DestroyAd(AndroidJavaObject ad)
{
if (ad != null) {
PostToAndroidMainThread(new DestryAdTask(ad));
}
}
private class DestryAdTask : Task
{
public AndroidJavaObject Ad;
public DestryAdTask(AndroidJavaObject ad)
{
this.Ad = ad;
}
public override void run()
{
Ad.Call("destroy");
AdHelper.RemoveAdView();
}
}
public static void PostToAndroidMainThread(Task task)
{
new AndroidJavaClass("sg.bigo.ads.AdHelper").CallStatic("postToAndroidMainThread", task);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c7b17fadc228c48b6900058970865c98
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,106 @@
package sg.bigo.ads;
import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import sg.bigo.ads.api.AdOptionsView;
import sg.bigo.ads.api.AdTag;
import sg.bigo.ads.api.MediaView;
import sg.bigo.ads.api.NativeAd;
public class AdHelper {
public static void postToAndroidMainThread(Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
public static void addAdView(Activity activity, View adView, int position) {
if (adView == null) return;
ViewGroup contentView = activity.findViewById(android.R.id.content);
String tag = "ad_container";
ViewGroup adContainer = contentView.findViewWithTag(tag);
if (adContainer == null) {
adContainer = new FrameLayout(activity);
adContainer.setTag(tag);
}
contentView.removeView(adContainer);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, position);
contentView.addView(adContainer, layoutParams);
adContainer.removeAllViews();
adContainer.addView(adView);
}
public static void removeAdView(Activity activity)
{
ViewGroup contentView = activity.findViewById(android.R.id.content);
String tag = "ad_container";
ViewGroup adContainer = contentView.findViewWithTag(tag);
if (adContainer == null) return;
adContainer.removeAllViews();
}
public static int getLayoutIdByResName(Activity activity, String resName) {
return activity.getResources().getIdentifier(resName, "layout", activity.getPackageName());
}
public static int getDrawableIdByResName(Activity activity, String resName) {
return activity.getResources().getIdentifier(resName, "drawable", activity.getPackageName());
}
public static View renderNativeAdView(Activity activity, NativeAd nativeAd, String layoutResName) {
int layoutId = getLayoutIdByResName(activity, layoutResName);
if (layoutId <= 0) {
Log.w("BigoAds-Unity", "Invalid res name: " + layoutResName);
return null;
}
View view = LayoutInflater.from(activity).inflate(layoutId, null, false);
if (!(view instanceof ViewGroup)) {
return view;
}
ViewGroup nativeView = (ViewGroup) view;
TextView titleView = findViewByIdName(nativeView, "native_title");
TextView descriptionView = findViewByIdName(nativeView, "native_description");
TextView warningView = findViewByIdName(nativeView, "native_warning");
Button ctaButton = findViewByIdName(nativeView, "native_cta");
MediaView mediaView = findViewByIdName(nativeView, "native_media_view");
ImageView iconView = findViewByIdName(nativeView, "native_icon_view");
AdOptionsView optionsView = findViewByIdName(nativeView, "native_option_view");
titleView.setTag(AdTag.TITLE);
descriptionView.setTag(AdTag.DESCRIPTION);
warningView.setTag(AdTag.WARNING);
ctaButton.setTag(AdTag.CALL_TO_ACTION);
titleView.setText(nativeAd.getTitle());
descriptionView.setText(nativeAd.getDescription());
warningView.setText(nativeAd.getWarning());
ctaButton.setText(nativeAd.getCallToAction());
List<View> clickableViews = new ArrayList<>();
clickableViews.add(titleView);
clickableViews.add(descriptionView);
clickableViews.add(ctaButton);
nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews);
return nativeView;
}
private static <T extends View> T findViewByIdName(ViewGroup parent, String name) {
Context context = parent.getContext();
int id = context.getResources().getIdentifier(name, "id", context.getPackageName());
return parent.findViewById(id);
}
}
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 0edf95022edcd4f9d8919629603eb5e1
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
#if UNITY_ANDROID
using System;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
public class AdInteractionCallback : AndroidJavaProxy
{
private readonly Action OnAdShowed;
protected readonly Action OnAdDismissed;
private readonly Action OnAdClicked;
private readonly Action<int, string> OnAdError;
private const string ListenerName = AndroidPlatformTool.ClassPackage + ".api.AdInteractionListener";
public AdInteractionCallback(Action onAdShowed, Action onAdClicked, Action onAdDismissed, Action<int, string> onAdError,
string listenerName = ListenerName) : base(listenerName)
{
OnAdShowed = onAdShowed;
OnAdDismissed = onAdDismissed;
OnAdClicked = onAdClicked;
OnAdError = onAdError;
}
public void onAdImpression()
{
OnAdShowed?.Invoke();
}
public void onAdClosed()
{
OnAdDismissed?.Invoke();
}
public void onAdClicked()
{
OnAdClicked?.Invoke();
}
public void onAdError(AndroidJavaObject error)
{
var code = error.Call<int>("getCode");
var message = error.Call<string>("getMessage");
OnAdError?.Invoke(code, message);
}
public void onAdOpened()
{
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eeaf0303131624578b3997f9db6cb014
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
#if UNITY_ANDROID
using System;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
public class AdLoadCallback : AndroidJavaProxy
{
private readonly Action<AndroidJavaObject> onLoad;
private readonly Action<int, string> onLoadFailed;
public AdLoadCallback(Action<AndroidJavaObject> onLoad, Action<int, string> onLoadFailed) : base(
AndroidPlatformTool.ClassPackage + ".api.AdLoadListener")
{
this.onLoad = onLoad;
this.onLoadFailed = onLoadFailed;
}
public void onError(AndroidJavaObject error)
{
var code = error.Call<int>("getCode");
var message = error.Call<string>("getMessage");
onLoadFailed?.Invoke(code, message);
}
public void onAdLoaded(AndroidJavaObject ad)
{
onLoad?.Invoke(ad);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b4d06d46018574b7bae1c9dc60ef6122
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,147 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidBannerAd : IBannerAd
{
private const string BannerAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.BannerAdLoader$Builder";
private const string BannerAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.BannerAdRequest$Builder";
private const string BannerSizeClassName = AndroidPlatformTool.ClassPackage + ".api.AdSize";
private const string BannerBuildMethod = "build";
private const string BannerAdLoaderBuildMethod = "withAdLoadListener";
private const string BannerAdLoaderExtMethod = "withExt";
private AndroidJavaObject BannerAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public AndroidBannerAd()
{
OnAdLoad += ((ad) =>
{
BannerAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoBannerRequest request)
{
if (request == null)
{
return;
}
var bannerLoaderBuilder = new AndroidJavaObject(BannerAdLoaderClassName);
bannerLoaderBuilder?.Call<AndroidJavaObject>(BannerAdLoaderExtMethod, request.ExtraInfoJson);
bannerLoaderBuilder?.Call<AndroidJavaObject>(BannerAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var bannerLoader = bannerLoaderBuilder?.Call<AndroidJavaObject>(BannerBuildMethod);
var bannerRequestBuilder = new AndroidJavaObject(BannerAdRequestClassName);
bannerRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
bannerRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
bannerRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
bannerRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var bannerSize = new AndroidJavaClass(BannerSizeClassName).GetStatic<AndroidJavaObject>("BANNER");
int width = request.Size.Width;
int height = request.Size.Height;
if (width == 300 && height == 250) {
bannerSize = new AndroidJavaClass(BannerSizeClassName).GetStatic<AndroidJavaObject>("MEDIUM_RECTANGLE");
}
AndroidJavaClass arrayClass = new AndroidJavaClass("java.lang.reflect.Array");
AndroidJavaObject arrayObject = arrayClass.CallStatic<AndroidJavaObject>("newInstance", new AndroidJavaClass(BannerSizeClassName), 1);
arrayClass.CallStatic("set", arrayObject, 0, bannerSize);
bannerRequestBuilder?.Call<AndroidJavaObject>("withAdSizes", arrayObject);
var bannerRequest = bannerRequestBuilder?.Call<AndroidJavaObject>(BannerBuildMethod);
bannerLoader?.Call("loadAd", bannerRequest);
}
public bool IsLoaded()
{
return BannerAd != null;
}
public void Show()
{
BannerAd?.Call("setAdInteractionListener", new AdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
AdHelper.ShowBannerAd(BannerAd);
});
}
public void Destroy()
{
//post to main
AdHelper.DestroyAd(BannerAd);
}
public bool IsExpired()
{
return BannerAd != null && BannerAd.Call<bool>("isExpired");
}
public void SetPosition(BigoPosition position)
{
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
AdHelper.ShowBannerAd(BannerAd, position);
});
}
public bool IsClientBidding()
{
if (BannerAd == null) return false;
AndroidJavaObject bid = BannerAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (BannerAd == null) return "";
return BannerAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (BannerAd == null) return 0;
AndroidJavaObject bid = BannerAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (BannerAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
BannerAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (BannerAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
BannerAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46ee6aacd6a2546ce8e23dd89e5d27d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
#if UNITY_ANDROID
using BigoAds.Scripts.Common;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidClientFactory : IClientFactory
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public ISDK BuildSDKClient()
{
return new BigoSdkClient();
}
public IBannerAd BuildBannerAdClient()
{
return new AndroidBannerAd();
}
public INativeAd BuildNativeAdClient()
{
return new AndroidNativeAd();
}
public IInterstitialAd BuildInterstitialAdClient()
{
return new AndroidInterstitialAd();
}
public IPopupAd BuildPopupAdClient()
{
return new AndroidPopupAd();
}
public ISplashAd BuildSplashAdClient()
{
return new AndroidSplashAd();
}
public IRewardedAd BuildRewardedAdClient()
{
return new AndroidRewardedAd();
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1809d4d3a8b034fa88284da804f66a71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,124 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidInterstitialAd : IInterstitialAd
{
private const string InterstitialAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.InterstitialAdLoader$Builder";
private const string InterstitialAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.InterstitialAdRequest$Builder";
private const string InterstitialBuildMethod = "build";
private const string InterstitialAdLoaderBuildMethod = "withAdLoadListener";
private const string InterstitialAdLoaderExtMethod = "withExt";
private AndroidJavaObject InterstitialAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public AndroidInterstitialAd()
{
OnAdLoad += ((ad) =>
{
InterstitialAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoInterstitialRequest request)
{
if (request == null)
{
return;
}
var InterstitialLoaderBuilder = new AndroidJavaObject(InterstitialAdLoaderClassName);
InterstitialLoaderBuilder?.Call<AndroidJavaObject>(InterstitialAdLoaderExtMethod, request.ExtraInfoJson);
InterstitialLoaderBuilder?.Call<AndroidJavaObject>(InterstitialAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var InterstitialLoader = InterstitialLoaderBuilder?.Call<AndroidJavaObject>(InterstitialBuildMethod);
var InterstitialRequestBuilder = new AndroidJavaObject(InterstitialAdRequestClassName);
InterstitialRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
InterstitialRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
InterstitialRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
InterstitialRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var InterstitialRequest = InterstitialRequestBuilder?.Call<AndroidJavaObject>(InterstitialBuildMethod);
InterstitialLoader?.Call("loadAd", InterstitialRequest);
}
public bool IsLoaded()
{
return InterstitialAd != null;
}
public void Show()
{
InterstitialAd?.Call("setAdInteractionListener", new AdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
InterstitialAd?.Call("show");
});
}
public void Destroy()
{
//post to main
AdHelper.DestroyAd(InterstitialAd);
}
public bool IsExpired()
{
return InterstitialAd != null && InterstitialAd.Call<bool>("isExpired");
}
public bool IsClientBidding()
{
if (InterstitialAd == null) return false;
AndroidJavaObject bid = InterstitialAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (InterstitialAd == null) return "";
return InterstitialAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (InterstitialAd == null) return 0;
AndroidJavaObject bid = InterstitialAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (InterstitialAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
InterstitialAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (InterstitialAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
InterstitialAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 087385bbddf0541e5be511be304caee8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,133 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidNativeAd : INativeAd
{
private const string NativeAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.NativeAdLoader$Builder";
private const string NativeAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.NativeAdRequest$Builder";
private const string NativeBuildMethod = "build";
private const string NativeAdLoaderBuildMethod = "withAdLoadListener";
private const string NativeAdLoaderExtMethod = "withExt";
private AndroidJavaObject NativeAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public AndroidNativeAd()
{
OnAdLoad += ((ad) =>
{
NativeAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoNativeRequest request)
{
if (request == null)
{
return;
}
var nativeLoaderBuilder = new AndroidJavaObject(NativeAdLoaderClassName);
nativeLoaderBuilder?.Call<AndroidJavaObject>(NativeAdLoaderExtMethod, request.ExtraInfoJson);
nativeLoaderBuilder?.Call<AndroidJavaObject>(NativeAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var nativeLoader = nativeLoaderBuilder?.Call<AndroidJavaObject>(NativeBuildMethod);
var nativeRequestBuilder = new AndroidJavaObject(NativeAdRequestClassName);
nativeRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
nativeRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
nativeRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
nativeRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var nativeRequest = nativeRequestBuilder?.Call<AndroidJavaObject>(NativeBuildMethod);
nativeLoader?.Call("loadAd", nativeRequest);
}
public bool IsLoaded()
{
return NativeAd != null;
}
public void Show()
{
NativeAd?.Call("setAdInteractionListener", new AdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
AdHelper.ShowNativeAd(NativeAd);
});
}
public void Destroy()
{
AdHelper.DestroyAd(NativeAd);
}
public bool IsExpired()
{
return NativeAd != null && NativeAd.Call<bool>("isExpired");
}
public void SetPosition(BigoPosition position)
{
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
AdHelper.ShowNativeAd(NativeAd, position);
});
}
public bool IsClientBidding()
{
if (NativeAd == null) return false;
AndroidJavaObject bid = NativeAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (NativeAd == null) return "";
return NativeAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (NativeAd == null) return 0;
AndroidJavaObject bid = NativeAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (NativeAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
NativeAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (NativeAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
NativeAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04dd9e8545a394cc0b0bd15cfe325045
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,101 @@
#if UNITY_ANDROID
using System;
using System.Collections.Generic;
using System.Text;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
internal static class AndroidPlatformTool
{
public const string ClassPackage = "sg.bigo.ads";
private const string UnityPlayerClassName = "com.unity3d.player.UnityPlayer";
private const string CurrentActivityMethod = "currentActivity";
private const string ResourceUtilClassName = ClassPackage + ".ResourceUtil";
private const string AdConfigClassName = ClassPackage + ".api.AdConfig$Builder";
public static AndroidJavaObject GetGameActivity()
{
return new AndroidJavaClass(UnityPlayerClassName).GetStatic<AndroidJavaObject>(CurrentActivityMethod);
}
public static AndroidJavaObject GetBigoConfig(BigoAdConfig config)
{
var builder = new AndroidJavaObject(AdConfigClassName);
if (config != null)
{
void CallNativeFunction<T>(string methodName, T arg)
{
builder.Call<AndroidJavaObject>(methodName, arg);
}
if (!string.IsNullOrEmpty(config.AppId))
{
CallNativeFunction("setAppId", config.AppId);
}
if (config.DebugLog) //default value is false
{
Debug.Log("set debug true");
CallNativeFunction("setDebug", true);
}
if (!string.IsNullOrEmpty(config.Channel))
{
CallNativeFunction("setChannel", config.Channel);
}
if (config.Age > 0)
{
CallNativeFunction("setAge", config.Age);
}
if (config.Gender > 0)
{
CallNativeFunction("setGender", config.Gender);
}
if (config.ActivatedTime > 0)
{
CallNativeFunction("setActivatedTime", config.ActivatedTime);
}
foreach (KeyValuePair<string, string> item in config.ExtraDictionary)
{
Debug.Log($"bigo sdk config extra:" + item.Key + "=" + item.Value);
builder.Call<AndroidJavaObject>("addExtra", item.Key, item.Value);
}
}
return builder.Call<AndroidJavaObject>("build");
}
public static AndroidJavaObject GetAdRequest(BigoRequest request)
{
switch (request)
{
case BigoBannerRequest _:
break;
case BigoNativeRequest _:
break;
case BigoSplashRequest _:
break;
case BigoInterstitialRequest _:
break;
case BigoRewardedRequest _:
break;
}
return null;
}
public static void CallMethodOnMainThread(Action task)
{
GetGameActivity()?.Call("runOnUiThread", new AndroidJavaRunnable(task));
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec73d6fa8edaa4c619d96f6db2789dd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,124 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidPopupAd : IPopupAd
{
private const string PopupAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.popup.PopupAdLoader$Builder";
private const string PopupAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.popup.PopupAdRequest$Builder";
private const string PopupBuildMethod = "build";
private const string PopupAdLoaderBuildMethod = "withAdLoadListener";
private const string PopupAdLoaderExtMethod = "withExt";
private AndroidJavaObject PopupAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public AndroidPopupAd()
{
OnAdLoad += ((ad) =>
{
PopupAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoPopupRequest request)
{
if (request == null)
{
return;
}
var PopupLoaderBuilder = new AndroidJavaObject(PopupAdLoaderClassName);
PopupLoaderBuilder?.Call<AndroidJavaObject>(PopupAdLoaderExtMethod, request.ExtraInfoJson);
PopupLoaderBuilder?.Call<AndroidJavaObject>(PopupAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var PopupLoader = PopupLoaderBuilder?.Call<AndroidJavaObject>(PopupBuildMethod);
var PopupRequestBuilder = new AndroidJavaObject(PopupAdRequestClassName);
PopupRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
PopupRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
PopupRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
PopupRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var PopupRequest = PopupRequestBuilder?.Call<AndroidJavaObject>(PopupBuildMethod);
PopupLoader?.Call("loadAd", PopupRequest);
}
public bool IsLoaded()
{
return PopupAd != null;
}
public void Show()
{
PopupAd?.Call("setAdInteractionListener", new AdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
PopupAd?.Call("show");
});
}
public void Destroy()
{
//post to main
AdHelper.DestroyAd(PopupAd);
}
public bool IsExpired()
{
return PopupAd != null && PopupAd.Call<bool>("isExpired");
}
public bool IsClientBidding()
{
if (PopupAd == null) return false;
AndroidJavaObject bid = PopupAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (PopupAd == null) return "";
return PopupAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (PopupAd == null) return 0;
AndroidJavaObject bid = PopupAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (PopupAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
PopupAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (PopupAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
PopupAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 34628c2993e174780bc5786dff90c900
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,125 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidRewardedAd : IRewardedAd
{
private const string RewardedAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.RewardVideoAdLoader$Builder";
private const string RewardedAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.RewardVideoAdRequest$Builder";
private const string RewardedAdBuildMethod = "build";
private const string RewardedAdLoaderBuildMethod = "withAdLoadListener";
private const string RewardedAdLoaderExtMethod = "withExt";
private AndroidJavaObject RewardedAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public event Action OnUserEarnedReward;
public AndroidRewardedAd()
{
OnAdLoad += ((ad) =>
{
RewardedAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoRewardedRequest request)
{
if (request == null)
{
return;
}
var rewardedAdLoaderBuilder = new AndroidJavaObject(RewardedAdLoaderClassName);
rewardedAdLoaderBuilder?.Call<AndroidJavaObject>(RewardedAdLoaderExtMethod, request.ExtraInfoJson);
rewardedAdLoaderBuilder?.Call<AndroidJavaObject>(RewardedAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var rewardedAdLoader = rewardedAdLoaderBuilder?.Call<AndroidJavaObject>(RewardedAdBuildMethod);
var rewardedAdRequestBuilder = new AndroidJavaObject(RewardedAdRequestClassName);
rewardedAdRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
rewardedAdRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
rewardedAdRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
rewardedAdRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var RewardedAdRequest = rewardedAdRequestBuilder?.Call<AndroidJavaObject>(RewardedAdBuildMethod);
rewardedAdLoader?.Call("loadAd", RewardedAdRequest);
}
public bool IsLoaded()
{
return RewardedAd != null;
}
public void Show()
{
RewardedAd?.Call("setAdInteractionListener", new RewardedAdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError, OnUserEarnedReward));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
RewardedAd?.Call("show");
});
}
public void Destroy()
{
//post to main
AdHelper.DestroyAd(RewardedAd);
}
public bool IsExpired()
{
return RewardedAd != null && RewardedAd.Call<bool>("isExpired");
}
public bool IsClientBidding()
{
if (RewardedAd == null) return false;
AndroidJavaObject bid = RewardedAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (RewardedAd == null) return "";
return RewardedAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (RewardedAd == null) return 0;
AndroidJavaObject bid = RewardedAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (RewardedAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
RewardedAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (RewardedAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
RewardedAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6bca6ddceb592449c9606175e8f5f77e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,124 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
class AndroidSplashAd : ISplashAd
{
private const string SplashAdLoaderClassName = AndroidPlatformTool.ClassPackage + ".api.SplashAdLoader$Builder";
private const string SplashAdRequestClassName = AndroidPlatformTool.ClassPackage + ".api.SplashAdRequest$Builder";
private const string SplashBuildMethod = "build";
private const string SplashAdLoaderBuildMethod = "withAdLoadListener";
private const string SplashAdLoaderExtMethod = "withExt";
private AndroidJavaObject SplashAd;
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public AndroidSplashAd()
{
OnAdLoad += ((ad) =>
{
SplashAd = ad;
OnLoad?.Invoke();
});
}
private event Action<AndroidJavaObject> OnAdLoad;
public void Load(string slotId, BigoSplashRequest request)
{
if (request == null)
{
return;
}
var SplashLoaderBuilder = new AndroidJavaObject(SplashAdLoaderClassName);
SplashLoaderBuilder?.Call<AndroidJavaObject>(SplashAdLoaderExtMethod, request.ExtraInfoJson);
SplashLoaderBuilder?.Call<AndroidJavaObject>(SplashAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed));
var SplashLoader = SplashLoaderBuilder?.Call<AndroidJavaObject>(SplashBuildMethod);
var SplashRequestBuilder = new AndroidJavaObject(SplashAdRequestClassName);
SplashRequestBuilder?.Call<AndroidJavaObject>("withSlotId", slotId);
SplashRequestBuilder?.Call<AndroidJavaObject>("withAge", request.Age);
SplashRequestBuilder?.Call<AndroidJavaObject>("withGender", (int)(request.Gender));
SplashRequestBuilder?.Call<AndroidJavaObject>("withActivatedTime", request.ActivatedTime);
var SplashRequest = SplashRequestBuilder?.Call<AndroidJavaObject>(SplashBuildMethod);
SplashLoader?.Call("loadAd", SplashRequest);
}
public bool IsLoaded()
{
return SplashAd != null;
}
public void Show()
{
SplashAd?.Call("setAdInteractionListener", new SplashAdInteractionCallback(OnAdShowed, OnAdClicked, OnAdDismissed, OnAdError));
AndroidPlatformTool.CallMethodOnMainThread(() =>
{
SplashAd?.Call("show");
});
}
public void Destroy()
{
//post to main
AdHelper.DestroyAd(SplashAd);
}
public bool IsExpired()
{
return SplashAd != null && SplashAd.Call<bool>("isExpired");
}
public bool IsClientBidding()
{
if (SplashAd == null) return false;
AndroidJavaObject bid = SplashAd.Call<AndroidJavaObject>("getBid");
return bid != null;
}
public string GetExtraInfo(string key)
{
if (SplashAd == null) return "";
return SplashAd.Call<string>("getExtraInfo", key);
}
/// get price
public double getPrice()
{
if (SplashAd == null) return 0;
AndroidJavaObject bid = SplashAd.Call<AndroidJavaObject>("getBid");
return bid == null ? 0 : bid.Call<double>("getPrice");
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
if (SplashAd == null) return;
var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", secPrice);
SplashAd.Call<AndroidJavaObject>("getBid")?.Call("notifyWin", secPriceDouble, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
if (SplashAd == null) return;
var firstPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic<AndroidJavaObject> ("valueOf", firstPrice);
SplashAd.Call<AndroidJavaObject>("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cdf1866c87531416d8159aae83c6e470
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
#if UNITY_ANDROID
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using UnityEngine;
using BigoAds.Scripts.Api.Constant;
namespace BigoAds.Scripts.Platforms.Android
{
class BigoSdkClient : ISDK
{
private const string SDKClientClassName = AndroidPlatformTool.ClassPackage + ".BigoAdSdk";
private const string InitMethod = "initialize";
private const string InitSuccessMethod = "isInitialized";
private const string SDKVersionMethod = "getSDKVersion";
private const string InitListenerInterfaceName = AndroidPlatformTool.ClassPackage + ".BigoAdSdk$InitListener";
private const string ConsentOptionsClassName = AndroidPlatformTool.ClassPackage + ".ConsentOptions";
public void Init(BigoAdConfig config, BigoAdSdk.InitResultDelegate initResultDelegate)
{
InvokeNativeMethod(InitMethod, AndroidPlatformTool.GetGameActivity(),
AndroidPlatformTool.GetBigoConfig(config),
new InitCallBack(initResultDelegate));
}
public bool IsInitSuccess()
{
return InvokeNativeMethod<bool>(InitSuccessMethod);
}
public string GetSDKVersion()
{
return InvokeNativeMethod<string>("getSDKVersion");
}
public string GetSDKVersionName()
{
return InvokeNativeMethod<string>("getSDKVersionName");
}
public void SetUserConsent(ConsentOptions option, bool consent)
{
var clazz = new AndroidJavaClass(ConsentOptionsClassName);
AndroidJavaObject obj = null;
switch (option)
{
case ConsentOptions.GDPR:
obj = clazz.GetStatic<AndroidJavaObject>("GDPR");
break;
case ConsentOptions.CCPA:
obj = clazz.GetStatic<AndroidJavaObject>("CCPA");
break;
case ConsentOptions.LGPD:
obj = clazz.GetStatic<AndroidJavaObject>("LGPD");
break;
case ConsentOptions.COPPA:
obj = clazz.GetStatic<AndroidJavaObject>("COPPA");
break;
default:
break;
}
InvokeNativeMethod("setUserConsent", AndroidPlatformTool.GetGameActivity(), obj, consent);
}
public void AddExtraHost(string country, string host)
{
InvokeNativeMethod("addExtraHost", country, host);
}
private static void InvokeNativeMethod(string methodName, params object[] args)
{
new AndroidJavaClass(SDKClientClassName).CallStatic(methodName, args);
}
private static T InvokeNativeMethod<T>(string methodName, params object[] args)
{
return new AndroidJavaClass(SDKClientClassName).CallStatic<T>(methodName, args);
}
private class InitCallBack : AndroidJavaProxy
{
private event BigoAdSdk.InitResultDelegate InitListener;
public InitCallBack(BigoAdSdk.InitResultDelegate initResultDelegate) : base(InitListenerInterfaceName)
{
this.InitListener = initResultDelegate;
}
public void onInitialized()
{
InitListener?.Invoke();
}
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a768d78eefdf84ba4bcbfa8077fe6a62
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
public class RewardedAdInteractionCallback : AdInteractionCallback
{
private event Action OnUserEarnedReward;
private const string ListenerName = AndroidPlatformTool.ClassPackage + ".api.RewardAdInteractionListener";
public RewardedAdInteractionCallback(Action onAdShowed, Action onAdClicked, Action onAdDismissed, Action<int, string> onAdError,
Action userEarnedReward) : base(
onAdShowed, onAdClicked, onAdDismissed, onAdError, ListenerName)
{
OnUserEarnedReward = userEarnedReward;
}
public void onAdRewarded()
{
OnUserEarnedReward?.Invoke();
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 679833dea127f43cebbb043ff2a1c2f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
#if UNITY_ANDROID
using System;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.Android
{
public class SplashAdInteractionCallback : AdInteractionCallback
{
private const string ListenerName = AndroidPlatformTool.ClassPackage + ".api.SplashAdInteractionListener";
public SplashAdInteractionCallback(Action onAdShowed, Action onAdClicked, Action onAdDismissed, Action<int, string> onAdError) : base(
onAdShowed, onAdClicked, onAdDismissed, onAdError, ListenerName)
{
}
public void onAdSkipped()
{
}
public void onAdFinished()
{
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 02f23872f0193427487d67e2373c8e41
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cc250d638e6404797a830f56c2b7e40e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e1921a1c99c3c47ae95c0103939e6ffa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7eed132e5c97a47718143d7e692cafda
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aaf596d8ee1bd409e831a2c8c6919580
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,112 @@
#if UNITY_IOS
using System;
using System.Threading;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Platforms.iOS;
using System.Runtime.InteropServices;
public class BigoUnityBannerAd: BigoIOSBaseAd, IBannerAd
{
private BigoBannerRequest bannerRequest;
//TODO:线程问题需要考虑下
public void Load(string slotId, BigoBannerRequest request)
{
bannerRequest = request;
adType = 2;
this.unityAdPtr = (IntPtr)GCHandle.Alloc (this);
IntPtr ptr = this.unityAdPtr;
int width = request.Size.Width;
int height = request.Size.Height;
int x = CalculateMiddleX(width);
int y = CalculatePositionY(request.Position,height);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"calculate-origin:{x},{y}-size:{width},{height}");
BigoIOS_loadBannerAdData(ptr,
slotId,
request.ToJson(),
x,
y,
width,
height,
cs_adDidLoadCallback,
cs_adLoadFailCallBack,
cs_adDidShowCallback,
cs_adDidClickCallback,
cs_adDidDismissCallback,
cs_adDidErrorCallBack
);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"request.position:{request.Position},slotId:{slotId}");
}
private int CalculatePositionY(BigoPosition position, int bannerHeight)
{
int screenHeight = BigoIOS_getScreenHeight();
float y = BigoIOS_getScreenSafeTop();
if (position == BigoPosition.Middle)
{
y = (float)((screenHeight - bannerHeight) * 0.5);
}
else if (position == BigoPosition.Bottom)
{
y = (float)(screenHeight - bannerHeight - BigoIOS_getScreenSafeBottom());
}
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position:{position},screenHeight:{screenHeight}-y:{y}");
return (int)y;
}
private int CalculateMiddleX(int bannerWidth)
{
int screenWidth = BigoIOS_getScreenWidth();
int x = (int)((screenWidth - bannerWidth) * 0.5);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"screenWidth:{screenWidth}-x:{x}");
return x;
}
public void SetPosition(BigoPosition position)
{
int x = CalculateMiddleX(bannerRequest.Size.Width);
int y = CalculatePositionY(position, bannerRequest.Size.Height);
BigoIOS_SetBannerAdPosition(unityAdPtr,x,y);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position-{position}");
}
//MARK: c# - oc
[DllImport("__Internal")]
static extern void BigoIOS_loadBannerAdData(IntPtr unityAdPtr,
string slotId,
string requestJson,
int x,
int y,
int width,
int height,
adDidLoadCallback_delegate successCallback,
adLoadFailCallBack_delegate failCallback,
adDidShowCallback_delegate showCallback,
adDidClickCallback_delegate clickCallback,
adDidDismissCallback_delegate dismissCallback,
adDidErrorCallback_delegate adErrorCallback
);
[DllImport("__Internal")]
static extern void BigoIOS_SetBannerAdPosition(IntPtr unityAdPtr, int x, int y);
[DllImport("__Internal")]
static extern int BigoIOS_getScreenWidth();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenHeight();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenSafeTop();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenSafeBottom();
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f3106d1522ac4b95a8f73c101387f8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,24 @@
#import "BigoUnityBaseAdHandler.h"
extern "C" {
//load banner Ad
void BigoIOS_loadBannerAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
int x,
int y,
int width,
int height,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
);
//show banner ad
void BigoIOS_showBannerAd(UnityAd unityAd);
void BigoIOS_SetBannerAdPosition(UnityAd unityAd,int x, int y);
void BigoIOS_removeBannerView(UnityAd unityAd);
}
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: a86c122698a834a0e868b3d38d576442
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,133 @@
#import <BigoADS/BigoADS.h>
#import "UnityAppController.h"
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityAdHandlerManager.h"
extern "C"{
int BigoIOS_getScreenWidth () {
__block int width = 0;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
width = (int)vc.view.frame.size.width;
});
return width;
}
int BigoIOS_getScreenHeight () {
__block int height = 0;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
height = (int)vc.view.frame.size.height;
});
return height;
}
int BigoIOS_getScreenSafeBottom() {
__block int bottom = 0;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
bottom = (int)vc.view.safeAreaInsets.bottom;
});
return bottom;
}
int BigoIOS_getScreenSafeTop() {
__block int top = 0;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
top = (int)vc.view.safeAreaInsets.top;
});
return top;
}
//load Banner ad
void BigoIOS_loadBannerAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
int x,
int y,
int width,
int height,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
) {
BigoIOS_dispatchSyncMainQueue(^{
BigoAdSize *size = BigoAdSize.BANNER;
if (width == 300 && height == 250) {
size = BigoAdSize.MEDIUM_RECTANGLE;
}
NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson);
BigoUnityBannerAdHandler *adHandler = [[BigoUnityBannerAdHandler alloc] init];
BigoBannerAdRequest *request = [[BigoBannerAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId) adSizes:@[size]];
request.age = [requestDict[@"age"] intValue];
request.gender = (BigoAdGender)[requestDict[@"gender"] intValue];
request.activatedTime = [requestDict[@"activatedTime"] longLongValue];
BigoBannerAdLoader *adLoader = [[BigoBannerAdLoader alloc] initWithBannerAdLoaderDelegate:adHandler];
adLoader.ext = requestDict[@"extraInfo"];
adHandler.adLoader = adLoader;
adHandler.unityAd = unityAd;
adHandler.showCallback = showCallback;
adHandler.clickCallback = clickCallback;
adHandler.dismissCallback = dismissCallback;
adHandler.adErrorCallback = adErrorCallback;
adHandler.successCallback = successCallback;
adHandler.failCallback = failCallback;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
[BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey];
[adLoader loadAd:request];
});
}
BigoUnityBannerAdHandler* BigoIOS_getBannerAdHandler(UnityAd unityAd) {
if (!unityAd) return nil;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBannerAdHandler *handler = (BigoUnityBannerAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
if (!handler || ![handler isMemberOfClass:[BigoUnityBannerAdHandler class]]) {
return nil;
}
return handler;
}
void BigoIOS_showBannerAd(UnityAd unityAd) {
BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
BigoBannerAd *ad = (BigoBannerAd *)handler.ad;
[vc.view addSubview:ad.adView];
});
}
void BigoIOS_SetBannerAdPosition(UnityAd unityAd,int x, int y) {
BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
BigoBannerAd *ad = (BigoBannerAd *)handler.ad;
CGRect frame = ad.adView.frame;
frame.origin.x = x;
frame.origin.y = y;
ad.adView.frame = frame;
});
}
void BigoIOS_removeBannerView(UnityAd unityAd) {
BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
BigoBannerAd *ad = (BigoBannerAd *)handler.ad;
[ad.adView removeFromSuperview];
});
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: fd1772b6ab58f4e74ac7e89d3fd471c3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,265 @@
#if UNITY_IOS
using System.Collections.Generic;
using AOT;
using UnityEngine;
using BigoAds.Scripts.Api.Constant;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Platforms.iOS;
using System.Runtime.InteropServices;
public class BigoIOSBaseAd : IBigoAd<BigoRequest>
{
public event Action OnLoad;
public event Action<int, string> OnLoadFailed;
public event Action OnAdShowed;
public event Action OnAdClicked;
public event Action OnAdDismissed;
public event Action<int, string> OnAdError;
public void Load(string slotId, BigoRequest request)
{
}
protected void LoadAdData(string slotId, BigoRequest request) {
this.unityAdPtr = (IntPtr)GCHandle.Alloc (this);
IntPtr ptr = this.unityAdPtr;
BigoIOS_loadAdData(adType,
ptr,
slotId,
request.ToJson(),
cs_adDidLoadCallback,
cs_adLoadFailCallBack,
cs_adDidShowCallback,
cs_adDidClickCallback,
cs_adDidDismissCallback,
cs_adDidErrorCallBack
);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"slotId:{slotId},request{request}");
}
public bool IsLoaded()
{
return bigoAdLoaded;
}
public virtual void Show()
{
LOGWithMessage("Show");
BigoIOS_showAd(adType,this.unityAdPtr);
}
public virtual bool IsExpired()
{
return BigoIOS_IsExpired(unityAdPtr);
}
public void Destroy()
{
BigoIOS_destroyAd(adType,unityAdPtr);
if (unityAdPtr != IntPtr.Zero)
{
GCHandle unityAdhandle = (GCHandle)this.unityAdPtr;
unityAdhandle.Free();
}
unityAdPtr = IntPtr.Zero;
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"unityPtr:{unityAdPtr}");
}
public bool IsClientBidding()
{
return BigoIOS_IsClientBidding(unityAdPtr);
}
public string GetExtraInfo(String key)
{
//todo
return "";
}
/// get price
public double getPrice()
{
return BigoIOS_GetPrice(unityAdPtr);
}
///notify win
public void notifyWin(double secPrice, string secBidder)
{
BigoIOS_NotifyWin(unityAdPtr, secPrice, secBidder);
}
///notify loss
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
{
BigoIOS_NotifyLoss(unityAdPtr, firstPrice, firstBidder, (int)lossReason);
}
protected void LOGWithMessage(string method)
{
LOGWithMessage(method,string.Empty);
}
protected void LOGWithMessage(string method,string msg)
{
//native = 1, banner = 2, interstitial = 3, rewarded = 4, appOpen = 5
int adtype = adType;
string adTypeString = "unknown";
if (adtype == 1)
{
adTypeString = "native";
}
else if (adtype == 2)
{
adTypeString = "banner";
}
else if (adtype == 3)
{
adTypeString = "interstitial";
}
else if (adtype == 4)
{
adTypeString = "rewarded";
}
else if (adtype == 5)
{
adTypeString = "appOpen";
}
//System.Reflection.MethodBase.GetCurrentMethod()?.Name
Type classType = this.GetType();
string className = $"{adTypeString}-{classType.Name}";
BigoUnityTools.LOGWithMessage(className,method,msg);
}
protected static BigoIOSBaseAd GetUnityAd(IntPtr unityAdPtr)
{
GCHandle handle = (GCHandle) unityAdPtr;
BigoIOSBaseAd unityAd = handle.Target as BigoIOSBaseAd;
// handle.Free ();
return unityAd;
}
protected int adType = 0;
private bool bigoAdLoaded = false;
protected IntPtr unityAdPtr = IntPtr.Zero;
//MARK: c --> oc
[DllImport("__Internal")]
static extern void BigoIOS_loadAdData(int adType,
IntPtr unityAdPtr,
string slotId,
string requestJson,
adDidLoadCallback_delegate successCallback,
adLoadFailCallBack_delegate failCallback,
adDidShowCallback_delegate showCallback,
adDidClickCallback_delegate clickCallback,
adDidDismissCallback_delegate dismissCallback,
adDidErrorCallback_delegate adErrorCallback);
[DllImport("__Internal")]
static extern void BigoIOS_showAd(int adType,IntPtr unityAdPtr);
[DllImport("__Internal")]
static extern void BigoIOS_destroyAd(int adType, IntPtr unityAdPtr);
[DllImport("__Internal")]
static extern bool BigoIOS_IsExpired(IntPtr unityAdPtr);
[DllImport("__Internal")]
static extern bool BigoIOS_IsClientBidding(IntPtr unityAdPtr);
[DllImport("__Internal")]
static extern double BigoIOS_GetPrice(IntPtr unityAdPtr);
[DllImport("__Internal")]
static extern void BigoIOS_NotifyWin(IntPtr unityAdPtr, double secPrice, string secBidder);
[DllImport("__Internal")]
static extern void BigoIOS_NotifyLoss(IntPtr unityAdPtr, double firstPrice, string firstBidder, int lossReason);
//callback method
protected delegate void adDidLoadCallback_delegate(IntPtr unityAdPtr);
protected delegate void adLoadFailCallBack_delegate(IntPtr unityAdPtr, int code, string msg);
protected delegate void adDidShowCallback_delegate(IntPtr unityAdPtr);
protected delegate void adDidClickCallback_delegate(IntPtr unityAdPtr);
protected delegate void adDidDismissCallback_delegate(IntPtr unityAdPtr);
protected delegate void adDidErrorCallback_delegate(IntPtr unityAdPtr, int code, string msg);
[MonoPInvokeCallback(typeof(adDidLoadCallback_delegate))]
protected static void cs_adDidLoadCallback(IntPtr unityAdPtr)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd == null)
{
return;
}
unityAd.bigoAdLoaded = true;
unityAd.OnLoad?.Invoke();
unityAd.LOGWithMessage("cs_adDidLoad");
}
[MonoPInvokeCallback(typeof(adLoadFailCallBack_delegate))]
protected static void cs_adLoadFailCallBack(IntPtr unityAdPtr, int code, string msg)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd.OnLoadFailed != null)
{
unityAd.OnLoadFailed(code, msg);
}
unityAd.LOGWithMessage("cs_adLoadFail",$"code:{code},msg:{msg}");
}
[MonoPInvokeCallback(typeof(adDidShowCallback_delegate))]
protected static void cs_adDidShowCallback(IntPtr unityAdPtr)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd == null)
{
return;
}
unityAd.OnAdShowed?.Invoke();
unityAd.LOGWithMessage($"cs_show");
}
[MonoPInvokeCallback(typeof(adDidClickCallback_delegate))]
protected static void cs_adDidClickCallback(IntPtr unityAdPtr)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd == null)
{
return;
}
unityAd.OnAdClicked?.Invoke();
unityAd.LOGWithMessage("cs_click");
}
[MonoPInvokeCallback(typeof(adDidDismissCallback_delegate))]
protected static void cs_adDidDismissCallback(IntPtr unityAdPtr)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd == null)
{
return;
}
unityAd.OnAdDismissed?.Invoke();
unityAd.LOGWithMessage("cs_dismiss");
}
[MonoPInvokeCallback(typeof(adDidErrorCallback_delegate))]
protected static void cs_adDidErrorCallBack(IntPtr unityAdPtr, int code, string msg)
{
BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr);
if (unityAd.OnAdError != null)
{
unityAd.OnAdError(code, msg);
}
unityAd.LOGWithMessage("cs_aderror",$"code:{code},msg:{msg}");
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b8d512f4ea0948bb8110a2eee062858
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,109 @@
#import <BigoADS/BigoADS.h>
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdHandlerManager.h"
#import "BigoUnityBannerAd.h"
#import "BigoUnityInterstitialAd.h"
#import "BigoUnityRewardedAd.h"
#import "BigoUnitySplashAd.h"
#import "BigoUnityNativeAd.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityPopupAd.h"
extern "C" {
enum BigoIOSAdType {
native = 1, banner = 2, interstitial = 3, rewarded = 4, splash = 5, popup = 6
};
void BigoIOS_loadAdData(int adType,
UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback) {
if (adType == rewarded || adType == banner) {//custom load
return;
}
if (adType == interstitial) {
BigoIOS_loadInterstitialAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback);
}
else if (adType == splash) {
BigoIOS_loadSplashAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback);
}
else if (adType == native) {
BigoIOS_loadNativeAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback);
} else if (adType == popup) {
BigoIOS_loadPopupAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback);
}
}
void BigoIOS_showAd(int adType, UnityAd unityAd) {
if (adType == interstitial) {
BigoIOS_showInterstitialAd(unityAd);
}
else if (adType == splash) {
BigoIOS_showSplashAd(unityAd);
}
else if (adType == rewarded) {
BigoIOS_showRewardedAd(unityAd);
}
else if (adType == banner) {
BigoIOS_showBannerAd(unityAd);
}
else if (adType == native) {
BigoIOS_showNativeAd(unityAd);
}
}
void BigoIOS_destroyAd(int adType, UnityAd unityAd) {
if (adType == banner) {
BigoIOS_removeBannerView(unityAd);
}
else if (adType == native) {
BigoIOS_removeNativeView(unityAd);
}
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
[BigoUnityAdHandlerManager removeAdHandlerWithKey:unityAdKey];
}
BOOL BigoIOS_IsExpired(UnityAd unityAd) {
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
BigoAd *ad = (BigoAd *)(handler.ad);
return ad.isExpired;
}
BOOL BigoIOS_IsClientBidding(UnityAd unityAd) {
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
BigoAd *ad = (BigoAd *)(handler.ad);
return ad.getBid != nil;
}
CGFloat BigoIOS_GetPrice(UnityAd unityAd) {
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
BigoAd *ad = (BigoAd *)(handler.ad);
return ad.getBid.getPrice;
}
void BigoIOS_NotifyWin(UnityAd unityAd, CGFloat secPrice, const char* secBidder) {
NSString *secBidderString = BigoIOS_transformNSStringForm(secBidder);
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
BigoAd *ad = (BigoAd *)(handler.ad);
[ad.getBid notifyWinWithSecPrice:secPrice secBidder:secBidderString];
}
void BigoIOS_NotifyLoss(UnityAd unityAd, CGFloat firstPrice , const char* firstBidder, int lossReason) {
NSString *firstBidderString = BigoIOS_transformNSStringForm(firstBidder);
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
BigoAd *ad = (BigoAd *)(handler.ad);
[ad.getBid notifyLossWithFirstPrice:firstPrice firstBidder:firstBidderString lossReason:(BGAdLossReasonType)lossReason];
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 75401cc01b4054f97931486033a4c690
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
#import <Foundation/Foundation.h>
#import "BigoUnityBaseAdHandler.h"
NS_ASSUME_NONNULL_BEGIN
@interface BigoUnityAdHandlerManager : NSObject
+ (void)saveAdHandler:(BigoUnityBaseAdHandler *)adhandler withKey:(NSString *)key;
+ (void)removeAdHandlerWithKey:(NSString *)key;
+ (NSString *)createKeyUnityAd:(UnityAd)unityAd;
+ (nullable BigoUnityBaseAdHandler *)handlerWithKey:(NSString *)key;
+ (void)printList;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: f39924fa7a4d144ee93ad3242f4c5e9f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
#import "BigoUnityAdHandlerManager.h"
@interface BigoUnityAdHandlerManager()
@property (nonatomic, strong) dispatch_semaphore_t semaphore;
@property (nonatomic, strong) NSMutableDictionary *dictionary;
@end
@implementation BigoUnityAdHandlerManager
+ (instancetype)sharedInstance {
static BigoUnityAdHandlerManager *manager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[BigoUnityAdHandlerManager alloc] init];
});
return manager;
}
- (instancetype)init
{
self = [super init];
if (self) {
self.dictionary = [NSMutableDictionary new];
self.semaphore = dispatch_semaphore_create(1);
}
return self;
}
+ (void)saveAdHandler:(BigoUnityBaseAdHandler *)adhandler withKey:(NSString *)key {
if (!adhandler || key.length == 0) {
return;
}
BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance];
dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER);
[manager.dictionary setObject:adhandler forKey:key];
dispatch_semaphore_signal(manager.semaphore);
}
+ (void)removeAdHandlerWithKey:(NSString *)key {
if (key.length == 0) {
return;
}
BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance];
dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER);
[manager.dictionary removeObjectForKey:key];
dispatch_semaphore_signal(manager.semaphore);
}
+ (NSString *)createKeyUnityAd:(UnityAd)unityAd {
return [NSString stringWithFormat:@"%p",unityAd];
}
+ (nullable BigoUnityBaseAdHandler *)handlerWithKey:(NSString *)key {
if (key.length == 0) {
return nil;
}
BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance];
dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER);
BigoUnityBaseAdHandler *handler = [manager.dictionary objectForKey:key];
dispatch_semaphore_signal(manager.semaphore);
return handler;
}
+ (void)printList {
NSLog(@"bigo-ios-list:%@",[BigoUnityAdHandlerManager sharedInstance].dictionary);
}
@end
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 053a4c32bd9344bcd9a22f2e0c87f777
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,62 @@
#import <Foundation/Foundation.h>
#import <BigoADS/BigoADS.h>
#import <UIKit/UIKit.h>
typedef void* UnityAd;//unity ad
typedef void* BigoAdSdkAd;//bigo ad
//int
//callback of ad load
typedef void(*AdDidLoadCallback)(UnityAd unityAd);
typedef void (*AdLoadFailCallBack)(UnityAd unityAd, int code, const char *msg);
//callback of ad event
typedef void(*AdDidShowCallback)(UnityAd unityAd);
typedef void(*AdDidClickCallback)(UnityAd unityAd);
typedef void(*AdDidDismissCallback)(UnityAd unityAd);
typedef void (*AdDidErrorCallback)(UnityAd unityAd, int code, const char *msg);
typedef void (*AdDidEarnRewardCallback)(UnityAd unityA);
@interface BigoUnityBaseAdHandler : NSObject<BigoAdInteractionDelegate>
@property (nonatomic, assign) UnityAd unityAd;
@property (nonatomic, strong) BigoAd *ad;
@property (nonatomic, assign) AdDidShowCallback showCallback;
@property (nonatomic, assign) AdDidClickCallback clickCallback;
@property (nonatomic, assign) AdDidDismissCallback dismissCallback;
@property (nonatomic, assign) AdDidErrorCallback adErrorCallback;
//强持有AdLoader
@property (nonatomic, strong) BigoAdLoader *adLoader;
@property (nonatomic, assign) AdDidLoadCallback successCallback;
@property (nonatomic, assign) AdLoadFailCallBack failCallback;
@end
@interface BigoUnityBannerAdHandler : BigoUnityBaseAdHandler<BigoBannerAdLoaderDelegate>
@end
@interface BigoUnityInterstitialAdHandler : BigoUnityBaseAdHandler<BigoInterstitialAdLoaderDelegate>
@end
@interface BigoUnityRewardedAdHandler : BigoUnityBaseAdHandler<BigoRewardVideoAdLoaderDelegate, BigoRewardVideoAdInteractionDelegate>
@property (nonatomic, assign) AdDidEarnRewardCallback earnCallback;
@end
@interface BigoUnitySplashAdHandler : BigoUnityBaseAdHandler<BigoSplashAdLoaderDelegate, BigoSplashAdInteractionDelegate>
@end
@interface BigoUnityNativeAdHandler : BigoUnityBaseAdHandler<BigoNativeAdLoaderDelegate>
@property (nonatomic, strong) UIView *nativeView;
@end
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 0f898c08506444b2cae9b6fb32656a61
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,170 @@
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdHandlerManager.h"
@implementation BigoUnityBaseAdHandler
//广告异常
- (void)onAd:(BigoAd *)ad error:(BigoAdError *)error {
}
//广告展示
- (void)onAdImpression:(BigoAd *)ad {
if (self.showCallback) {
self.showCallback(self.unityAd);
}
}
//广告点击
- (void)onAdClicked:(BigoAd *)ad {
if (self.clickCallback) {
self.clickCallback(self.unityAd);
}
}
//广告打开
- (void)onAdOpened:(BigoAd *)ad {
}
//广告关闭
- (void)onAdClosed:(BigoAd *)ad {
if (self.dismissCallback) {
self.dismissCallback(self.unityAd);
}
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:self.unityAd];
[BigoUnityAdHandlerManager removeAdHandlerWithKey:unityAdKey];
}
- (void)dealloc {
NSLog(@"BigoAd-iOS-[BigoUnityBaseAdHandler]-[dealloc]");
}
@end
@implementation BigoUnityBannerAdHandler
#pragma mark - BigoBannerAdLoaderDelegate
- (void)onBannerAdLoaded:(BigoBannerAd *)ad {
[ad setAdInteractionDelegate:self];
self.ad = ad;
if (self.successCallback) {
self.successCallback(self.unityAd);
}
}
- (void)onBannerAdLoadError:(BigoAdError *)error {
if (self.failCallback) {
self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String);
}
}
@end
@implementation BigoUnityInterstitialAdHandler
#pragma mark - BigoInterstitialAdLoaderDelegate
- (void)onInterstitialAdLoaded:(BigoInterstitialAd *)ad {
[ad setAdInteractionDelegate:self];
self.ad = ad;
if (self.successCallback) {
self.successCallback(self.unityAd);
}
}
- (void)onInterstitialAdLoadError:(BigoAdError *)error {
if (self.failCallback) {
self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String);
}
}
@end
@implementation BigoUnityRewardedAdHandler
#pragma mark - BigoRewardVideoAdLoaderDelegate
- (void)onRewardVideoAdLoaded:(BigoRewardVideoAd *)ad {
[ad setRewardVideoAdInteractionDelegate:self];
self.ad = ad;
if (self.successCallback) {
self.successCallback(self.unityAd);
}
}
- (void)onRewardVideoAdLoadError:(BigoAdError *)error {
if (self.failCallback) {
self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String);
}
}
#pragma mark - BigoRewardVideoAdInteractionDelegate
//激励视频激励回调
- (void)onAdRewarded:(BigoRewardVideoAd *)ad {
if (self.earnCallback) {
self.earnCallback(self.unityAd);
}
}
@end
@implementation BigoUnitySplashAdHandler
#pragma mark - BigoSplashAdLoaderDelegate
- (void)onSplashAdLoaded:(BigoSplashAd *)ad {
[ad setSplashAdInteractionDelegate:self];
self.ad = ad;
if (self.successCallback) {
self.successCallback(self.unityAd);
}
}
- (void)onSplashAdLoadError:(BigoAdError *)error {
if (self.failCallback) {
self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String);
}
}
#pragma mark - BigoSplashAdInteractionDelegate
/**
* 广告可跳过回调,通常是由用户点击了右上角 SKIP 按钮所触发
*/
- (void)onAdSkipped:(BigoAd *)ad {
if (self.dismissCallback) {
self.dismissCallback(self.unityAd);
}
}
/**
* 广告倒计时结束回调
*/
- (void)onAdFinished:(BigoAd *)ad {
if (self.dismissCallback) {
self.dismissCallback(self.unityAd);
}
}
@end
@implementation BigoUnityNativeAdHandler
#pragma mark - BigoNativeAdLoaderDelegate
- (void)onNativeAdLoaded:(BigoNativeAd *)ad {
[ad setAdInteractionDelegate:self];
self.ad = ad;
if (self.successCallback) {
self.successCallback(self.unityAd);
}
}
- (void)onNativeAdLoadError:(BigoAdError *)error {
if (self.failCallback) {
self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String);
}
}
@end
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 956299e395371425abfa788d6f80bad9
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
#if UNITY_IOS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BigoAds.Scripts.Api;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
class BigoUnityConfig
{
private IntPtr _config;
internal void Init(BigoAdConfig config)
{
_config = BigoIOS_config(config.AppId);
BigoIOS_configSetInfo(_config, config.DebugLog, config.Age, config.Gender, config.ActivatedTime);
// set extra
foreach (KeyValuePair<string, string> item in config.ExtraDictionary)
{
BigoIOS_configSetExtra(_config, item.Key, item.Value);
}
}
public IntPtr getInternalConfig()
{
return _config;
}
//c# - > oc
[DllImport("__Internal")]
private static extern IntPtr BigoIOS_config(string appID);
[DllImport(dllName: "__Internal")]
private static extern void BigoIOS_configSetInfo(IntPtr configPt, bool debugLog, int age, int gender, long activatedTime);
[DllImport(dllName: "__Internal")]
private static extern void BigoIOS_configSetExtra(IntPtr configPt, string key, string extra);
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd95f8f9cd401477c8b11db40da15a59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
#import <BigoADS/BigoADS.h>
#import <UIKit/UIKit.h>
#import "BigoUnityAdapterTools.h"
extern "C" {
BigoAdConfig* BigoIOS_config(const char* appID) {
NSString *appId = BigoIOS_transformNSStringForm(appID);
return [[BigoAdConfig alloc] initWithAppId:appId];
}
BigoAdConfig* BigoIOS_GetConfig(void* __nullable config) {
BigoAdConfig *bigoConfig = config ? (__bridge BigoAdConfig*)config : nil;
return bigoConfig;
}
void BigoIOS_configSetExtra(void* __nullable config, const char* key, const char* extra) {
BigoAdConfig *bigoConfig = BigoIOS_GetConfig(config);
NSString *keyString = BigoIOS_transformNSStringForm(key);
NSString *extraString = BigoIOS_transformNSStringForm(extra);
[bigoConfig addExtraWithKey:keyString extra:extraString];
}
void BigoIOS_configSetInfo(void* config, bool debugLog, int age, int gender, long activatedTime) {
BigoIOS_GetConfig(config).testMode = debugLog;
BigoIOS_GetConfig(config).age = age;
BigoIOS_GetConfig(config).gender = (BigoAdGender)gender;
BigoIOS_GetConfig(config).activatedTime = activatedTime;
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: d89226cd1e10648008bd21184cd89fe0
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,105 @@
#if UNITY_IOS
using AOT;
using UnityEngine;
using BigoAds.Scripts.Api.Constant;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Platforms.iOS;
using System.Runtime.InteropServices;
class BigoUnitySdk : ISDK
{
private BigoAdSdk.InitResultDelegate resultDelegate;
public void Init(BigoAdConfig config, BigoAdSdk.InitResultDelegate initResultDelegate)
{
BigoUnityConfig unityConfig = new BigoUnityConfig();
unityConfig.Init(config);
resultDelegate = initResultDelegate;
IntPtr ptr = (IntPtr)GCHandle.Alloc(this);
BigoIOS_initSDK(ptr, unityConfig.getInternalConfig(), cs_successCallback);
}
public bool IsInitSuccess()
{
return BigoIOS_sdkInitializationState();
}
public string GetSDKVersion()
{
return BigoIOS_sdkVersion();
}
public string GetSDKVersionName()
{
return BigoIOS_sdkVersionName();
}
public void SetUserConsent(ConsentOptions option, bool consent)
{
if (option == ConsentOptions.GDPR) {
BigoIOS_setConsentGDPR(consent);
} else if (option == ConsentOptions.CCPA) {
BigoIOS_setConsentCCPA(consent);
} else if (option == ConsentOptions.LGPD) {
BigoIOS_setConsentLGPD(consent);
} else if (option == ConsentOptions.COPPA) {
BigoIOS_setConsentCOPPA(consent);
}
}
public void AddExtraHost(string country, string host)
{
BigoIOS_addExtraHost(country, host);
}
[DllImport("__Internal")]
static extern void BigoIOS_initSDK(IntPtr unitySDK, IntPtr config, SuccessCallbackDelegate successCallback);
[DllImport("__Internal")]
static extern bool BigoIOS_sdkInitializationState();
[DllImport("__Internal")]
static extern string BigoIOS_sdkVersion();
[DllImport("__Internal")]
static extern string BigoIOS_sdkVersionName();
[DllImport("__Internal")]
static extern void BigoIOS_setConsentGDPR(bool consent);
[DllImport("__Internal")]
static extern void BigoIOS_setConsentCCPA(bool consent);
[DllImport("__Internal")]
static extern void BigoIOS_setConsentLGPD(bool consent);
[DllImport("__Internal")]
static extern void BigoIOS_setConsentCOPPA(bool consent);
[DllImport("__Internal")]
static extern void BigoIOS_addExtraHost(string country, string host);
private delegate void SuccessCallbackDelegate(IntPtr unitySDK);
[MonoPInvokeCallback(typeof(SuccessCallbackDelegate))]
private static void cs_successCallback(IntPtr unitySDK)
{
BigoUnitySdk sdk = GetUnitySdk(unitySDK);
sdk.resultDelegate();
}
private static BigoUnitySdk GetUnitySdk(IntPtr unitySdkPtr)
{
GCHandle handle = (GCHandle) unitySdkPtr;
BigoUnitySdk unitysdk = handle.Target as BigoUnitySdk;
return unitysdk;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0119df06271854e9497b8cab7cc3ef1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
#import <BigoADS/BigoADS.h>
#import "BigoUnityAdapterTools.h"
char* MakeStringCopy(const char* string) {
if (string == NULL) return NULL;
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
extern "C" {
typedef void (*BigoSDKInitSuccessCallBack)(void* unitySDK);
void BigoIOS_initSDK(void* unitySDK, void* config, BigoSDKInitSuccessCallBack successCallback) {
BigoAdConfig *adConfig = config ? (__bridge BigoAdConfig*)config : nil;
[[BigoAdSdk sharedInstance] initializeSdkWithAdConfig:adConfig completion:^{
successCallback(unitySDK);
}];
}
BOOL BigoIOS_sdkInitializationState() {
return [[BigoAdSdk sharedInstance] isInitialized];
}
const char* BigoIOS_sdkVersion() {
NSString *version = [[BigoAdSdk sharedInstance] getSDKVersion];
return MakeStringCopy([version UTF8String]);
}
const char* BigoIOS_sdkVersionName() {
NSString *versionName = [[BigoAdSdk sharedInstance] getSDKVersionName];
return MakeStringCopy([versionName UTF8String]);
}
void BigoIOS_setConsentGDPR(bool consent) {
[BigoAdSdk setUserConsentWithOption:BigoConsentOptionsGDPR consent:consent];
}
void BigoIOS_setConsentCCPA(bool consent) {
[BigoAdSdk setUserConsentWithOption:BigoConsentOptionsCCPA consent:consent];
}
void BigoIOS_setConsentCOPPA(bool consent) {
[BigoAdSdk setUserConsentWithOption:BigoConsentOptionsCOPPA consent:consent];
}
void BigoIOS_setConsentLGPD(bool consent) {
[BigoAdSdk setUserConsentWithOption:BigoConsentOptionsLGPD consent:consent];
}
void BigoIOS_addExtraHost(const char* country, const char* host) {
NSString *countryString = BigoIOS_transformNSStringForm(country);
NSString *hostString = BigoIOS_transformNSStringForm(host);
[BigoAdSdk addExtraHostWithCountry:countryString host:hostString];
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 2a926ae7c93f34a81ad8c0dca79dbe9f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
#if UNITY_IOS
using System.Collections.Generic;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
public class BigoUnityTools
{
private static int mainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
internal static bool isMainThread()
{
return System.Threading.Thread.CurrentThread.ManagedThreadId == mainThreadID;
}
internal static void LOGWithMessage(string className,string methodName,string msg)
{
Debug.Log($"BigoAds-iOS-[{className}]-[{methodName}]-{msg}");
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2171856213534228be217d8b18397ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3d154fcfff71f4a50bbcb02fe73c8a63
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
#if UNITY_IOS
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
class BigoUnityinterstitialAd : BigoIOSBaseAd, IInterstitialAd
{
public void Load(string slotId, BigoInterstitialRequest request)
{
adType = 3;
LoadAdData(slotId,request);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 439e9f1b2a72c4d52bbba125c8625121
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
#import "BigoUnityBaseAdHandler.h"
extern "C" {
//load appOpen Ad
void BigoIOS_loadInterstitialAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback);
//show open ad
void BigoIOS_showInterstitialAd(UnityAd unityAd);
}
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 09b930587afa743ca93ec5ae2d427b8a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
#import <BigoADS/BigoADS.h>
#import "UnityAppController.h"
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityAdHandlerManager.h"
extern "C"{
//load interstitial ad
void BigoIOS_loadInterstitialAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
) {
BigoIOS_dispatchSyncMainQueue(^{
BigoUnityInterstitialAdHandler *adHandler = [[BigoUnityInterstitialAdHandler alloc] init];
BigoInterstitialAdRequest *request = [[BigoInterstitialAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)];
NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson);
request.age = [requestDict[@"age"] intValue];
request.gender = (BigoAdGender)[requestDict[@"gender"] intValue];
request.activatedTime = [requestDict[@"activatedTime"] longLongValue];
BigoInterstitialAdLoader *adLoader = [[BigoInterstitialAdLoader alloc] initWithInterstitialAdLoaderDelegate:adHandler];
adLoader.ext = requestDict[@"extraInfo"];
adHandler.adLoader = adLoader;
adHandler.unityAd = unityAd;
adHandler.showCallback = showCallback;
adHandler.clickCallback = clickCallback;
adHandler.dismissCallback = dismissCallback;
adHandler.adErrorCallback = adErrorCallback;
adHandler.successCallback = successCallback;
adHandler.failCallback = failCallback;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
[BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey];
[adLoader loadAd:request];
});
}
BigoUnityInterstitialAdHandler* BigoIOS_getInterstitialAdHandler(UnityAd unityAd) {
if (!unityAd) return nil;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityInterstitialAdHandler *handler = (BigoUnityInterstitialAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
if (!handler || ![handler isMemberOfClass:[BigoUnityInterstitialAdHandler class]]) {
return nil;
}
return handler;
}
void BigoIOS_showInterstitialAd(UnityAd unityAd) {
BigoUnityInterstitialAdHandler *handler = BigoIOS_getInterstitialAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
BigoInterstitialAd *ad = (BigoInterstitialAd *)handler.ad;
[ad show:vc];
});
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 0ed50328a865a41e6a0c4c862dfc3a20
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 91d71cd2823ff4f758ffc2f9340dd36a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
#if UNITY_IOS
using System;
using System.Threading;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Api.Constant;
using BigoAds.Scripts.Common;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Platforms.iOS;
using System.Runtime.InteropServices;
public class BigoUnityNativeAd : BigoIOSBaseAd, INativeAd
{
public void Load(string slotId, BigoNativeRequest request)
{
adType = 1;
LoadAdData(slotId,request);
}
private int CalculatePositionY(BigoPosition position, int nativeHeight)
{
int screenHeight = BigoIOS_getScreenHeight();
float y = BigoIOS_getScreenSafeTop();
if (position == BigoPosition.Middle)
{
y = (float)((screenHeight - nativeHeight) * 0.5);
}
else if (position == BigoPosition.Bottom)
{
y = (float)(screenHeight - nativeHeight - BigoIOS_getScreenSafeBottom());
}
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position:{position},screenHeight:{screenHeight}-y:{y}");
return (int)y;
}
private int CalculateMiddleX(int nativeWidth)
{
int screenWidth = BigoIOS_getScreenWidth();
int x = (int)((screenWidth - nativeWidth) * 0.5);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"screenWidth:{screenWidth}-x:{x}");
return x;
}
public void SetPosition(BigoPosition position)
{
int x = 0;
int y = CalculatePositionY(position, 300); //dafault 300
BigoIOS_SetNativeAdPosition(unityAdPtr,x,y);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position-{position}");
}
//MARK: c# - oc
[DllImport("__Internal")]
static extern void BigoIOS_loadNativeAdData(IntPtr unityAdPtr,
string slotId,
string requestJson,
int x,
int y,
int width,
int height,
adDidLoadCallback_delegate successCallback,
adLoadFailCallBack_delegate failCallback,
adDidShowCallback_delegate showCallback,
adDidClickCallback_delegate clickCallback,
adDidDismissCallback_delegate dismissCallback
);
[DllImport("__Internal")]
static extern void BigoIOS_SetNativeAdPosition(IntPtr unityAdPtr, int x, int y);
[DllImport("__Internal")]
static extern int BigoIOS_getScreenWidth();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenHeight();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenSafeTop();
[DllImport("__Internal")]
static extern int BigoIOS_getScreenSafeBottom();
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2826ac57d309146a69194c7d0ba5764b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,21 @@
#import "BigoUnityBaseAdHandler.h"
extern "C" {
//load Native ad
void BigoIOS_loadNativeAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
);
void BigoIOS_SetNativeAdPosition(UnityAd unityAd,int x, int y);
void BigoIOS_showNativeAd(UnityAd unityAd);
void BigoIOS_removeNativeView(UnityAd unityAd);
}
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 7e57a1c9615984eaa8fcabfd30911db3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,102 @@
#import <BigoADS/BigoADS.h>
#import "UnityAppController.h"
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityAdHandlerManager.h"
#import "BigoUnityNativeCustomView.h"
extern "C"{
//load interstitial ad
void BigoIOS_loadNativeAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
) {
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
BigoUnityNativeCustomView *nativeView = [[BigoUnityNativeCustomView alloc] initWithFrame:CGRectMake(0, 0, vc.view.frame.size.width, 300)];
NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson);
BigoUnityNativeAdHandler *adHandler = [[BigoUnityNativeAdHandler alloc] init];
BigoNativeAdRequest *request = [[BigoNativeAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)];
request.age = [requestDict[@"age"] intValue];
request.gender = (BigoAdGender)[requestDict[@"gender"] intValue];
request.activatedTime = [requestDict[@"activatedTime"] longLongValue];
BigoNativeAdLoader *adLoader = [[BigoNativeAdLoader alloc] initWithNativeAdLoaderDelegate:adHandler];
adLoader.ext = requestDict[@"extraInfo"];
adHandler.nativeView = nativeView;
adHandler.adLoader = adLoader;
adHandler.unityAd = unityAd;
adHandler.showCallback = showCallback;
adHandler.clickCallback = clickCallback;
adHandler.dismissCallback = dismissCallback;
adHandler.adErrorCallback = adErrorCallback;
adHandler.successCallback = successCallback;
adHandler.failCallback = failCallback;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
[BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey];
[adLoader loadAd:request];
});
}
BigoUnityNativeAdHandler* BigoIOS_getNativeAdHandler(UnityAd unityAd) {
if (!unityAd) return nil;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityNativeAdHandler *handler = (BigoUnityNativeAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
if (!handler || ![handler isMemberOfClass:[BigoUnityNativeAdHandler class]]) {
return nil;
}
return handler;
}
void BigoIOS_showNativeAd(UnityAd unityAd) {
BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
BigoNativeAd *ad = (BigoNativeAd *)handler.ad;
//render
BigoUnityNativeCustomView *nativeView = (BigoUnityNativeCustomView *)handler.nativeView;
[ad registerViewForInteraction:nativeView mediaView:nativeView.mediaView adIconView:nativeView.adIconView adOptionsView:nativeView.adOptionsView clickableViews:nativeView.clickAbleViews];
[nativeView refreshNativeView:ad];
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
CGRect frame = nativeView.frame;
frame.origin.y = screenHeight - frame.size.height;
nativeView.frame = frame;
[vc.view addSubview:handler.nativeView];
});
}
void BigoIOS_SetNativeAdPosition(UnityAd unityAd,int x, int y) {
BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
CGRect frame = handler.nativeView.frame;
frame.origin.x = x;
frame.origin.y = y;
handler.nativeView.frame = frame;
});
}
void BigoIOS_removeNativeView(UnityAd unityAd) {
BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
[handler.nativeView removeFromSuperview];
});
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 6e061b29b36eb4be7a56af7098092fb3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
#import <UIKit/UIKit.h>
#import <BigoADS/BigoADS.h>
@interface BigoUnityNativeCustomView : UIView
@property (nonatomic, strong) BigoAdMediaView *mediaView;
@property (nonatomic, strong) UIImageView *adIconView;
@property (nonatomic, strong) BigoAdOptionsView *adOptionsView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UIButton *cta;
- (NSArray<UIView *> *)clickAbleViews;
- (void)refreshNativeView:(BigoNativeAd *)nativeAd;
@end
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 1d74138abaf434fd38dce6301cac1107
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,72 @@
#import "BigoUnityNativeCustomView.h"
@implementation BigoUnityNativeCustomView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = UIColor.whiteColor;
self.mediaView = [BigoAdMediaView new];
self.mediaView.bigoNativeAdViewTag = BigoNativeAdViewTagMedia;
self.mediaView.frame = CGRectMake(0, 50, CGRectGetWidth(self.bounds) , CGRectGetHeight(self.bounds) - 100);
self.adIconView = [UIImageView new];
self.adIconView.bigoNativeAdViewTag = BigoNativeAdViewTagIcon;
self.adIconView.frame = CGRectMake(0, 0, 50, 50);
self.cta = [UIButton new];
self.cta.bigoNativeAdViewTag = BigoNativeAdViewTagCallToAction;
self.cta.titleLabel.textColor = [UIColor colorWithRed:0 green:0 blue:255 alpha:255];
self.cta.bigoNativeAdViewTag = BigoNativeAdViewTagCallToAction;
[self.cta setBackgroundColor:[UIColor grayColor]];
self.adOptionsView = [BigoAdOptionsView new];
self.adOptionsView.bigoNativeAdViewTag = BigoNativeAdViewTagOption;
self.adOptionsView.frame = CGRectMake(CGRectGetWidth(self.bounds) - 20, 0, 20, 20);
[self addSubview:self.mediaView];
[self addSubview:self.adOptionsView];
[self addSubview:self.adIconView];
[self addSubview:self.cta];
self.titleLabel = UILabel.new;
self.titleLabel.textColor = UIColor.blackColor;
self.titleLabel.bigoNativeAdViewTag = BigoNativeAdViewTagTitle;
self.titleLabel.font = [UIFont systemFontOfSize:18];
[self addSubview:self.titleLabel];
self.detailLabel = UILabel.new;
self.detailLabel.textColor = UIColor.lightGrayColor;
self.detailLabel.bigoNativeAdViewTag = BigoNativeAdViewTagDescription;
self.detailLabel.font = [UIFont systemFontOfSize:18];
[self addSubview:self.detailLabel];
self.titleLabel.frame = CGRectMake(65, 5, CGRectGetWidth(self.bounds)-95, 20);
self.detailLabel.frame = CGRectMake(65, 30, CGRectGetWidth(self.bounds)-95, 20);
self.cta.frame = CGRectMake(CGRectGetWidth(self.bounds)-100, 250, 100, 50);
}
return self;
}
- (NSArray<UIView *> *)clickAbleViews {
return @[self.adIconView, self.titleLabel, self.detailLabel, self.cta];
}
- (void)refreshNativeView:(BigoNativeAd *)nativeAd {
self.titleLabel.text = nativeAd.title;
self.detailLabel.text = nativeAd.adDescription;
NSString *ctaTitle = nativeAd.callToAction.length > 0 ? nativeAd.callToAction : @"Install";
[self.cta setTitle:ctaTitle forState:UIControlStateNormal];
//设置按钮选择状态下的标题
[self.cta setTitle:ctaTitle forState:UIControlStateSelected];
//设置按钮高亮状态下的标题
[self.cta setTitle:ctaTitle forState:UIControlStateHighlighted];
}
@end
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: d9e95ef6076f8408a98e195f9786007a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 24e19875a9807479e8e67ede8568a37d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
#if UNITY_IOS
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
class BigoUnitypopupAd : BigoIOSBaseAd, IPopupAd
{
public void Load(string slotId, BigoPopupRequest request)
{
adType = 6;
LoadAdData(slotId,request);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6db3f7d6fb1a84a6eb484a3a8de4498a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
#import "BigoUnityBaseAdHandler.h"
extern "C" {
//load appOpen Ad
void BigoIOS_loadPopupAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback);
//show open ad
void BigoIOS_showPopupAd(UnityAd unityAd);
}
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 60f143a983fcf474f9c68938033d595e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
#import <BigoADS/BigoADS.h>
#import "UnityAppController.h"
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityAdHandlerManager.h"
extern "C"{
//load popup ad
void BigoIOS_loadPopupAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback
) {
}
void BigoIOS_showPopupAd(UnityAd unityAd) {
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 1216b7bb5404a4e478138d98a4ceabc8
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc24c03453ca84472831cbe13d0cd70d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,63 @@
#if UNITY_IOS
using System.Collections.Generic;
using AOT;
using UnityEngine;
namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd
{
using System;
using BigoAds.Scripts.Api;
using BigoAds.Scripts.Common;
using BigoAds.Scripts.Platforms.iOS;
using System.Runtime.InteropServices;
class BigoUnityRewardedAd : BigoIOSBaseAd, IRewardedAd
{
public event Action OnUserEarnedReward;
public void Load(string slotId, BigoRewardedRequest request)
{
adType = 4;
this.unityAdPtr = (IntPtr)GCHandle.Alloc (this);
IntPtr ptr = this.unityAdPtr;
BigoIOS_loadRewardedAdData(ptr,
slotId,
request.ToJson(),
cs_adDidLoadCallback,
cs_adLoadFailCallBack,
cs_adDidShowCallback,
cs_adDidClickCallback,
cs_adDidDismissCallback,
cs_adDidErrorCallBack,
cs_adDidEarnRewardCallback);
LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"slotId:{slotId},request{request}");
}
// c-> oc
[DllImport("__Internal")]
static extern void BigoIOS_loadRewardedAdData(IntPtr unityAd,
string slotId,
string requestJson,
adDidLoadCallback_delegate successCallback,
adLoadFailCallBack_delegate failCallback,
adDidShowCallback_delegate showCallback,
adDidClickCallback_delegate clickCallback,
adDidDismissCallback_delegate dismissCallback,
adDidErrorCallback_delegate adErrorCallback,
adDidEarnRewardCallback_delegate earnCallback);
private delegate void adDidEarnRewardCallback_delegate(IntPtr unityAdPtr);
[MonoPInvokeCallback(typeof(adDidEarnRewardCallback_delegate))]
private static void cs_adDidEarnRewardCallback(IntPtr unityAdPtr)
{
BigoUnityRewardedAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr) as BigoUnityRewardedAd;
if (unityAd == null)
{
return;
}
unityAd.OnUserEarnedReward?.Invoke();
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 63ac6f7f8298c4f2585c4847b19ae90d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
#import "BigoUnityBaseAdHandler.h"
extern "C" {
//load Rewarded Ad
void BigoIOS_loadRewardedAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback,
AdDidEarnRewardCallback earnCallback);
//show open ad
void BigoIOS_showRewardedAd(UnityAd unityAd);
}
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 780f30ce3796b4a89a92aa7e746d76bd
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,69 @@
#import <BigoADS/BigoADS.h>
#import "UnityAppController.h"
#import "BigoUnityBaseAdHandler.h"
#import "BigoUnityAdapterTools.h"
#import "BigoUnityAdHandlerManager.h"
extern "C"{
//load rewarded ad
void BigoIOS_loadRewardedAdData(UnityAd unityAd,
const char *slotId,
const char *requestJson,
AdDidLoadCallback successCallback,
AdLoadFailCallBack failCallback,
AdDidShowCallback showCallback,
AdDidClickCallback clickCallback,
AdDidDismissCallback dismissCallback,
AdDidErrorCallback adErrorCallback,
AdDidEarnRewardCallback earnCallback
) {
BigoIOS_dispatchSyncMainQueue(^{
BigoUnityRewardedAdHandler *adHandler = [[BigoUnityRewardedAdHandler alloc] init];
BigoRewardVideoAdRequest *request = [[BigoRewardVideoAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)];
NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson);
request.age = [requestDict[@"age"] intValue];
request.gender = (BigoAdGender)[requestDict[@"gender"] intValue];
request.activatedTime = [requestDict[@"activatedTime"] longLongValue];
BigoRewardVideoAdLoader *adLoader = [[BigoRewardVideoAdLoader alloc] initWithRewardVideoAdLoaderDelegate:adHandler];
adLoader.ext = requestDict[@"extraInfo"];
adHandler.adLoader = adLoader;
adHandler.unityAd = unityAd;
adHandler.showCallback = showCallback;
adHandler.clickCallback = clickCallback;
adHandler.dismissCallback = dismissCallback;
adHandler.adErrorCallback = adErrorCallback;
adHandler.successCallback = successCallback;
adHandler.failCallback = failCallback;
adHandler.earnCallback = earnCallback;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
[BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey];
[adLoader loadAd:request];
});
}
BigoUnityRewardedAdHandler* BigoIOS_getRewardedAdHandler(UnityAd unityAd) {
if (!unityAd) return nil;
NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd];
BigoUnityRewardedAdHandler *handler = (BigoUnityRewardedAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey];
if (!handler || ![handler isMemberOfClass:[BigoUnityRewardedAdHandler class]]) {
return nil;
}
return handler;
}
void BigoIOS_showRewardedAd(UnityAd unityAd) {
BigoUnityRewardedAdHandler *handler = BigoIOS_getRewardedAdHandler(unityAd);
if (!handler) return;
BigoIOS_dispatchSyncMainQueue(^{
UIViewController *vc = GetAppController().rootViewController;
BigoRewardVideoAd *ad = (BigoRewardVideoAd *)handler.ad;
[ad show:vc];
});
}
}
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: d8fabace3a5bc43d1909e6d2e3d11b76
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7f81b17e4602f4d049f2f1679dd986df
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,24 @@
//
// BGSplashAdViewController.h
// demo
//
// Created by cai on 2022/5/23.
//
#import <UIKit/UIKit.h>
#import <BigoADS/BigoSplashAd.h>
#import "BigoUnityBaseAdHandler.h"
NS_ASSUME_NONNULL_BEGIN
@interface BGSplashAdViewController : UIViewController
@property (nonatomic, strong) UIViewController *rootVC;
@property (nonatomic, strong) BigoSplashAd *ad;
@property (nonatomic, weak) BigoUnitySplashAdHandler *adHandle;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: fb04cd43cee464aaca615d708992dd8c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
//
// BGSplashAdViewController.m
// demo
//
// Created by cai on 2022/5/23.
//
#import "BGSplashAdViewController.h"
@interface BGSplashAdViewController () <BigoSplashAdInteractionDelegate>
@end
@implementation BGSplashAdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.ad setSplashAdInteractionDelegate:self];
[self.ad showInAdContainer:self.view];
}
- (void)dismissSplashController:(BigoAd *)ad {
[self.adHandle onAdClosed:ad];
[[UIApplication sharedApplication].keyWindow setRootViewController:self.rootVC];
}
/**
* 广告可跳过回调,通常是由用户点击了右上角 SKIP 按钮所触发
*/
- (void)onAdSkipped:(BigoAd *)ad {
[self dismissSplashController:ad];
}
/**
* 广告倒计时结束回调
*/
- (void)onAdFinished:(BigoAd *)ad {
}
- (void)onAd:(BigoAd *)ad error:(BigoAdError *)error {
[self dismissSplashController:ad];
}
//广告展示
- (void)onAdImpression:(BigoAd *)ad {
[self.adHandle onAdImpression:ad];
}
//广告点击
- (void)onAdClicked:(BigoAd *)ad {
[self.adHandle onAdClicked:ad];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
@end
@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 39e7476be840e4443b46b46741933efe
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More