添加bigo sdk 修改kwai AndroidPlatformTools类名
This commit is contained in:
parent
8767c379ed
commit
51f2024e7f
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bd0ef81b1482347b38905fab4f30e583
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 467aa0b9eadf04b22b5b3713a1b07bea
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1dd438e36fdc745aaa018eac5d3b182c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,115 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoAdConfig
|
||||||
|
{
|
||||||
|
public const string EXTRA_KEY_HOST_RULES = "host_rules";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the unique identifier of the App
|
||||||
|
/// </summary>
|
||||||
|
internal string AppId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom set the debugLog to print debug Log.
|
||||||
|
/// debugLog NO: close debug log, YES: open debug log.
|
||||||
|
/// </summary>
|
||||||
|
internal bool DebugLog { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Channels for publishing media applications
|
||||||
|
/// </summary>
|
||||||
|
internal string Channel { get; }
|
||||||
|
|
||||||
|
internal int Age { get; }
|
||||||
|
|
||||||
|
internal int Gender { get; }
|
||||||
|
|
||||||
|
internal long ActivatedTime { get; }
|
||||||
|
|
||||||
|
internal Dictionary<string, string> ExtraDictionary { get; }
|
||||||
|
|
||||||
|
private BigoAdConfig(BigoAdConfig.Builder builder)
|
||||||
|
{
|
||||||
|
AppId = builder.AppId;
|
||||||
|
DebugLog = builder.DebugLog;
|
||||||
|
Channel = builder.Channel;
|
||||||
|
Age = builder.Age;
|
||||||
|
Gender = (int)builder.Gender;
|
||||||
|
ActivatedTime = builder.ActivatedTime;
|
||||||
|
ExtraDictionary = builder.ExtraDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Builder
|
||||||
|
{
|
||||||
|
internal string AppId;
|
||||||
|
|
||||||
|
internal bool DebugLog;
|
||||||
|
|
||||||
|
internal string Channel;
|
||||||
|
|
||||||
|
internal int Age;
|
||||||
|
|
||||||
|
internal BGAdGender Gender;
|
||||||
|
|
||||||
|
internal long ActivatedTime;
|
||||||
|
|
||||||
|
internal Dictionary<string, string> ExtraDictionary = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
public Builder SetAppId(string appid)
|
||||||
|
{
|
||||||
|
this.AppId = appid;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder SetDebugLog(bool debugLog)
|
||||||
|
{
|
||||||
|
this.DebugLog = debugLog;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder SetChannel(string channel)
|
||||||
|
{
|
||||||
|
this.Channel = channel;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder SetAge(int age)
|
||||||
|
{
|
||||||
|
this.Age = age;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder SetGender(BGAdGender gender)
|
||||||
|
{
|
||||||
|
this.Gender = gender;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder SetActivatedTime(long activatedTime)
|
||||||
|
{
|
||||||
|
this.ActivatedTime = activatedTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
///Only works on Android
|
||||||
|
public Builder SetExtra(string key, string extra)
|
||||||
|
{
|
||||||
|
if (key != null && extra != null)
|
||||||
|
{
|
||||||
|
this.ExtraDictionary.Add(key, extra);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigoAdConfig Build()
|
||||||
|
{
|
||||||
|
return new BigoAdConfig(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b18497a84c58a49f385b63be54aff0cb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,106 @@
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public static class BigoAdSdk
|
||||||
|
{
|
||||||
|
private static IClientFactory _clientFactory;
|
||||||
|
|
||||||
|
private static ISDK _sdk;
|
||||||
|
|
||||||
|
internal static ISDK SDK
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_sdk == null)
|
||||||
|
{
|
||||||
|
_sdk = GetClientFactory().BuildSDKClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _sdk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static IClientFactory GetClientFactory()
|
||||||
|
{
|
||||||
|
if (_clientFactory != null)
|
||||||
|
{
|
||||||
|
return _clientFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
_clientFactory =
|
||||||
|
#if UNITY_ANDROID
|
||||||
|
new BigoAds.Scripts.Platforms.Android.AndroidClientFactory();
|
||||||
|
#elif UNITY_IOS
|
||||||
|
new BigoAds.Scripts.Platforms.iOS.IOSClientFactory();
|
||||||
|
#else
|
||||||
|
null;
|
||||||
|
throw new PlatformNotSupportedException();
|
||||||
|
#endif
|
||||||
|
return _clientFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void InitResultDelegate();
|
||||||
|
|
||||||
|
public static event InitResultDelegate OnInitFinish;
|
||||||
|
|
||||||
|
/// Starts the Bigo SDK
|
||||||
|
/// @warning Call this method as early as possible to reduce ad request fail.
|
||||||
|
/// @param config SDK configuration
|
||||||
|
/// @param callback Callback for starting the Bigo SDK
|
||||||
|
/// ////
|
||||||
|
public static void Initialize(BigoAdConfig config)
|
||||||
|
{
|
||||||
|
if (IsInitSuccess())
|
||||||
|
{
|
||||||
|
OnInitFinish?.Invoke();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDK.Init(config, (() => { OnInitFinish?.Invoke(); }));
|
||||||
|
}
|
||||||
|
|
||||||
|
////
|
||||||
|
/// The SDK initialization state
|
||||||
|
////
|
||||||
|
public static bool IsInitSuccess()
|
||||||
|
{
|
||||||
|
return SDK.IsInitSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK version
|
||||||
|
/// ////
|
||||||
|
public static string GetSDKVersion()
|
||||||
|
{
|
||||||
|
return SDK.GetSDKVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK version name
|
||||||
|
/// ////
|
||||||
|
public static string GetSDKVersionName()
|
||||||
|
{
|
||||||
|
return SDK.GetSDKVersionName();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK set user consent
|
||||||
|
/// ////
|
||||||
|
public static void SetUserConsent(ConsentOptions option, bool consent)
|
||||||
|
{
|
||||||
|
SDK.SetUserConsent(option, consent);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Only works on Android
|
||||||
|
/// Bigo SDK set user consent
|
||||||
|
/// ////
|
||||||
|
public static void AddExtraHost(string country, string host)
|
||||||
|
{
|
||||||
|
SDK.AddExtraHost(country, host);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5ad9c8c265954d4e8f4f03312b5fa42
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,30 @@
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoBannerAd : BigoBaseAd<BigoBannerRequest>
|
||||||
|
{
|
||||||
|
private readonly IBannerAd _bannerAdClient;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// create a banner ad
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slotId"></param>
|
||||||
|
public BigoBannerAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildBannerAdClient())
|
||||||
|
{
|
||||||
|
_bannerAdClient = (IBannerAd) ADClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set position for banner
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
public void SetPosition(BigoPosition position)
|
||||||
|
{
|
||||||
|
_bannerAdClient?.SetPosition(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5136d466cbb6c461f92fbd90b6fa157d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class BigoBannerRequest : BigoRequest
|
||||||
|
{
|
||||||
|
[SerializeField()]
|
||||||
|
private BigoBannerSize size;
|
||||||
|
public BigoBannerSize Size => size;
|
||||||
|
|
||||||
|
public BigoPosition Position { get; }
|
||||||
|
|
||||||
|
public BigoBannerRequest(BigoBannerSize size, BigoPosition position = BigoPosition.Bottom)
|
||||||
|
{
|
||||||
|
this.size = size;
|
||||||
|
this.Position = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 159c6164853954739adbca1ae7592df7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoInterstitialAd : BigoBaseAd<BigoInterstitialRequest>
|
||||||
|
{
|
||||||
|
public BigoInterstitialAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildInterstitialAdClient())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1323eae1e03094d8281b23f5527a53db
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
|
||||||
|
public class BigoInterstitialRequest : BigoRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1947fd630823b4858af6c3a471497f70
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoNativeAd : BigoBaseAd<BigoNativeRequest>
|
||||||
|
{
|
||||||
|
private readonly INativeAd _NativeAdClient;
|
||||||
|
|
||||||
|
public BigoNativeAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildNativeAdClient())
|
||||||
|
{
|
||||||
|
_NativeAdClient = (INativeAd) ADClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set position for native
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
public void SetPosition(BigoPosition position)
|
||||||
|
{
|
||||||
|
_NativeAdClient?.SetPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1742d1ee2ff5e4d508ae81524cb94ade
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class BigoNativeRequest : BigoRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 033c30386f5714bddb5dd41d7524979e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoPopupAd : BigoBaseAd<BigoPopupRequest>
|
||||||
|
{
|
||||||
|
public BigoPopupAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildPopupAdClient())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2be0a8fe9e5aa4bea8970a47e617a076
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
|
||||||
|
public class BigoPopupRequest : BigoRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 580aad20fbde543bab37a5e878c682cb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class BigoRequest
|
||||||
|
{
|
||||||
|
[SerializeField] private string extraInfo;
|
||||||
|
[SerializeField] private int age;
|
||||||
|
[SerializeField] private BGAdGender gender;
|
||||||
|
[SerializeField] private long activatedTime;
|
||||||
|
|
||||||
|
public string ExtraInfoJson
|
||||||
|
{
|
||||||
|
get => extraInfo;
|
||||||
|
set => extraInfo = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Only works on Android
|
||||||
|
public int Age
|
||||||
|
{
|
||||||
|
get => age;
|
||||||
|
set => age = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Only works on Android
|
||||||
|
public BGAdGender Gender
|
||||||
|
{
|
||||||
|
get => gender;
|
||||||
|
set => gender = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Only works on Android
|
||||||
|
public long ActivatedTime
|
||||||
|
{
|
||||||
|
get => activatedTime;
|
||||||
|
set => activatedTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToJson()
|
||||||
|
{
|
||||||
|
return JsonUtility.ToJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2707ffe474e6443d6a5260876d5b1370
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoRewardedAd : BigoBaseAd<BigoRewardedRequest>
|
||||||
|
{
|
||||||
|
public event Action OnUserEarnedReward;
|
||||||
|
|
||||||
|
public BigoRewardedAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildRewardedAdClient())
|
||||||
|
{
|
||||||
|
var rewardedAdClient = (IRewardedAd) ADClient;
|
||||||
|
rewardedAdClient.OnUserEarnedReward += InvokeOnUserEarnedReward;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void InvokeOnUserEarnedReward()
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnUserEarnedReward?.Invoke(); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnUserEarnedReward?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f745c8797b25430685a5a08b34f0d9f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
|
||||||
|
public class BigoRewardedRequest : BigoRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 38f4a763a1fc9429ca87c62eed4b4645
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
||||||
|
using BigoAds.Scripts.Common;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
public class BigoSplashAd : BigoBaseAd<BigoSplashRequest>
|
||||||
|
{
|
||||||
|
public BigoSplashAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildSplashAdClient())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 61b62ca232d2e42788e61f33d7784209
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
|
||||||
|
public class BigoSplashRequest : BigoRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: afdf808922a744419b5db1fdd4ca18b9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0762cd7e46c3c43e5a32b1558643eb74
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
namespace BigoAds.Scripts.Api.Constant
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public enum BGAdGender
|
||||||
|
{
|
||||||
|
Female = 1,
|
||||||
|
Male = 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2784802c5b5b34470a0500118ccb7f55
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api.Constant
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public enum BGAdLossReason
|
||||||
|
{
|
||||||
|
InternalError = 1,
|
||||||
|
Timeout = 2,
|
||||||
|
LowerThanFloorPrice = 100,
|
||||||
|
LowerThanHighestPrice = 101
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 303b2e25e09c44797a167b642310a319
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api.Constant
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public struct BigoBannerSize
|
||||||
|
{
|
||||||
|
public static readonly BigoBannerSize BANNER_W_320_H_50 = new BigoBannerSize(320,50);
|
||||||
|
public static readonly BigoBannerSize BANNER_W_300_H_250 = new BigoBannerSize(300,250);
|
||||||
|
|
||||||
|
[SerializeField] private int width;
|
||||||
|
[SerializeField] private int height;
|
||||||
|
public int Width => width;
|
||||||
|
public int Height => height;
|
||||||
|
|
||||||
|
public BigoBannerSize(int width, int height)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4a4411a50cfc94717b30325ceed3d52f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api.Constant
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public enum BigoPosition
|
||||||
|
{
|
||||||
|
Top = 0,
|
||||||
|
Middle = 1,
|
||||||
|
Bottom = 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6511065ffc7f44235bacb3ee16a87f5a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Api.Constant
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public enum ConsentOptions
|
||||||
|
{
|
||||||
|
GDPR,
|
||||||
|
CCPA,
|
||||||
|
LGPD,
|
||||||
|
COPPA
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7867ac15c426649a6aa633a772d54879
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b4db2c2875384f11b89eb7dec28b823
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,218 @@
|
||||||
|
using System;
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public class BigoBaseAd<T> where T : BigoRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// event for load ad success
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnLoad;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// load ad failed with error code and error message
|
||||||
|
/// </summary>
|
||||||
|
public event Action<int, string> OnLoadFailed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// event for ad impression
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnAdShowed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// event for ad be clicked
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnAdClicked;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// event for ad be closed
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnAdDismissed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// event for ad error
|
||||||
|
/// </summary>
|
||||||
|
public event Action<int, string> OnAdError;
|
||||||
|
|
||||||
|
private readonly string _slotId;
|
||||||
|
|
||||||
|
private bool _isAdLoaded;
|
||||||
|
|
||||||
|
protected readonly IBigoAd<T> ADClient;
|
||||||
|
|
||||||
|
public bool CallbackOnMainThread { get; set; } = true;
|
||||||
|
|
||||||
|
private BigoAdBid _bid;
|
||||||
|
|
||||||
|
protected BigoBaseAd(string id, IBigoAd<T> adClient)
|
||||||
|
{
|
||||||
|
_slotId = id;
|
||||||
|
ADClient = adClient;
|
||||||
|
InitEvent(ADClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitEvent(IBigoAd<T> adClient)
|
||||||
|
{
|
||||||
|
adClient.OnLoad += InvokeOnLoad;
|
||||||
|
adClient.OnLoadFailed += InvokeOnLoadFailed;
|
||||||
|
|
||||||
|
adClient.OnAdShowed += InvokeOnAdShowed;
|
||||||
|
adClient.OnAdClicked += InvokeOnAdClicked;
|
||||||
|
adClient.OnAdDismissed += InvokeOnAdDismissed;
|
||||||
|
adClient.OnAdError += InvokeOnAdError;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Load(T request)
|
||||||
|
{
|
||||||
|
if (_isAdLoaded)
|
||||||
|
{
|
||||||
|
InvokeOnLoad();
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(_slotId))
|
||||||
|
{
|
||||||
|
InvokeOnLoadFailed(-1, "slotId must be not null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BigoAdSdk.IsInitSuccess())
|
||||||
|
{
|
||||||
|
InvokeOnLoadFailed(-1, "sdk has not init");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ADClient?.Load(_slotId, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Show()
|
||||||
|
{
|
||||||
|
_isAdLoaded = false;
|
||||||
|
ADClient?.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DestroyAd()
|
||||||
|
{
|
||||||
|
ADClient?.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsLoaded()
|
||||||
|
{
|
||||||
|
return _isAdLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExpired()
|
||||||
|
{
|
||||||
|
return ADClient == null ? false : ADClient.IsExpired();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetExtraInfo(String key)
|
||||||
|
{
|
||||||
|
return ADClient == null ? "" : ADClient.GetExtraInfo(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeOnLoad()
|
||||||
|
{
|
||||||
|
OnLoad?.Invoke();
|
||||||
|
_isAdLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void InvokeOnLoadFailed(int errorCode, string errorMessage)
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnLoadFailed?.Invoke(errorCode, errorMessage); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnLoadFailed?.Invoke(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void InvokeOnAdShowed()
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnAdShowed?.Invoke(); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnAdShowed?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeOnAdClicked()
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnAdClicked?.Invoke(); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnAdClicked?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeOnAdDismissed()
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnAdDismissed?.Invoke(); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnAdDismissed?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeOnAdError(int errorCode, string errorMessage)
|
||||||
|
{
|
||||||
|
if (CallbackOnMainThread)
|
||||||
|
{
|
||||||
|
BigoDispatcher.PostTask((() => { OnAdError?.Invoke(errorCode, errorMessage); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnAdError?.Invoke(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigoAdBid GetBid()
|
||||||
|
{
|
||||||
|
if (ADClient == null) return null;
|
||||||
|
if (!ADClient.IsClientBidding()) return null;
|
||||||
|
if (_bid == null)
|
||||||
|
{
|
||||||
|
_bid = new BigoAdBid(ADClient);
|
||||||
|
}
|
||||||
|
return _bid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BigoAdBid : IClientBidding
|
||||||
|
{
|
||||||
|
protected readonly IBigoAd<T> _ADClient;
|
||||||
|
|
||||||
|
public BigoAdBid(IBigoAd<T> ADClient)
|
||||||
|
{
|
||||||
|
_ADClient = ADClient;
|
||||||
|
}
|
||||||
|
/// get price
|
||||||
|
public double getPrice()
|
||||||
|
{
|
||||||
|
return _ADClient == null ? 0 : _ADClient.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
///notify win
|
||||||
|
public void notifyWin(double secPrice, string secBidder)
|
||||||
|
{
|
||||||
|
_ADClient?.notifyWin(secPrice, secBidder);
|
||||||
|
}
|
||||||
|
|
||||||
|
///notify loss
|
||||||
|
public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason)
|
||||||
|
{
|
||||||
|
_ADClient?.notifyLoss(firstPrice, firstBidder, lossReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8554386bfcec3403cb6fab89c7a35f31
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,86 @@
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The unity thread dispatcher.
|
||||||
|
/// </summary>
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
internal sealed class BigoDispatcher : MonoBehaviour
|
||||||
|
{
|
||||||
|
private static bool _instanceCreated;
|
||||||
|
|
||||||
|
// The thread safe task queue.
|
||||||
|
private static readonly List<Action> PostTasks = new List<Action>();
|
||||||
|
|
||||||
|
// The executing buffer.
|
||||||
|
private static readonly List<Action> Executing = new List<Action>();
|
||||||
|
|
||||||
|
static BigoDispatcher()
|
||||||
|
{
|
||||||
|
CreateInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Work thread post a task to the main thread.
|
||||||
|
/// </summary>
|
||||||
|
public static void PostTask(Action task)
|
||||||
|
{
|
||||||
|
lock (PostTasks)
|
||||||
|
{
|
||||||
|
PostTasks.Add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start to run this dispatcher.
|
||||||
|
/// </summary>
|
||||||
|
[RuntimeInitializeOnLoadMethod]
|
||||||
|
private static void CreateInstance()
|
||||||
|
{
|
||||||
|
if (_instanceCreated || !Application.isPlaying) return;
|
||||||
|
var go = new GameObject(
|
||||||
|
"BigoDispatcher", typeof(BigoDispatcher));
|
||||||
|
DontDestroyOnLoad(go);
|
||||||
|
_instanceCreated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
lock (PostTasks)
|
||||||
|
{
|
||||||
|
PostTasks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Executing.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
lock (PostTasks)
|
||||||
|
{
|
||||||
|
if (PostTasks.Count > 0)
|
||||||
|
{
|
||||||
|
Executing.AddRange(PostTasks);
|
||||||
|
PostTasks.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var task in Executing)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
task();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.Message, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Executing.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d1af23e5ee93476382ea747bb4b6985
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IBannerAd : IBigoAd<BigoBannerRequest>
|
||||||
|
{
|
||||||
|
void SetPosition(BigoPosition position);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9632da3a0b8674b539385af7fec47c33
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IBigoAd<in T> : IClientBidding where T : BigoRequest
|
||||||
|
{
|
||||||
|
event Action OnLoad;
|
||||||
|
event Action<int, string> OnLoadFailed;
|
||||||
|
event Action OnAdShowed;
|
||||||
|
event Action OnAdClicked;
|
||||||
|
event Action OnAdDismissed;
|
||||||
|
event Action<int, string> OnAdError;
|
||||||
|
void Load(string slotId, T request);
|
||||||
|
bool IsLoaded();
|
||||||
|
bool IsExpired();
|
||||||
|
void Show();
|
||||||
|
void Destroy();
|
||||||
|
bool IsClientBidding();
|
||||||
|
string GetExtraInfo(String key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ac3c835ae5b8f421192fb72d32c9c6c1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IClientBidding
|
||||||
|
{
|
||||||
|
/// get price
|
||||||
|
double getPrice();
|
||||||
|
|
||||||
|
///notify win
|
||||||
|
void notifyWin(double secPrice, string secBidder);
|
||||||
|
|
||||||
|
///notify loss
|
||||||
|
void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be474d5a8f44740eeac370fd98153d15
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IClientFactory
|
||||||
|
{
|
||||||
|
ISDK BuildSDKClient();
|
||||||
|
IBannerAd BuildBannerAdClient();
|
||||||
|
INativeAd BuildNativeAdClient();
|
||||||
|
IInterstitialAd BuildInterstitialAdClient();
|
||||||
|
IPopupAd BuildPopupAdClient();
|
||||||
|
ISplashAd BuildSplashAdClient();
|
||||||
|
IRewardedAd BuildRewardedAdClient();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2cb5f6ac1b7f463db75ac0bfa7d7fbe
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IInterstitialAd : IBigoAd<BigoInterstitialRequest>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d31ee1df8a074b81a5575e9a7735b2a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface INativeAd : IBigoAd<BigoNativeRequest>
|
||||||
|
{
|
||||||
|
void SetPosition(BigoPosition position);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eef5c6b4f590c4ceaac635a2992576ef
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IPopupAd : IBigoAd<BigoPopupRequest>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e767b9004c4f4ca19baa6f54c409c5d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface IRewardedAd : IBigoAd<BigoRewardedRequest>
|
||||||
|
{
|
||||||
|
event Action OnUserEarnedReward;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0b3baa8d362724d19997664f34f4320d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,40 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
using BigoAds.Scripts.Api.Constant;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface ISDK
|
||||||
|
{
|
||||||
|
///
|
||||||
|
/// Starts the Bigo SDK
|
||||||
|
///
|
||||||
|
void Init(BigoAdConfig config, BigoAdSdk.InitResultDelegate initResultDelegate);
|
||||||
|
|
||||||
|
////
|
||||||
|
/// The SDK initialization state
|
||||||
|
////
|
||||||
|
bool IsInitSuccess();
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK version
|
||||||
|
/// ////
|
||||||
|
string GetSDKVersion();
|
||||||
|
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK version name
|
||||||
|
/// ////
|
||||||
|
string GetSDKVersionName();
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Bigo SDK set user consent
|
||||||
|
/// ////
|
||||||
|
void SetUserConsent(ConsentOptions option, bool consent);
|
||||||
|
|
||||||
|
///////
|
||||||
|
/// Only works on Android
|
||||||
|
/// Bigo SDK set user consent
|
||||||
|
/// ////
|
||||||
|
void AddExtraHost(string country, string host);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00ad18b48fa1047ee98bd415dd127f65
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
using BigoAds.Scripts.Api;
|
||||||
|
|
||||||
|
namespace BigoAds.Scripts.Common
|
||||||
|
{
|
||||||
|
public interface ISplashAd:IBigoAd<BigoSplashRequest>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e1105e67678354e71850311744a989c3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f730f3e43d10941928ac676ed88c7ee4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue