fix:1、删除上一个sdk,更换新的。2、删除了max广告
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc99674688719d74b876de20bb6a3b14
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dependencies>
|
||||
<androidPackages>
|
||||
<androidPackage spec="androidx.media3:media3-exoplayer:1.0.0-alpha01" />
|
||||
<androidPackage spec="androidx.appcompat:appcompat:1.2.0"/>
|
||||
<androidPackage spec="com.google.android.material:material:1.2.1"/>
|
||||
<androidPackage spec="androidx.annotation:annotation:1.2.0"/>
|
||||
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
|
||||
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.0.1"/>
|
||||
</androidPackages>
|
||||
</dependencies>
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1c7cbd7b008346bea69111b0c84540d
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d52e0c395500ee64faea04d4f84eb974
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37ca4c781770fa34a908620d8d3cdb0b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
BIN
Binary file not shown.
+32
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6e6590bee960b04f975d587683cb655
|
||||
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:
|
||||
Vendored
BIN
Binary file not shown.
+32
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45ae2b547eff5804d958e306cc372cc7
|
||||
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,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b7831b042a714ecbbed624079aee268
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cfda4e373bf74dc188f05e9d13e5686
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace KwaiAds.Scripts.Api
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static class Request
|
||||
{
|
||||
public const string BID_FLOOR_PRICE = "bidfloor";
|
||||
public const string BID_FLOOR_CURRENCY = "bidfloorcur";
|
||||
public const string MEDIATION_TYPE = "knMediationType";
|
||||
}
|
||||
|
||||
public static class Currency
|
||||
{
|
||||
public static string USD = "USD";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d588296f2ea8e4ad2b0d8fe1352f6601
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace KwaiAds.Scripts.Api
|
||||
{
|
||||
public interface InitResultCallback
|
||||
{
|
||||
// init success.
|
||||
void OnSuccess();
|
||||
// init fail.
|
||||
void OnFail(int code, string msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8be85fafbbdb749d19df315210dc5f00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c15a0f83cafbc445d8b2d6f33b4ddc39
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api.Interstitial
|
||||
{
|
||||
public interface IInterstitialAdController : IKwaiAdController<KwaiInterstitialAdRequest, IInterstitialAdListener, IInterstitialAdLoadListener>
|
||||
|
||||
{
|
||||
bool Load(KwaiInterstitialAdRequest request, IInterstitialAdListener adListener, IInterstitialAdLoadListener AdLoadListener);
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe02ba500a25a4d7d8908d374918ff77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
namespace KwaiAds.Scripts.Api.Interstitial
|
||||
{
|
||||
public interface IInterstitialAdListener : IAdListener
|
||||
{
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 918faaa178894484c9a6e049087a19a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
namespace KwaiAds.Scripts.Api.Interstitial
|
||||
{
|
||||
public interface IInterstitialAdLoadListener : IRwardAdListener
|
||||
{
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d72b6a69cd6d34540ac09553f5b5ac8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
namespace KwaiAds.Scripts.Api.Interstitial
|
||||
{
|
||||
public class KwaiInterstitialAdRequest : KwaiRequest
|
||||
{
|
||||
public KwaiInterstitialAdRequest(string tagId) : base(tagId)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c4a573a0bd164e71b48712fce52f831
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,90 @@
|
||||
namespace KwaiAds.Scripts.Api
|
||||
{
|
||||
public class KwaiAdConfig
|
||||
{
|
||||
// 必填
|
||||
internal string AppId { get; }
|
||||
|
||||
// 必填
|
||||
internal string Token { get; }
|
||||
|
||||
// 选填
|
||||
internal string AppName { get; }
|
||||
|
||||
// 选填
|
||||
internal string AppDomain { get; }
|
||||
|
||||
// 选填
|
||||
internal string AppStoreUrl { get; }
|
||||
|
||||
// 选填, 打印debug日志使用,注意上线前需要关闭
|
||||
internal bool DebugLog { get; }
|
||||
|
||||
private KwaiAdConfig(KwaiAdConfig.Builder builder)
|
||||
{
|
||||
AppId = builder.AppId;
|
||||
Token = builder.Token;
|
||||
AppName = builder.AppName;
|
||||
AppDomain = builder.AppDomain;
|
||||
AppStoreUrl = builder.AppStoreUrl;
|
||||
DebugLog = builder.DebugLog;
|
||||
}
|
||||
|
||||
public class Builder
|
||||
{
|
||||
internal string AppId;
|
||||
|
||||
internal string Token;
|
||||
|
||||
internal string AppName;
|
||||
|
||||
internal string AppDomain;
|
||||
|
||||
internal string AppStoreUrl;
|
||||
|
||||
internal bool DebugLog;
|
||||
|
||||
public Builder SetAppId(string appid)
|
||||
{
|
||||
this.AppId = appid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetToken(string token)
|
||||
{
|
||||
this.Token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetAppName(string appName)
|
||||
{
|
||||
this.AppName = appName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetAppDomain(string appDomain)
|
||||
{
|
||||
this.AppDomain = appDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetAppStoreUrl(string appStoreUrl)
|
||||
{
|
||||
this.AppStoreUrl = appStoreUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetDebugLog(bool debugLog)
|
||||
{
|
||||
this.DebugLog = debugLog;
|
||||
return this;
|
||||
}
|
||||
|
||||
public KwaiAdConfig Build()
|
||||
{
|
||||
return new KwaiAdConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32b28f3fd33f1428da1cc9988640243b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api
|
||||
{
|
||||
public static class KwaiAdsSdk
|
||||
{
|
||||
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 KwaiAds.Scripts.Platforms.Android.AndroidClientFactory();
|
||||
#else
|
||||
null;
|
||||
throw new PlatformNotSupportedException();
|
||||
#endif
|
||||
return _clientFactory;
|
||||
}
|
||||
|
||||
/// Starts the Kwai SDK
|
||||
/// @warning Call this method as early as possible to reduce ad request fail.
|
||||
/// @param config SDK configuration
|
||||
/// @param callback Callback for starting the Kwai SDK
|
||||
/// ////
|
||||
public static void Initialize(KwaiAdConfig config, InitResultCallback initResultCallback)
|
||||
{
|
||||
SDK.Init(config, initResultCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2791cc736a9794f25ab1696f26f5213c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KwaiAds.Scripts.Api
|
||||
{
|
||||
public class KwaiRequest
|
||||
{
|
||||
public readonly string TagId;
|
||||
|
||||
public Dictionary<string, string> ExtParams = new Dictionary<string, string>();
|
||||
|
||||
public KwaiRequest(string tagId)
|
||||
{
|
||||
this.TagId = tagId ?? throw new ArgumentNullException(nameof(tagId));
|
||||
InitExtParams();
|
||||
}
|
||||
|
||||
protected void InitExtParams()
|
||||
{
|
||||
ExtParams[Constants.Request.BID_FLOOR_PRICE] = "0";
|
||||
ExtParams[Constants.Request.BID_FLOOR_CURRENCY] = Constants.Currency.USD;
|
||||
ExtParams[Constants.Request.MEDIATION_TYPE] = "4";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61bfe19af80544aba92d1b80944a1be4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cd289c41733447869d15ae750e6053b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api.Reward
|
||||
{
|
||||
public interface IRewardAdController : IKwaiAdController<KwaiRewardAdRequest, IRewardAdListener, IRewardAdLoadListener>
|
||||
|
||||
{
|
||||
bool Load(KwaiRewardAdRequest request, IRewardAdListener adListener, IRewardAdLoadListener AdLoadListener);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5caaf31f542a47f393348c0ae68e02f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api.Reward
|
||||
{
|
||||
public interface IRewardAdListener : IAdListener
|
||||
{
|
||||
void OnRewardEarned();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 045ba09dbdc7c466e9be4fc380f2d9bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api.Reward
|
||||
{
|
||||
public interface IRewardAdLoadListener : IRwardAdListener
|
||||
{
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13ea58bcd42a84f62bb3135d963cdafc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace KwaiAds.Scripts.Api.Reward
|
||||
{
|
||||
public class KwaiRewardAdRequest : KwaiRequest
|
||||
{
|
||||
public KwaiRewardAdRequest(string tagId) : base(tagId)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd180b13db2b542d182f2385909233a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9d21eba105154e56868106703439665
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface IAdListener
|
||||
{
|
||||
public void OnAdShow();
|
||||
|
||||
public void OnAdShowFailed(int code, string msg);
|
||||
|
||||
public void OnAdClick();
|
||||
|
||||
public void OnAdClose();
|
||||
|
||||
public void OnAdPlayComplete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 610a8aa1a88da4205aef22f667f20fb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface IRwardAdListener
|
||||
{
|
||||
void OnAdLoadStart(string trackId);
|
||||
|
||||
void OnAdLoadSuccess(string trackId, string price);
|
||||
|
||||
void OnAdLoadFailed(string trackId, int code, string msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a89806e9b67c64489a2a827347537cc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface IClientBidding
|
||||
{
|
||||
void NotifyWin(string minWinPrice);
|
||||
|
||||
void NotifyLoss(string winPrice);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e0c163d17ce64bc8b252335972ee68e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface IClientFactory
|
||||
{
|
||||
ISDK BuildSDKClient();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdc26de22e37d4230a8e0da39e5c796e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using KwaiAds.Scripts.Api;
|
||||
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface IKwaiAdController<in T, in A, in L> : IClientBidding
|
||||
where T : KwaiRequest
|
||||
where A : IAdListener
|
||||
where L : IRwardAdListener
|
||||
{
|
||||
bool Load(T request, A adListener, L AdLoadListener);
|
||||
bool IsLoaded();
|
||||
bool IsReady();
|
||||
void Show();
|
||||
void Destroy();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f46c0951e94f4f8281a9fe8163ada33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
|
||||
namespace KwaiAds.Scripts.Common
|
||||
{
|
||||
public interface ISDK
|
||||
{
|
||||
void Init(KwaiAdConfig config, InitResultCallback initResultCallback);
|
||||
|
||||
IRewardAdController getRewardAdController();
|
||||
|
||||
IInterstitialAdController getInterstitialAdController();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f06c54ccc95d498888d80a2f23ae03b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IKwaiAdListener
|
||||
{
|
||||
void OnLoaded(string unitId, string price);
|
||||
|
||||
void OnLoadFailed(string unitId, int code, string msg);
|
||||
|
||||
void OnShow();
|
||||
|
||||
void OnShowFailed(int code, string msg);
|
||||
|
||||
void OnClick();
|
||||
|
||||
void OnClosed();
|
||||
|
||||
void OnReward();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4d86a7f047d1eb48a96f2f9ffe70241
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "KwaiAds"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95d7c37fc142dcf479cefa5612a6a0d9
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsMgr
|
||||
{
|
||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||
{
|
||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId) // ±ØÌî
|
||||
.SetToken(token) // ±ØÌî
|
||||
.SetAppName("")
|
||||
.SetAppDomain("")
|
||||
.SetAppStoreUrl("")
|
||||
.SetDebugLog(debug)
|
||||
.Build();
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||
}
|
||||
|
||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
private Action<bool, int, string> _initCallBack;
|
||||
|
||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||
{
|
||||
_initCallBack = callBack;
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
_initCallBack?.Invoke(false, code, msg);
|
||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||
}
|
||||
|
||||
public void OnSuccess()
|
||||
{
|
||||
_initCallBack?.Invoke(true, 0, "");
|
||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class KwaiLog
|
||||
{
|
||||
public static bool isShow = true;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.LogError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25e4eb400e2e9e418849d3581ed3aaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiInterAd
|
||||
{
|
||||
private IInterstitialAdController _kwaiInter;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||
if (_kwaiInter != null)
|
||||
{
|
||||
_kwaiInter.Destroy();
|
||||
_kwaiInter = null;
|
||||
}
|
||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
// 构建KwaiInterstitialAdRequest
|
||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiInterstitialAdRequest 配置请求参数
|
||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
_kwaiInter.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||
_kwaiInter?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyLoss();
|
||||
_kwaiInter?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
|
||||
public InterstitialAdListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78532d0248b75424595fa1d155a2ebc2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiVideoAd
|
||||
{
|
||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
if(_kwaiReward != null)
|
||||
{
|
||||
_kwaiReward.Destroy();
|
||||
_kwaiReward = null;
|
||||
}
|
||||
|
||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
|
||||
// 构建KwaiRewardAdRequest
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiRewardAdRequest 配置请求参数
|
||||
// - IRewardAdListener实现类,回调为激励
|
||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(IsReady())
|
||||
{
|
||||
_kwaiReward.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||
_kwaiReward?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyLoss();
|
||||
_kwaiReward?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
|
||||
private class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98dc26ad0e603f746a11b91cdfcc3dfe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c356a83720f804e72bf376a6269fdd49
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f65ac5b34e2e421daefec3aca0c1ee3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#if UNITY_ANDROID
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Platforms.Android
|
||||
{
|
||||
class AndroidClientFactory : IClientFactory
|
||||
{
|
||||
public ISDK BuildSDKClient()
|
||||
{
|
||||
return new KwaiSdkClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 275e0a240fbb94bbbaa5b2aef39327fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BigoAds.Scripts.Platforms.Android
|
||||
{
|
||||
internal static class AndroidPlatformTool
|
||||
{
|
||||
public const string ClassPackage = "com.kwai.network.sdk";
|
||||
private const string CurrentActivityMethod = "currentActivity";
|
||||
private const string UnityPlayerClassName = "com.unity3d.player.UnityPlayer";
|
||||
|
||||
public static AndroidJavaObject GetGameActivity()
|
||||
{
|
||||
return new AndroidJavaClass(UnityPlayerClassName).GetStatic<AndroidJavaObject>(CurrentActivityMethod);
|
||||
}
|
||||
|
||||
public static void CallMethodOnMainThread(Action task)
|
||||
{
|
||||
GetGameActivity()?.Call("runOnUiThread", new AndroidJavaRunnable(task));
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b96b326de04d4efc86c67f33abe4f87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
#if UNITY_ANDROID
|
||||
using System;
|
||||
using BigoAds.Scripts.Platforms.Android;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KwaiAds.Scripts.Platforms.Android
|
||||
{
|
||||
public class KwaiAdSDKInit
|
||||
{
|
||||
private const string TAG = "[KwaiAdSDK-INIT]";
|
||||
private const string SDKClientClassName = AndroidPlatformTool.ClassPackage + ".KwaiAdSDK";
|
||||
private const string SDKClientBuilder = AndroidPlatformTool.ClassPackage + ".api.SdkConfig$Builder";
|
||||
private const string SDKClientInitCallback = AndroidPlatformTool.ClassPackage + ".api.KwaiInitCallback";
|
||||
|
||||
private static AndroidJavaClass kwaiAdSdkClass;
|
||||
private static KwaiAdConfig config;
|
||||
private static InitResultCallback initCallback;
|
||||
|
||||
private KwaiAdSDKInit(KwaiAdConfig kwaiAdConfig, InitResultCallback initResultCallback)
|
||||
{
|
||||
if (kwaiAdConfig == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kwaiAdConfig), $"{TAG}: KwaiAdConfig cannot be null.");
|
||||
}
|
||||
config = kwaiAdConfig;
|
||||
initCallback = initResultCallback;
|
||||
}
|
||||
|
||||
private class KwaiNetworkSingleton
|
||||
{
|
||||
private static volatile KwaiAdSDKInit _instance;
|
||||
private static object syncRoot = new object();
|
||||
|
||||
public static KwaiAdSDKInit Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
throw new InvalidOperationException($"{TAG}: KwaiAdSDK instance has not been initialized.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize(KwaiAdConfig kwaiAdConfig, InitResultCallback initResultCallback)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new KwaiAdSDKInit(kwaiAdConfig, initResultCallback);
|
||||
_instance.InitializeKwaiAdSDK();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize(KwaiAdConfig kwaiAdConfig, InitResultCallback initResultCallback)
|
||||
{
|
||||
KwaiNetworkSingleton.Initialize(kwaiAdConfig, initResultCallback);
|
||||
}
|
||||
|
||||
public static KwaiAdSDKInit Instance
|
||||
{
|
||||
get { return KwaiNetworkSingleton.Instance; }
|
||||
}
|
||||
|
||||
public AndroidJavaClass GetKwaiAdSDKClass()
|
||||
{
|
||||
if (kwaiAdSdkClass == null)
|
||||
{
|
||||
Debug.LogError($"{TAG}: KwaiAdSDKClass has not been initialized..");
|
||||
}
|
||||
return kwaiAdSdkClass;
|
||||
}
|
||||
|
||||
private void InitializeKwaiAdSDK()
|
||||
{
|
||||
var kwaiUnityCallback = new KwaiUnityCallback();
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
Debug.LogError($"{TAG}: Kwai Ad SDK can only be initialized on Android.");
|
||||
kwaiUnityCallback.onFail(2, "Kwai Ad SDK can only be initialized on Android.");
|
||||
return;
|
||||
}
|
||||
|
||||
kwaiAdSdkClass = new AndroidJavaClass(SDKClientClassName);
|
||||
if (kwaiAdSdkClass == null)
|
||||
{
|
||||
Debug.LogError($"{TAG}: Failed to get KwaiAdSDK class.");
|
||||
kwaiUnityCallback.onFail(3, "Failed to get KwaiAdSDK class.");
|
||||
return;
|
||||
}
|
||||
|
||||
var sdkConfigBuilder = new AndroidJavaObject(SDKClientBuilder);
|
||||
if (sdkConfigBuilder == null)
|
||||
{
|
||||
Debug.LogError($"{TAG}: Failed to create SdkConfig builder.");
|
||||
kwaiUnityCallback.onFail(4, "Failed to create SdkConfig builder.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("appId", config.AppId);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("token", config.Token);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("appName", config.AppName);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("appDomain", config.AppDomain);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("appStoreUrl", config.AppStoreUrl);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("setInitCallback", kwaiUnityCallback);
|
||||
sdkConfigBuilder.Call<AndroidJavaObject>("debug", config.DebugLog);
|
||||
}
|
||||
|
||||
AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity();
|
||||
if (currentActivity != null)
|
||||
{
|
||||
AndroidJavaObject contextObject = currentActivity.Call<AndroidJavaObject>("getApplicationContext");
|
||||
Debug.Log("Android Context: " + contextObject.Call<string>("toString"));
|
||||
kwaiAdSdkClass.CallStatic("init", contextObject, sdkConfigBuilder.Call<AndroidJavaObject>("build"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Current Activity not found.");
|
||||
kwaiUnityCallback.onFail(1, $"{TAG}: Current Activity not found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private class KwaiUnityCallback : AndroidJavaProxy
|
||||
{
|
||||
public KwaiUnityCallback() : base(SDKClientInitCallback) { }
|
||||
|
||||
public void onSuccess()
|
||||
{
|
||||
Debug.Log($"{TAG}: Kwai SDK initialized successfully.");
|
||||
if (initCallback != null)
|
||||
{
|
||||
initCallback.OnSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
public void onFail(int code, string msg)
|
||||
{
|
||||
Debug.LogError($"{TAG}: Kwai SDK initialization failed. Code: {code}, Message: {msg}");
|
||||
if (initCallback != null)
|
||||
{
|
||||
initCallback.OnFail(code, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8225807b5469a4df4a11ec59cc223f4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
+244
@@ -0,0 +1,244 @@
|
||||
#if UNITY_ANDROID
|
||||
using BigoAds.Scripts.Platforms.Android;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KwaiAds.Scripts.Platforms.Android
|
||||
{
|
||||
public class KwaiInterstitialAdController : IInterstitialAdController
|
||||
{
|
||||
private const string TAG = "[KwaiAdSDK-InterstitialAdController]";
|
||||
private const string InterstitialAdConfigBuilderClassName = AndroidPlatformTool.ClassPackage + ".loader.business.interstitial.data.KwaiInterstitialAdConfig$Builder";
|
||||
private const string KwaiInterstitialAdListenerClassName = AndroidPlatformTool.ClassPackage + ".loader.business.interstitial.interf.IKwaiInterstitialAdListener";
|
||||
private const string AdLoadListenerClassName = AndroidPlatformTool.ClassPackage + ".loader.common.interf.AdLoadListener";
|
||||
private const string KwaiInterstitialAdRequestClassName = AndroidPlatformTool.ClassPackage + ".loader.business.interstitial.data.KwaiInterstitialAdRequest";
|
||||
private const string KwaiAdLoaderManagerMethodName = "getKwaiAdLoaderManager";
|
||||
private const string WithKwaiInterstitialAdListenerMethodName = "withKwaiInterstitialAdListener";
|
||||
private const string BuildInterstitialAdLoaderMethodName = "buildInterstitialAdLoader";
|
||||
|
||||
private AndroidJavaClass _KwaiAdSDKInit;
|
||||
private AdLoadListener _AdLoadListener;
|
||||
private InterstitialAdListener _InterstitialAdListener;
|
||||
private AndroidJavaObject _KwaiInterstitialAd;
|
||||
|
||||
public bool Load(KwaiInterstitialAdRequest request, IInterstitialAdListener adListener, IInterstitialAdLoadListener adLoadListener)
|
||||
{
|
||||
_KwaiAdSDKInit = Android.KwaiAdSDKInit.Instance.GetKwaiAdSDKClass();
|
||||
if (_KwaiAdSDKInit == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: kwaiAdSDKInit is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var loaderManager = _KwaiAdSDKInit.CallStatic<AndroidJavaObject>(KwaiAdLoaderManagerMethodName);
|
||||
if (loaderManager == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: loaderManager is null.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_AdLoadListener = new AdLoadListener(adLoadListener, this);
|
||||
_InterstitialAdListener = new InterstitialAdListener(adListener);
|
||||
var kwaiInterstitialAdConfig = new AndroidJavaObject(InterstitialAdConfigBuilderClassName, _AdLoadListener);
|
||||
if (kwaiInterstitialAdConfig == null)
|
||||
{
|
||||
Debug.LogError($"{TAG}: Failed to create kwaiInterstitialAdConfig builder.");
|
||||
return false;
|
||||
}
|
||||
kwaiInterstitialAdConfig.Call<AndroidJavaObject>(WithKwaiInterstitialAdListenerMethodName, _InterstitialAdListener);
|
||||
|
||||
var kwaiInterstitialAdAdLoader = loaderManager.Call<AndroidJavaObject>(BuildInterstitialAdLoaderMethodName, kwaiInterstitialAdConfig.Call<AndroidJavaObject>("build"));
|
||||
var adRequest = new AndroidJavaObject(KwaiInterstitialAdRequestClassName, request.TagId);
|
||||
string floorPrice = request.ExtParams[Constants.Request.BID_FLOOR_PRICE];
|
||||
if (floorPrice != null && floorPrice.Length != 0)
|
||||
{
|
||||
Debug.Log($"{TAG}: floorPrice: {floorPrice}.");
|
||||
adRequest.Get<AndroidJavaObject>("extParams").Call<AndroidJavaObject>("put", Constants.Request.BID_FLOOR_PRICE, floorPrice);
|
||||
}
|
||||
kwaiInterstitialAdAdLoader.Call("loadAd", adRequest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity();
|
||||
if (currentActivity == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: Current Game Activity not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{TAG}: start showing.");
|
||||
_KwaiInterstitialAd.Call("show", currentActivity);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{TAG}: IsLoaded: {IsLoaded()}, IsReady: {IsReady()}.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
if (_AdLoadListener != null)
|
||||
{
|
||||
_AdLoadListener.Destory();
|
||||
_AdLoadListener = null;
|
||||
}
|
||||
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.Destory();
|
||||
}
|
||||
|
||||
_KwaiInterstitialAd = null;
|
||||
}
|
||||
|
||||
public bool IsLoaded()
|
||||
{
|
||||
return _KwaiInterstitialAd != null;
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return IsLoaded() && _KwaiInterstitialAd.Call<bool>("isReady");
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
}
|
||||
}
|
||||
|
||||
private class AdLoadListener : AndroidJavaProxy
|
||||
{
|
||||
private IInterstitialAdLoadListener _InterstitialAdLoadListener;
|
||||
private KwaiInterstitialAdController _KwaiInterstitialAdController;
|
||||
public AdLoadListener(IInterstitialAdLoadListener interstitialAdLoadListener, KwaiInterstitialAdController kwaiInterstitialAdController) : base(AdLoadListenerClassName)
|
||||
{
|
||||
this._InterstitialAdLoadListener = interstitialAdLoadListener;
|
||||
this._KwaiInterstitialAdController = kwaiInterstitialAdController;
|
||||
}
|
||||
|
||||
public void onAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdLoadStart");
|
||||
if (_InterstitialAdLoadListener != null)
|
||||
{
|
||||
_InterstitialAdLoadListener.OnAdLoadStart(trackId);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdLoadSuccess(string trackId, AndroidJavaObject kwaiInterstitialAd)
|
||||
{
|
||||
_KwaiInterstitialAdController._KwaiInterstitialAd = kwaiInterstitialAd;
|
||||
string price = kwaiInterstitialAd.Call<string>("getPrice");
|
||||
Debug.Log($"{TAG}: onAdLoaded: {kwaiInterstitialAd.Call<string>("getPrice")}");
|
||||
if (_InterstitialAdLoadListener != null)
|
||||
{
|
||||
_InterstitialAdLoadListener.OnAdLoadSuccess(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdLoadFailed(string trackId, AndroidJavaObject kwaiError)
|
||||
{
|
||||
int code = kwaiError.Call<int>("getCode");
|
||||
string msg = kwaiError.Call<string>("getMsg");
|
||||
Debug.LogError($"{TAG}: onAdLoadFailed code = {code} msg = {msg}");
|
||||
if (_InterstitialAdLoadListener != null)
|
||||
{
|
||||
_InterstitialAdLoadListener.OnAdLoadFailed(trackId, code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void Destory()
|
||||
{
|
||||
_InterstitialAdLoadListener = null;
|
||||
_KwaiInterstitialAdController = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : AndroidJavaProxy
|
||||
{
|
||||
private IInterstitialAdListener _InterstitialAdListener;
|
||||
|
||||
public InterstitialAdListener(IInterstitialAdListener interstitialAdListener) : base(KwaiInterstitialAdListenerClassName)
|
||||
{
|
||||
_InterstitialAdListener = interstitialAdListener;
|
||||
}
|
||||
|
||||
public void onAdShow()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdShow");
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.OnAdShow();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdShowFailed(AndroidJavaObject error)
|
||||
{
|
||||
int code = error.Call<int>("getCode");
|
||||
string msg = error.Call<string>("getMsg");
|
||||
Debug.LogError($"{TAG}: onAdShowFailed code = {code} msg = {msg}");
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.OnAdShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdClick()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdClick");
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.OnAdClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdClose()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdClose");
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.OnAdClose();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdPlayComplete()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdPlayComplete");
|
||||
if (_InterstitialAdListener != null)
|
||||
{
|
||||
_InterstitialAdListener.OnAdPlayComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public void Destory()
|
||||
{
|
||||
_InterstitialAdListener = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0981c7bc6c3f9404e8effcfa265e2632
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
#if UNITY_ANDROID
|
||||
using BigoAds.Scripts.Platforms.Android;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KwaiAds.Scripts.Platforms.Android
|
||||
{
|
||||
public class KwaiRewardAdController : IRewardAdController
|
||||
{
|
||||
private const string TAG = "[KwaiAdSDK-RewardAdController]";
|
||||
private const string RewardedAdConfigBuilderClassName = AndroidPlatformTool.ClassPackage + ".loader.business.reward.data.KwaiRewardAdConfig$Builder";
|
||||
private const string KwaiRewardAdListenerClassName = AndroidPlatformTool.ClassPackage + ".loader.business.reward.interf.IKwaiRewardAdListener";
|
||||
private const string AdLoadListenerClassName = AndroidPlatformTool.ClassPackage + ".loader.common.interf.AdLoadListener";
|
||||
private const string KwaiRewardAdRequestClassName = AndroidPlatformTool.ClassPackage + ".loader.business.reward.data.KwaiRewardAdRequest";
|
||||
private const string KwaiAdLoaderManagerMethodName = "getKwaiAdLoaderManager";
|
||||
private const string WithKwaiRewardAdListenerMethodName = "withKwaiRewardAdListener";
|
||||
private const string BuildRewardAdLoaderMethodName = "buildRewardAdLoader";
|
||||
|
||||
private AndroidJavaClass _KwaiAdSDKInit;
|
||||
private AdLoadListener _AdLoadListener;
|
||||
private RewardAdListener _RewardAdListener;
|
||||
private AndroidJavaObject _KwaiRewardAd;
|
||||
|
||||
public bool Load(KwaiRewardAdRequest request, IRewardAdListener rewardAdListener, IRewardAdLoadListener rewardAdLoadListener)
|
||||
{
|
||||
_KwaiAdSDKInit = Android.KwaiAdSDKInit.Instance.GetKwaiAdSDKClass();
|
||||
if (_KwaiAdSDKInit == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: kwaiAdSDKInit is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var loaderManager = _KwaiAdSDKInit.CallStatic<AndroidJavaObject>(KwaiAdLoaderManagerMethodName);
|
||||
if (loaderManager == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: loaderManager is null.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_AdLoadListener = new AdLoadListener(rewardAdLoadListener, this);
|
||||
_RewardAdListener = new RewardAdListener(rewardAdListener);
|
||||
var kwaiRewardAdConfig = new AndroidJavaObject(RewardedAdConfigBuilderClassName, _AdLoadListener);
|
||||
if (kwaiRewardAdConfig == null)
|
||||
{
|
||||
Debug.LogError($"{TAG}:Failed to create kwaiRewardAdConfig builder.");
|
||||
return false;
|
||||
}
|
||||
kwaiRewardAdConfig.Call<AndroidJavaObject>(WithKwaiRewardAdListenerMethodName, _RewardAdListener);
|
||||
|
||||
var kwaiRewardAdAdLoader = loaderManager.Call<AndroidJavaObject>(BuildRewardAdLoaderMethodName, kwaiRewardAdConfig.Call<AndroidJavaObject>("build"));
|
||||
var adRequest = new AndroidJavaObject(KwaiRewardAdRequestClassName, request.TagId);
|
||||
string floorPrice = request.ExtParams[Constants.Request.BID_FLOOR_PRICE];
|
||||
if (floorPrice != null && floorPrice.Length != 0)
|
||||
{
|
||||
Debug.Log($"{TAG}: floorPrice: {floorPrice}.");
|
||||
adRequest.Get<AndroidJavaObject>("extParams").Call<AndroidJavaObject>("put", Constants.Request.BID_FLOOR_PRICE, floorPrice);
|
||||
}
|
||||
kwaiRewardAdAdLoader.Call("loadAd", adRequest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity();
|
||||
if (currentActivity == null)
|
||||
{
|
||||
Debug.Log($"{TAG}: Current Game Activity not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{TAG}: start showing.");
|
||||
_KwaiRewardAd.Call("show", currentActivity);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{TAG}: IsLoaded: {IsLoaded()}, IsReady: {IsReady()}.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
if (_AdLoadListener != null)
|
||||
{
|
||||
_AdLoadListener.Destory();
|
||||
_AdLoadListener = null;
|
||||
}
|
||||
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.Destory();
|
||||
}
|
||||
|
||||
_KwaiRewardAd = null;
|
||||
}
|
||||
|
||||
public bool IsLoaded()
|
||||
{
|
||||
return _KwaiRewardAd != null;
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return IsLoaded() && _KwaiRewardAd.Call<bool>("isReady");
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
}
|
||||
}
|
||||
|
||||
private class AdLoadListener : AndroidJavaProxy
|
||||
{
|
||||
private IRewardAdLoadListener _RewardAdLoadListener;
|
||||
private KwaiRewardAdController _KwaiRewardAdController;
|
||||
public AdLoadListener(IRewardAdLoadListener rewardAdListener, KwaiRewardAdController kwaiRewardAdController) : base(AdLoadListenerClassName)
|
||||
{
|
||||
this._RewardAdLoadListener = rewardAdListener;
|
||||
this._KwaiRewardAdController = kwaiRewardAdController;
|
||||
}
|
||||
|
||||
public void onAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdLoadStart");
|
||||
if (_RewardAdLoadListener != null)
|
||||
{
|
||||
_RewardAdLoadListener.OnAdLoadStart(trackId);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdLoadSuccess(string trackId, AndroidJavaObject kwaiRewardAd)
|
||||
{
|
||||
_KwaiRewardAdController._KwaiRewardAd = kwaiRewardAd;
|
||||
string price = kwaiRewardAd.Call<string>("getPrice");
|
||||
Debug.Log($"{TAG}: onAdLoaded: {kwaiRewardAd.Call<string>("getPrice")}");
|
||||
if (_RewardAdLoadListener != null)
|
||||
{
|
||||
_RewardAdLoadListener.OnAdLoadSuccess(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdLoadFailed(string trackId, AndroidJavaObject kwaiError)
|
||||
{
|
||||
int code = kwaiError.Call<int>("getCode");
|
||||
string msg = kwaiError.Call<string>("getMsg");
|
||||
Debug.LogError($"{TAG}: onAdLoadFailed code = {code} msg = {msg}");
|
||||
if (_RewardAdLoadListener != null)
|
||||
{
|
||||
_RewardAdLoadListener.OnAdLoadFailed(trackId, code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void Destory()
|
||||
{
|
||||
_RewardAdLoadListener = null;
|
||||
_KwaiRewardAdController = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdListener : AndroidJavaProxy
|
||||
{
|
||||
private IRewardAdListener _RewardAdListener;
|
||||
|
||||
public RewardAdListener(IRewardAdListener rewardAdListener) : base(KwaiRewardAdListenerClassName) {
|
||||
_RewardAdListener = rewardAdListener;
|
||||
}
|
||||
|
||||
public void onAdShow()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdShow");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnAdShow();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdShowFailed(AndroidJavaObject error)
|
||||
{
|
||||
int code = error.Call<int>("getCode");
|
||||
string msg = error.Call<string>("getMsg");
|
||||
Debug.LogError($"{TAG}: onAdShowFailed code = {code} msg = {msg}");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnAdShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdClick()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdClick");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnAdClick();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdPlayComplete()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdPlayComplete");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnAdPlayComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public void onRewardEarned()
|
||||
{
|
||||
Debug.Log($"{TAG}: onRewarded");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnRewardEarned();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAdClose()
|
||||
{
|
||||
Debug.Log($"{TAG}: onAdClose");
|
||||
if (_RewardAdListener != null)
|
||||
{
|
||||
_RewardAdListener.OnAdClose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Destory()
|
||||
{
|
||||
_RewardAdListener = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac60b4b82a68d4feb811961ea98ad413
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#if UNITY_ANDROID
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Platforms.Android
|
||||
{
|
||||
public class KwaiSdkClient: ISDK
|
||||
{
|
||||
public void Init(KwaiAdConfig config, InitResultCallback initResultCallback)
|
||||
{
|
||||
KwaiAdSDKInit.Initialize(config, initResultCallback);
|
||||
}
|
||||
|
||||
public IRewardAdController getRewardAdController()
|
||||
{
|
||||
return new KwaiRewardAdController();
|
||||
}
|
||||
|
||||
public IInterstitialAdController getInterstitialAdController()
|
||||
{
|
||||
return new KwaiInterstitialAdController();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 440ab8edeedf747c48701c4009831273
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user