From 51f2024e7f502ea2b491f05406709f06eb44e456 Mon Sep 17 00:00:00 2001 From: juncong lee Date: Sat, 30 Aug 2025 13:49:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bigo=20sdk=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9kwai=20AndroidPlatformTools=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/BigoAds.meta | 8 + Assets/BigoAds/Scripts.meta | 8 + Assets/BigoAds/Scripts/Api.meta | 8 + Assets/BigoAds/Scripts/Api/BigoAdConfig.cs | 115 ++++++++ .../BigoAds/Scripts/Api/BigoAdConfig.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoAdSdk.cs | 106 +++++++ Assets/BigoAds/Scripts/Api/BigoAdSdk.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoBannerAd.cs | 30 ++ .../BigoAds/Scripts/Api/BigoBannerAd.cs.meta | 11 + .../BigoAds/Scripts/Api/BigoBannerRequest.cs | 22 ++ .../Scripts/Api/BigoBannerRequest.cs.meta | 11 + .../BigoAds/Scripts/Api/BigoInterstitialAd.cs | 11 + .../Scripts/Api/BigoInterstitialAd.cs.meta | 11 + .../Scripts/Api/BigoInterstitialRequest.cs | 10 + .../Api/BigoInterstitialRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoNativeAd.cs | 26 ++ .../BigoAds/Scripts/Api/BigoNativeAd.cs.meta | 11 + .../BigoAds/Scripts/Api/BigoNativeRequest.cs | 10 + .../Scripts/Api/BigoNativeRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoPopupAd.cs | 11 + .../BigoAds/Scripts/Api/BigoPopupAd.cs.meta | 11 + .../BigoAds/Scripts/Api/BigoPopupRequest.cs | 10 + .../Scripts/Api/BigoPopupRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoRequest.cs | 47 ++++ .../BigoAds/Scripts/Api/BigoRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs | 29 ++ .../Scripts/Api/BigoRewardedAd.cs.meta | 11 + .../Scripts/Api/BigoRewardedRequest.cs | 10 + .../Scripts/Api/BigoRewardedRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/BigoSplashAd.cs | 11 + .../BigoAds/Scripts/Api/BigoSplashAd.cs.meta | 11 + .../BigoAds/Scripts/Api/BigoSplashRequest.cs | 10 + .../Scripts/Api/BigoSplashRequest.cs.meta | 11 + Assets/BigoAds/Scripts/Api/Constant.meta | 8 + .../Scripts/Api/Constant/BGAdGender.cs | 10 + .../Scripts/Api/Constant/BGAdGender.cs.meta | 11 + .../Scripts/Api/Constant/BGAdLossReason.cs | 13 + .../Api/Constant/BGAdLossReason.cs.meta | 11 + .../Scripts/Api/Constant/BigoBannerSize.cs | 23 ++ .../Api/Constant/BigoBannerSize.cs.meta | 11 + .../Scripts/Api/Constant/BigoPosition.cs | 12 + .../Scripts/Api/Constant/BigoPosition.cs.meta | 11 + .../Scripts/Api/Constant/ConsentOptions.cs | 13 + .../Api/Constant/ConsentOptions.cs.meta | 11 + Assets/BigoAds/Scripts/Common.meta | 8 + Assets/BigoAds/Scripts/Common/BigoBaseAd.cs | 218 ++++++++++++++ .../BigoAds/Scripts/Common/BigoBaseAd.cs.meta | 11 + .../BigoAds/Scripts/Common/BigoDispatcher.cs | 86 ++++++ .../Scripts/Common/BigoDispatcher.cs.meta | 11 + Assets/BigoAds/Scripts/Common/IBannerAd.cs | 10 + .../BigoAds/Scripts/Common/IBannerAd.cs.meta | 11 + Assets/BigoAds/Scripts/Common/IBigoAd.cs | 22 ++ Assets/BigoAds/Scripts/Common/IBigoAd.cs.meta | 11 + .../BigoAds/Scripts/Common/IClientBidding.cs | 16 ++ .../Scripts/Common/IClientBidding.cs.meta | 11 + .../BigoAds/Scripts/Common/IClientFactory.cs | 13 + .../Scripts/Common/IClientFactory.cs.meta | 11 + .../BigoAds/Scripts/Common/IInterstitialAd.cs | 8 + .../Scripts/Common/IInterstitialAd.cs.meta | 11 + Assets/BigoAds/Scripts/Common/INativeAd.cs | 10 + .../BigoAds/Scripts/Common/INativeAd.cs.meta | 11 + Assets/BigoAds/Scripts/Common/IPopupAd.cs | 8 + .../BigoAds/Scripts/Common/IPopupAd.cs.meta | 11 + Assets/BigoAds/Scripts/Common/IRewardedAd.cs | 10 + .../Scripts/Common/IRewardedAd.cs.meta | 11 + Assets/BigoAds/Scripts/Common/ISDK.cs | 40 +++ Assets/BigoAds/Scripts/Common/ISDK.cs.meta | 11 + Assets/BigoAds/Scripts/Common/ISplashAd.cs | 8 + .../BigoAds/Scripts/Common/ISplashAd.cs.meta | 11 + Assets/BigoAds/Scripts/Platforms.meta | 8 + Assets/BigoAds/Scripts/Platforms/Android.meta | 8 + .../Scripts/Platforms/Android/AdHelper.cs | 99 +++++++ .../Platforms/Android/AdHelper.cs.meta | 11 + .../Scripts/Platforms/Android/AdHelper.java | 106 +++++++ .../Platforms/Android/AdHelper.java.meta | 32 +++ .../Android/AdInteractionCallback.cs | 53 ++++ .../Android/AdInteractionCallback.cs.meta | 11 + .../Platforms/Android/AdLoadCallback.cs | 33 +++ .../Platforms/Android/AdLoadCallback.cs.meta | 11 + .../Platforms/Android/AndroidBannerAd.cs | 147 ++++++++++ .../Platforms/Android/AndroidBannerAd.cs.meta | 11 + .../Platforms/Android/AndroidClientFactory.cs | 49 ++++ .../Android/AndroidClientFactory.cs.meta | 11 + .../Android/AndroidInterstitialAd.cs | 124 ++++++++ .../Android/AndroidInterstitialAd.cs.meta | 11 + .../Platforms/Android/AndroidNativeAd.cs | 133 +++++++++ .../Platforms/Android/AndroidNativeAd.cs.meta | 11 + .../Platforms/Android/AndroidPlatformTool.cs | 101 +++++++ .../Android/AndroidPlatformTool.cs.meta | 11 + .../Platforms/Android/AndroidPopupAd.cs | 124 ++++++++ .../Platforms/Android/AndroidPopupAd.cs.meta | 11 + .../Platforms/Android/AndroidRewardedAd.cs | 125 +++++++++ .../Android/AndroidRewardedAd.cs.meta | 11 + .../Platforms/Android/AndroidSplashAd.cs | 124 ++++++++ .../Platforms/Android/AndroidSplashAd.cs.meta | 11 + .../Platforms/Android/BigoSdkClient.cs | 99 +++++++ .../Platforms/Android/BigoSdkClient.cs.meta | 11 + .../Android/RewardedAdInteractionCallback.cs | 27 ++ .../RewardedAdInteractionCallback.cs.meta | 11 + .../Android/SplashAdInteractionCallback.cs | 29 ++ .../SplashAdInteractionCallback.cs.meta | 11 + Assets/BigoAds/Scripts/Platforms/iOS.meta | 8 + .../Scripts/Platforms/iOS/Adapter.meta | 8 + .../Scripts/Platforms/iOS/Adapter/BigoAd.meta | 8 + .../Platforms/iOS/Adapter/BigoAd/Banner.meta | 8 + .../BigoAd/Banner/BigoUnityBannerAd.cs | 112 ++++++++ .../BigoAd/Banner/BigoUnityBannerAd.cs.meta | 11 + .../Adapter/BigoAd/Banner/BigoUnityBannerAd.h | 24 ++ .../BigoAd/Banner/BigoUnityBannerAd.h.meta | 27 ++ .../BigoAd/Banner/BigoUnityBannerAd.mm | 133 +++++++++ .../BigoAd/Banner/BigoUnityBannerAd.mm.meta | 37 +++ .../iOS/Adapter/BigoAd/BigoIOSBaseAd.cs | 265 ++++++++++++++++++ .../iOS/Adapter/BigoAd/BigoIOSBaseAd.cs.meta | 11 + .../iOS/Adapter/BigoAd/BigoIOSBaseAd.mm | 109 +++++++ .../iOS/Adapter/BigoAd/BigoIOSBaseAd.mm.meta | 37 +++ .../BigoAd/BigoUnityAdHandlerManager.h | 22 ++ .../BigoAd/BigoUnityAdHandlerManager.h.meta | 27 ++ .../BigoAd/BigoUnityAdHandlerManager.m | 70 +++++ .../BigoAd/BigoUnityAdHandlerManager.m.meta | 37 +++ .../Adapter/BigoAd/BigoUnityBaseAdHandler.h | 62 ++++ .../BigoAd/BigoUnityBaseAdHandler.h.meta | 27 ++ .../Adapter/BigoAd/BigoUnityBaseAdHandler.mm | 170 +++++++++++ .../BigoAd/BigoUnityBaseAdHandler.mm.meta | 37 +++ .../iOS/Adapter/BigoAd/BigoUnityConfig.cs | 44 +++ .../Adapter/BigoAd/BigoUnityConfig.cs.meta | 11 + .../iOS/Adapter/BigoAd/BigoUnityConfig.mm | 30 ++ .../Adapter/BigoAd/BigoUnityConfig.mm.meta | 37 +++ .../iOS/Adapter/BigoAd/BigoUnitySdk.cs | 105 +++++++ .../iOS/Adapter/BigoAd/BigoUnitySdk.cs.meta | 11 + .../iOS/Adapter/BigoAd/BigoUnitySdk.mm | 58 ++++ .../iOS/Adapter/BigoAd/BigoUnitySdk.mm.meta | 37 +++ .../iOS/Adapter/BigoAd/BigoUnityTools.cs | 22 ++ .../iOS/Adapter/BigoAd/BigoUnityTools.cs.meta | 11 + .../iOS/Adapter/BigoAd/Interstitial.meta | 8 + .../Interstitial/BigoUnityInterstitialAd.cs | 17 ++ .../BigoUnityInterstitialAd.cs.meta | 11 + .../Interstitial/BigoUnityInterstitialAd.h | 17 ++ .../BigoUnityInterstitialAd.h.meta | 27 ++ .../Interstitial/BigoUnityInterstitialAd.mm | 67 +++++ .../BigoUnityInterstitialAd.mm.meta | 37 +++ .../Platforms/iOS/Adapter/BigoAd/Native.meta | 8 + .../BigoAd/Native/BigoUnityNativeAd.cs | 84 ++++++ .../BigoAd/Native/BigoUnityNativeAd.cs.meta | 11 + .../Adapter/BigoAd/Native/BigoUnityNativeAd.h | 21 ++ .../BigoAd/Native/BigoUnityNativeAd.h.meta | 27 ++ .../BigoAd/Native/BigoUnityNativeAd.mm | 102 +++++++ .../BigoAd/Native/BigoUnityNativeAd.mm.meta | 37 +++ .../BigoAd/Native/BigoUnityNativeCustomView.h | 17 ++ .../Native/BigoUnityNativeCustomView.h.meta | 27 ++ .../BigoAd/Native/BigoUnityNativeCustomView.m | 72 +++++ .../Native/BigoUnityNativeCustomView.m.meta | 37 +++ .../Platforms/iOS/Adapter/BigoAd/Popup.meta | 8 + .../Adapter/BigoAd/Popup/BigoUnityPopupAd.cs | 17 ++ .../BigoAd/Popup/BigoUnityPopupAd.cs.meta | 11 + .../Adapter/BigoAd/Popup/BigoUnityPopupAd.h | 17 ++ .../BigoAd/Popup/BigoUnityPopupAd.h.meta | 27 ++ .../Adapter/BigoAd/Popup/BigoUnityPopupAd.mm | 29 ++ .../BigoAd/Popup/BigoUnityPopupAd.mm.meta | 37 +++ .../iOS/Adapter/BigoAd/Rewarded.meta | 8 + .../BigoAd/Rewarded/BigoUnityRewardedAd.cs | 63 +++++ .../Rewarded/BigoUnityRewardedAd.cs.meta | 11 + .../BigoAd/Rewarded/BigoUnityRewardedAd.h | 18 ++ .../Rewarded/BigoUnityRewardedAd.h.meta | 27 ++ .../BigoAd/Rewarded/BigoUnityRewardedAd.mm | 69 +++++ .../Rewarded/BigoUnityRewardedAd.mm.meta | 37 +++ .../Platforms/iOS/Adapter/BigoAd/Splash.meta | 8 + .../BigoAd/Splash/BGSplashAdViewController.h | 24 ++ .../Splash/BGSplashAdViewController.h.meta | 27 ++ .../BigoAd/Splash/BGSplashAdViewController.m | 71 +++++ .../Splash/BGSplashAdViewController.m.meta | 37 +++ .../BigoAd/Splash/BigoUnitySplashAd.cs | 17 ++ .../BigoAd/Splash/BigoUnitySplashAd.cs.meta | 11 + .../Adapter/BigoAd/Splash/BigoUnitySplashAd.h | 17 ++ .../BigoAd/Splash/BigoUnitySplashAd.h.meta | 27 ++ .../BigoAd/Splash/BigoUnitySplashAd.mm | 71 +++++ .../BigoAd/Splash/BigoUnitySplashAd.mm.meta | 37 +++ .../iOS/Adapter/BigoUnityAdapterTools.h | 6 + .../iOS/Adapter/BigoUnityAdapterTools.h.meta | 27 ++ .../iOS/Adapter/BigoUnityAdapterTools.mm | 43 +++ .../iOS/Adapter/BigoUnityAdapterTools.mm.meta | 37 +++ .../Scripts/Platforms/iOS/IOSClientFactory.cs | 46 +++ .../Platforms/iOS/IOSClientFactory.cs.meta | 11 + Assets/BigoSDK.meta | 8 + Assets/BigoSDK/Editor.meta | 8 + Assets/BigoSDK/Editor/Dependencies.xml | 13 + Assets/BigoSDK/Editor/Dependencies.xml.meta | 7 + .../Platform/Android/AndroidPlatformTool.cs | 2 +- .../Scripts/Platform/Android/KwaiAdSDKInit.cs | 8 +- .../Android/KwaiInterstitialAdController.cs | 10 +- .../Android/KwaiRewardAdController.cs | 10 +- 190 files changed, 6135 insertions(+), 15 deletions(-) create mode 100644 Assets/BigoAds.meta create mode 100644 Assets/BigoAds/Scripts.meta create mode 100644 Assets/BigoAds/Scripts/Api.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoAdConfig.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoAdConfig.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoAdSdk.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoAdSdk.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoBannerAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoBannerAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoNativeAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoNativeAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoPopupAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoPopupAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoSplashAd.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoSplashAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs create mode 100644 Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs create mode 100644 Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs.meta create mode 100644 Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs create mode 100644 Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common.meta create mode 100644 Assets/BigoAds/Scripts/Common/BigoBaseAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/BigoBaseAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/BigoDispatcher.cs create mode 100644 Assets/BigoAds/Scripts/Common/BigoDispatcher.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IBannerAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/IBannerAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IBigoAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/IBigoAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IClientBidding.cs create mode 100644 Assets/BigoAds/Scripts/Common/IClientBidding.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IClientFactory.cs create mode 100644 Assets/BigoAds/Scripts/Common/IClientFactory.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IInterstitialAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/IInterstitialAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/INativeAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/INativeAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IPopupAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/IPopupAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/IRewardedAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/IRewardedAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/ISDK.cs create mode 100644 Assets/BigoAds/Scripts/Common/ISDK.cs.meta create mode 100644 Assets/BigoAds/Scripts/Common/ISplashAd.cs create mode 100644 Assets/BigoAds/Scripts/Common/ISplashAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs.meta create mode 100755 Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm.meta create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs create mode 100644 Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs.meta create mode 100644 Assets/BigoSDK.meta create mode 100644 Assets/BigoSDK/Editor.meta create mode 100644 Assets/BigoSDK/Editor/Dependencies.xml create mode 100644 Assets/BigoSDK/Editor/Dependencies.xml.meta diff --git a/Assets/BigoAds.meta b/Assets/BigoAds.meta new file mode 100644 index 0000000..c4a3cd5 --- /dev/null +++ b/Assets/BigoAds.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bd0ef81b1482347b38905fab4f30e583 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts.meta b/Assets/BigoAds/Scripts.meta new file mode 100644 index 0000000..dc11939 --- /dev/null +++ b/Assets/BigoAds/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 467aa0b9eadf04b22b5b3713a1b07bea +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api.meta b/Assets/BigoAds/Scripts/Api.meta new file mode 100644 index 0000000..15c0daf --- /dev/null +++ b/Assets/BigoAds/Scripts/Api.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1dd438e36fdc745aaa018eac5d3b182c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs b/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs new file mode 100644 index 0000000..82e0447 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs @@ -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"; + + /// + /// the unique identifier of the App + /// + internal string AppId { get; } + + /// + /// Custom set the debugLog to print debug Log. + /// debugLog NO: close debug log, YES: open debug log. + /// + internal bool DebugLog { get; } + + /// + /// Channels for publishing media applications + /// + internal string Channel { get; } + + internal int Age { get; } + + internal int Gender { get; } + + internal long ActivatedTime { get; } + + internal Dictionary 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 ExtraDictionary = new Dictionary(); + + 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); + } + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs.meta b/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs.meta new file mode 100644 index 0000000..b457ea0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoAdConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b18497a84c58a49f385b63be54aff0cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs b/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs new file mode 100644 index 0000000..c248141 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs @@ -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); + } + + } +} diff --git a/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs.meta b/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs.meta new file mode 100644 index 0000000..4672ff6 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoAdSdk.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e5ad9c8c265954d4e8f4f03312b5fa42 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs b/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs new file mode 100644 index 0000000..598d5bb --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs @@ -0,0 +1,30 @@ +using BigoAds.Scripts.Api.Constant; +using BigoAds.Scripts.Common; +using UnityEngine; + +namespace BigoAds.Scripts.Api +{ + public class BigoBannerAd : BigoBaseAd + { + private readonly IBannerAd _bannerAdClient; + + + /// + /// create a banner ad + /// + /// + public BigoBannerAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildBannerAdClient()) + { + _bannerAdClient = (IBannerAd) ADClient; + } + + /// + /// set position for banner + /// + /// + public void SetPosition(BigoPosition position) + { + _bannerAdClient?.SetPosition(position); + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs.meta new file mode 100644 index 0000000..c20e587 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5136d466cbb6c461f92fbd90b6fa157d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs b/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs new file mode 100644 index 0000000..a40d433 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs.meta new file mode 100644 index 0000000..b1bc7ba --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoBannerRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 159c6164853954739adbca1ae7592df7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs b/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs new file mode 100644 index 0000000..aadc6ff --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs @@ -0,0 +1,11 @@ +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Api +{ + public class BigoInterstitialAd : BigoBaseAd + { + public BigoInterstitialAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildInterstitialAdClient()) + { + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs.meta new file mode 100644 index 0000000..ef2cffe --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoInterstitialAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1323eae1e03094d8281b23f5527a53db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs b/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs new file mode 100644 index 0000000..29fd866 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs @@ -0,0 +1,10 @@ +using System; + +namespace BigoAds.Scripts.Api +{ + [Serializable] + + public class BigoInterstitialRequest : BigoRequest + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs.meta new file mode 100644 index 0000000..dab3ed2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoInterstitialRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1947fd630823b4858af6c3a471497f70 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs b/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs new file mode 100644 index 0000000..d47b55b --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs @@ -0,0 +1,26 @@ +using BigoAds.Scripts.Api.Constant; +using BigoAds.Scripts.Common; +using UnityEngine; + +namespace BigoAds.Scripts.Api +{ + public class BigoNativeAd : BigoBaseAd + { + private readonly INativeAd _NativeAdClient; + + public BigoNativeAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildNativeAdClient()) + { + _NativeAdClient = (INativeAd) ADClient; + } + + /// + /// set position for native + /// + /// + public void SetPosition(BigoPosition position) + { + _NativeAdClient?.SetPosition(position); + } + + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs.meta new file mode 100644 index 0000000..8660675 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoNativeAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1742d1ee2ff5e4d508ae81524cb94ade +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs b/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs new file mode 100644 index 0000000..fb99270 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs @@ -0,0 +1,10 @@ +using System; + +namespace BigoAds.Scripts.Api +{ + [Serializable] + public class BigoNativeRequest : BigoRequest + { + + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs.meta new file mode 100644 index 0000000..304ad89 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoNativeRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 033c30386f5714bddb5dd41d7524979e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs b/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs new file mode 100644 index 0000000..80a872b --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs @@ -0,0 +1,11 @@ +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Api +{ + public class BigoPopupAd : BigoBaseAd + { + public BigoPopupAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildPopupAdClient()) + { + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs.meta new file mode 100644 index 0000000..ad93110 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoPopupAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2be0a8fe9e5aa4bea8970a47e617a076 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs b/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs new file mode 100644 index 0000000..c30c437 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs @@ -0,0 +1,10 @@ +using System; + +namespace BigoAds.Scripts.Api +{ + [Serializable] + + public class BigoPopupRequest : BigoRequest + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs.meta new file mode 100644 index 0000000..9b9e2ea --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoPopupRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 580aad20fbde543bab37a5e878c682cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoRequest.cs b/Assets/BigoAds/Scripts/Api/BigoRequest.cs new file mode 100644 index 0000000..fe217ba --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRequest.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoRequest.cs.meta new file mode 100644 index 0000000..b054061 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2707ffe474e6443d6a5260876d5b1370 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs b/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs new file mode 100644 index 0000000..8d594b2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs @@ -0,0 +1,29 @@ +using System; +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Api +{ + public class BigoRewardedAd : BigoBaseAd + { + 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(); + } + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs.meta new file mode 100644 index 0000000..95f6da4 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRewardedAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2f745c8797b25430685a5a08b34f0d9f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs b/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs new file mode 100644 index 0000000..9b36137 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs @@ -0,0 +1,10 @@ +using System; + +namespace BigoAds.Scripts.Api +{ + [Serializable] + + public class BigoRewardedRequest : BigoRequest + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs.meta new file mode 100644 index 0000000..2c3f5c6 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoRewardedRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 38f4a763a1fc9429ca87c62eed4b4645 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs b/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs new file mode 100644 index 0000000..14dac42 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs @@ -0,0 +1,11 @@ +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Api +{ + public class BigoSplashAd : BigoBaseAd + { + public BigoSplashAd(string slotId) : base(slotId, BigoAdSdk.GetClientFactory().BuildSplashAdClient()) + { + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs.meta b/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs.meta new file mode 100644 index 0000000..24bf412 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoSplashAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 61b62ca232d2e42788e61f33d7784209 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs b/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs new file mode 100644 index 0000000..e6d9239 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs @@ -0,0 +1,10 @@ +using System; + +namespace BigoAds.Scripts.Api +{ + [Serializable] + + public class BigoSplashRequest : BigoRequest + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs.meta b/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs.meta new file mode 100644 index 0000000..54ba905 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/BigoSplashRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: afdf808922a744419b5db1fdd4ca18b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant.meta b/Assets/BigoAds/Scripts/Api/Constant.meta new file mode 100644 index 0000000..df5fa74 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0762cd7e46c3c43e5a32b1558643eb74 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs b/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs new file mode 100644 index 0000000..462edff --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs @@ -0,0 +1,10 @@ +using System; +namespace BigoAds.Scripts.Api.Constant +{ + [Serializable] + public enum BGAdGender + { + Female = 1, + Male = 2 + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs.meta b/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs.meta new file mode 100644 index 0000000..f517742 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BGAdGender.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2784802c5b5b34470a0500118ccb7f55 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs b/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs new file mode 100644 index 0000000..1e8b77e --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs @@ -0,0 +1,13 @@ +using System; + +namespace BigoAds.Scripts.Api.Constant +{ + [Serializable] + public enum BGAdLossReason + { + InternalError = 1, + Timeout = 2, + LowerThanFloorPrice = 100, + LowerThanHighestPrice = 101 + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs.meta b/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs.meta new file mode 100644 index 0000000..c16d048 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BGAdLossReason.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 303b2e25e09c44797a167b642310a319 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs b/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs new file mode 100644 index 0000000..0d26ace --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs.meta b/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs.meta new file mode 100644 index 0000000..2a3dff5 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BigoBannerSize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4a4411a50cfc94717b30325ceed3d52f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs b/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs new file mode 100644 index 0000000..44a6cdb --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs @@ -0,0 +1,12 @@ +using System; + +namespace BigoAds.Scripts.Api.Constant +{ + [Serializable] + public enum BigoPosition + { + Top = 0, + Middle = 1, + Bottom = 2 + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs.meta b/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs.meta new file mode 100644 index 0000000..409da19 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/BigoPosition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6511065ffc7f44235bacb3ee16a87f5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs b/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs new file mode 100644 index 0000000..5b49a5e --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs @@ -0,0 +1,13 @@ +using System; + +namespace BigoAds.Scripts.Api.Constant +{ + [Serializable] + public enum ConsentOptions + { + GDPR, + CCPA, + LGPD, + COPPA + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs.meta b/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs.meta new file mode 100644 index 0000000..c1ae974 --- /dev/null +++ b/Assets/BigoAds/Scripts/Api/Constant/ConsentOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7867ac15c426649a6aa633a772d54879 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common.meta b/Assets/BigoAds/Scripts/Common.meta new file mode 100644 index 0000000..f8e8c89 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b4db2c2875384f11b89eb7dec28b823 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs b/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs new file mode 100644 index 0000000..955822c --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs @@ -0,0 +1,218 @@ +using System; +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Api.Constant; + +namespace BigoAds.Scripts.Common +{ + public class BigoBaseAd where T : BigoRequest + { + /// + /// event for load ad success + /// + public event Action OnLoad; + + /// + /// load ad failed with error code and error message + /// + public event Action OnLoadFailed; + + /// + /// event for ad impression + /// + public event Action OnAdShowed; + + /// + /// event for ad be clicked + /// + public event Action OnAdClicked; + + /// + /// event for ad be closed + /// + public event Action OnAdDismissed; + + /// + /// event for ad error + /// + public event Action OnAdError; + + private readonly string _slotId; + + private bool _isAdLoaded; + + protected readonly IBigoAd ADClient; + + public bool CallbackOnMainThread { get; set; } = true; + + private BigoAdBid _bid; + + protected BigoBaseAd(string id, IBigoAd adClient) + { + _slotId = id; + ADClient = adClient; + InitEvent(ADClient); + } + + private void InitEvent(IBigoAd 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 _ADClient; + + public BigoAdBid(IBigoAd 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); + } + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs.meta b/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs.meta new file mode 100644 index 0000000..f0dae98 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/BigoBaseAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8554386bfcec3403cb6fab89c7a35f31 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs b/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs new file mode 100644 index 0000000..18f0d61 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs @@ -0,0 +1,86 @@ +namespace BigoAds.Scripts.Common +{ + using System; + using System.Collections.Generic; + using UnityEngine; + + /// + /// The unity thread dispatcher. + /// + [DisallowMultipleComponent] + internal sealed class BigoDispatcher : MonoBehaviour + { + private static bool _instanceCreated; + + // The thread safe task queue. + private static readonly List PostTasks = new List(); + + // The executing buffer. + private static readonly List Executing = new List(); + + static BigoDispatcher() + { + CreateInstance(); + } + + /// + /// Work thread post a task to the main thread. + /// + public static void PostTask(Action task) + { + lock (PostTasks) + { + PostTasks.Add(task); + } + } + + /// + /// Start to run this dispatcher. + /// + [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(); + } + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs.meta b/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs.meta new file mode 100644 index 0000000..95d2986 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/BigoDispatcher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d1af23e5ee93476382ea747bb4b6985 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IBannerAd.cs b/Assets/BigoAds/Scripts/Common/IBannerAd.cs new file mode 100644 index 0000000..b47ae5d --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IBannerAd.cs @@ -0,0 +1,10 @@ +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Api.Constant; + +namespace BigoAds.Scripts.Common +{ + public interface IBannerAd : IBigoAd + { + void SetPosition(BigoPosition position); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IBannerAd.cs.meta b/Assets/BigoAds/Scripts/Common/IBannerAd.cs.meta new file mode 100644 index 0000000..07400ff --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9632da3a0b8674b539385af7fec47c33 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IBigoAd.cs b/Assets/BigoAds/Scripts/Common/IBigoAd.cs new file mode 100644 index 0000000..8bebc72 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IBigoAd.cs @@ -0,0 +1,22 @@ +using System; +using BigoAds.Scripts.Api; + +namespace BigoAds.Scripts.Common +{ + public interface IBigoAd : IClientBidding where T : BigoRequest + { + event Action OnLoad; + event Action OnLoadFailed; + event Action OnAdShowed; + event Action OnAdClicked; + event Action OnAdDismissed; + event Action OnAdError; + void Load(string slotId, T request); + bool IsLoaded(); + bool IsExpired(); + void Show(); + void Destroy(); + bool IsClientBidding(); + string GetExtraInfo(String key); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IBigoAd.cs.meta b/Assets/BigoAds/Scripts/Common/IBigoAd.cs.meta new file mode 100644 index 0000000..aedaab2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IBigoAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ac3c835ae5b8f421192fb72d32c9c6c1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IClientBidding.cs b/Assets/BigoAds/Scripts/Common/IClientBidding.cs new file mode 100644 index 0000000..941cb45 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IClientBidding.cs @@ -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); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IClientBidding.cs.meta b/Assets/BigoAds/Scripts/Common/IClientBidding.cs.meta new file mode 100644 index 0000000..d02114a --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IClientBidding.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: be474d5a8f44740eeac370fd98153d15 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IClientFactory.cs b/Assets/BigoAds/Scripts/Common/IClientFactory.cs new file mode 100644 index 0000000..9dd9700 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IClientFactory.cs @@ -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(); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IClientFactory.cs.meta b/Assets/BigoAds/Scripts/Common/IClientFactory.cs.meta new file mode 100644 index 0000000..4061cfb --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IClientFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b2cb5f6ac1b7f463db75ac0bfa7d7fbe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs b/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs new file mode 100644 index 0000000..7678caf --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs @@ -0,0 +1,8 @@ +using BigoAds.Scripts.Api; + +namespace BigoAds.Scripts.Common +{ + public interface IInterstitialAd : IBigoAd + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs.meta b/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs.meta new file mode 100644 index 0000000..4b86fca --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IInterstitialAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d31ee1df8a074b81a5575e9a7735b2a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/INativeAd.cs b/Assets/BigoAds/Scripts/Common/INativeAd.cs new file mode 100644 index 0000000..530387d --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/INativeAd.cs @@ -0,0 +1,10 @@ +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Api.Constant; + +namespace BigoAds.Scripts.Common +{ + public interface INativeAd : IBigoAd + { + void SetPosition(BigoPosition position); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/INativeAd.cs.meta b/Assets/BigoAds/Scripts/Common/INativeAd.cs.meta new file mode 100644 index 0000000..2c2e818 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/INativeAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eef5c6b4f590c4ceaac635a2992576ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IPopupAd.cs b/Assets/BigoAds/Scripts/Common/IPopupAd.cs new file mode 100644 index 0000000..9cf8489 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IPopupAd.cs @@ -0,0 +1,8 @@ +using BigoAds.Scripts.Api; + +namespace BigoAds.Scripts.Common +{ + public interface IPopupAd : IBigoAd + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IPopupAd.cs.meta b/Assets/BigoAds/Scripts/Common/IPopupAd.cs.meta new file mode 100644 index 0000000..f0866ad --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IPopupAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e767b9004c4f4ca19baa6f54c409c5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/IRewardedAd.cs b/Assets/BigoAds/Scripts/Common/IRewardedAd.cs new file mode 100644 index 0000000..2b549ab --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IRewardedAd.cs @@ -0,0 +1,10 @@ +using System; +using BigoAds.Scripts.Api; + +namespace BigoAds.Scripts.Common +{ + public interface IRewardedAd : IBigoAd + { + event Action OnUserEarnedReward; + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/IRewardedAd.cs.meta b/Assets/BigoAds/Scripts/Common/IRewardedAd.cs.meta new file mode 100644 index 0000000..a705be0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/IRewardedAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0b3baa8d362724d19997664f34f4320d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/ISDK.cs b/Assets/BigoAds/Scripts/Common/ISDK.cs new file mode 100644 index 0000000..67113a0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/ISDK.cs @@ -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); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/ISDK.cs.meta b/Assets/BigoAds/Scripts/Common/ISDK.cs.meta new file mode 100644 index 0000000..5b97bc8 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/ISDK.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00ad18b48fa1047ee98bd415dd127f65 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Common/ISplashAd.cs b/Assets/BigoAds/Scripts/Common/ISplashAd.cs new file mode 100644 index 0000000..3cf05a6 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/ISplashAd.cs @@ -0,0 +1,8 @@ +using BigoAds.Scripts.Api; + +namespace BigoAds.Scripts.Common +{ + public interface ISplashAd:IBigoAd + { + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Common/ISplashAd.cs.meta b/Assets/BigoAds/Scripts/Common/ISplashAd.cs.meta new file mode 100644 index 0000000..6aa7ff1 --- /dev/null +++ b/Assets/BigoAds/Scripts/Common/ISplashAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1105e67678354e71850311744a989c3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms.meta b/Assets/BigoAds/Scripts/Platforms.meta new file mode 100644 index 0000000..842ddfd --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f730f3e43d10941928ac676ed88c7ee4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android.meta b/Assets/BigoAds/Scripts/Platforms/Android.meta new file mode 100644 index 0000000..9103522 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e595ff25130d84811aae9bbe30751d78 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs new file mode 100644 index 0000000..89fef60 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs @@ -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("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("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("currentActivity"); + var adView = new AndroidJavaClass("sg.bigo.ads.AdHelper").CallStatic("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("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); + } +} \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs.meta new file mode 100644 index 0000000..a1fed7c --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7b17fadc228c48b6900058970865c98 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java new file mode 100755 index 0000000..6900850 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java @@ -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 clickableViews = new ArrayList<>(); + clickableViews.add(titleView); + clickableViews.add(descriptionView); + clickableViews.add(ctaButton); + nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews); + return nativeView; + } + + private static T findViewByIdName(ViewGroup parent, String name) { + Context context = parent.getContext(); + int id = context.getResources().getIdentifier(name, "id", context.getPackageName()); + return parent.findViewById(id); + } +} diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java.meta b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java.meta new file mode 100644 index 0000000..ab4bd1d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdHelper.java.meta @@ -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: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs b/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs new file mode 100644 index 0000000..3735717 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs @@ -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 OnAdError; + private const string ListenerName = AndroidPlatformTool.ClassPackage + ".api.AdInteractionListener"; + + public AdInteractionCallback(Action onAdShowed, Action onAdClicked, Action onAdDismissed, Action 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("getCode"); + var message = error.Call("getMessage"); + OnAdError?.Invoke(code, message); + } + + public void onAdOpened() + { + + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs.meta new file mode 100644 index 0000000..9524d94 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdInteractionCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eeaf0303131624578b3997f9db6cb014 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs b/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs new file mode 100644 index 0000000..96565b4 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs @@ -0,0 +1,33 @@ +#if UNITY_ANDROID +using System; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.Android +{ + public class AdLoadCallback : AndroidJavaProxy + { + private readonly Action onLoad; + private readonly Action onLoadFailed; + + public AdLoadCallback(Action onLoad, Action onLoadFailed) : base( + AndroidPlatformTool.ClassPackage + ".api.AdLoadListener") + { + this.onLoad = onLoad; + this.onLoadFailed = onLoadFailed; + } + + public void onError(AndroidJavaObject error) + { + var code = error.Call("getCode"); + var message = error.Call("getMessage"); + onLoadFailed?.Invoke(code, message); + } + + public void onAdLoaded(AndroidJavaObject ad) + { + onLoad?.Invoke(ad); + } + } + +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs.meta new file mode 100644 index 0000000..0fb8eef --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AdLoadCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b4d06d46018574b7bae1c9dc60ef6122 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs new file mode 100644 index 0000000..d541307 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + + public AndroidBannerAd() + { + OnAdLoad += ((ad) => + { + BannerAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoBannerRequest request) + { + if (request == null) + { + return; + } + var bannerLoaderBuilder = new AndroidJavaObject(BannerAdLoaderClassName); + bannerLoaderBuilder?.Call(BannerAdLoaderExtMethod, request.ExtraInfoJson); + bannerLoaderBuilder?.Call(BannerAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var bannerLoader = bannerLoaderBuilder?.Call(BannerBuildMethod); + + var bannerRequestBuilder = new AndroidJavaObject(BannerAdRequestClassName); + bannerRequestBuilder?.Call("withSlotId", slotId); + bannerRequestBuilder?.Call("withAge", request.Age); + bannerRequestBuilder?.Call("withGender", (int)(request.Gender)); + bannerRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var bannerSize = new AndroidJavaClass(BannerSizeClassName).GetStatic("BANNER"); + int width = request.Size.Width; + int height = request.Size.Height; + if (width == 300 && height == 250) { + bannerSize = new AndroidJavaClass(BannerSizeClassName).GetStatic("MEDIUM_RECTANGLE"); + } + AndroidJavaClass arrayClass = new AndroidJavaClass("java.lang.reflect.Array"); + AndroidJavaObject arrayObject = arrayClass.CallStatic("newInstance", new AndroidJavaClass(BannerSizeClassName), 1); + arrayClass.CallStatic("set", arrayObject, 0, bannerSize); + + bannerRequestBuilder?.Call("withAdSizes", arrayObject); + + var bannerRequest = bannerRequestBuilder?.Call(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("isExpired"); + } + + public void SetPosition(BigoPosition position) + { + AndroidPlatformTool.CallMethodOnMainThread(() => + { + AdHelper.ShowBannerAd(BannerAd, position); + }); + } + + public bool IsClientBidding() + { + if (BannerAd == null) return false; + AndroidJavaObject bid = BannerAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (BannerAd == null) return ""; + return BannerAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (BannerAd == null) return 0; + AndroidJavaObject bid = BannerAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (BannerAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + BannerAd.Call("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 ("valueOf", firstPrice); + BannerAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs.meta new file mode 100644 index 0000000..133fd1f --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 46ee6aacd6a2546ce8e23dd89e5d27d4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs new file mode 100644 index 0000000..45d6f26 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs @@ -0,0 +1,49 @@ +#if UNITY_ANDROID + +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Platforms.Android +{ + class AndroidClientFactory : IClientFactory + { + /// + /// + /// + /// + 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 \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs.meta new file mode 100644 index 0000000..8e800fb --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidClientFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1809d4d3a8b034fa88284da804f66a71 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs new file mode 100644 index 0000000..0beed80 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + + public AndroidInterstitialAd() + { + OnAdLoad += ((ad) => + { + InterstitialAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoInterstitialRequest request) + { + if (request == null) + { + return; + } + var InterstitialLoaderBuilder = new AndroidJavaObject(InterstitialAdLoaderClassName); + InterstitialLoaderBuilder?.Call(InterstitialAdLoaderExtMethod, request.ExtraInfoJson); + InterstitialLoaderBuilder?.Call(InterstitialAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var InterstitialLoader = InterstitialLoaderBuilder?.Call(InterstitialBuildMethod); + + var InterstitialRequestBuilder = new AndroidJavaObject(InterstitialAdRequestClassName); + InterstitialRequestBuilder?.Call("withSlotId", slotId); + InterstitialRequestBuilder?.Call("withAge", request.Age); + InterstitialRequestBuilder?.Call("withGender", (int)(request.Gender)); + InterstitialRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var InterstitialRequest = InterstitialRequestBuilder?.Call(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("isExpired"); + } + + public bool IsClientBidding() + { + if (InterstitialAd == null) return false; + AndroidJavaObject bid = InterstitialAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (InterstitialAd == null) return ""; + return InterstitialAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (InterstitialAd == null) return 0; + AndroidJavaObject bid = InterstitialAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (InterstitialAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + InterstitialAd.Call("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 ("valueOf", firstPrice); + InterstitialAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs.meta new file mode 100644 index 0000000..2218096 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidInterstitialAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 087385bbddf0541e5be511be304caee8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs new file mode 100644 index 0000000..9cbd5a7 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + + public AndroidNativeAd() + { + OnAdLoad += ((ad) => + { + NativeAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoNativeRequest request) + { + if (request == null) + { + return; + } + var nativeLoaderBuilder = new AndroidJavaObject(NativeAdLoaderClassName); + nativeLoaderBuilder?.Call(NativeAdLoaderExtMethod, request.ExtraInfoJson); + nativeLoaderBuilder?.Call(NativeAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var nativeLoader = nativeLoaderBuilder?.Call(NativeBuildMethod); + + var nativeRequestBuilder = new AndroidJavaObject(NativeAdRequestClassName); + nativeRequestBuilder?.Call("withSlotId", slotId); + nativeRequestBuilder?.Call("withAge", request.Age); + nativeRequestBuilder?.Call("withGender", (int)(request.Gender)); + nativeRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var nativeRequest = nativeRequestBuilder?.Call(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("isExpired"); + } + + public void SetPosition(BigoPosition position) + { + AndroidPlatformTool.CallMethodOnMainThread(() => + { + AdHelper.ShowNativeAd(NativeAd, position); + }); + } + + public bool IsClientBidding() + { + if (NativeAd == null) return false; + AndroidJavaObject bid = NativeAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (NativeAd == null) return ""; + return NativeAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (NativeAd == null) return 0; + AndroidJavaObject bid = NativeAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (NativeAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + NativeAd.Call("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 ("valueOf", firstPrice); + NativeAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs.meta new file mode 100644 index 0000000..0369f2d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidNativeAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 04dd9e8545a394cc0b0bd15cfe325045 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs new file mode 100644 index 0000000..208fcbb --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs @@ -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(CurrentActivityMethod); + } + + public static AndroidJavaObject GetBigoConfig(BigoAdConfig config) + { + var builder = new AndroidJavaObject(AdConfigClassName); + if (config != null) + { + void CallNativeFunction(string methodName, T arg) + { + builder.Call(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 item in config.ExtraDictionary) + { + Debug.Log($"bigo sdk config extra:" + item.Key + "=" + item.Value); + builder.Call("addExtra", item.Key, item.Value); + } + } + + return builder.Call("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 \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs.meta new file mode 100644 index 0000000..f643aef --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPlatformTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec73d6fa8edaa4c619d96f6db2789dd1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs new file mode 100644 index 0000000..81382d7 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + + public AndroidPopupAd() + { + OnAdLoad += ((ad) => + { + PopupAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoPopupRequest request) + { + if (request == null) + { + return; + } + var PopupLoaderBuilder = new AndroidJavaObject(PopupAdLoaderClassName); + PopupLoaderBuilder?.Call(PopupAdLoaderExtMethod, request.ExtraInfoJson); + PopupLoaderBuilder?.Call(PopupAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var PopupLoader = PopupLoaderBuilder?.Call(PopupBuildMethod); + + var PopupRequestBuilder = new AndroidJavaObject(PopupAdRequestClassName); + PopupRequestBuilder?.Call("withSlotId", slotId); + PopupRequestBuilder?.Call("withAge", request.Age); + PopupRequestBuilder?.Call("withGender", (int)(request.Gender)); + PopupRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var PopupRequest = PopupRequestBuilder?.Call(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("isExpired"); + } + + public bool IsClientBidding() + { + if (PopupAd == null) return false; + AndroidJavaObject bid = PopupAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (PopupAd == null) return ""; + return PopupAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (PopupAd == null) return 0; + AndroidJavaObject bid = PopupAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (PopupAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + PopupAd.Call("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 ("valueOf", firstPrice); + PopupAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs.meta new file mode 100644 index 0000000..595df40 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidPopupAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34628c2993e174780bc5786dff90c900 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs new file mode 100644 index 0000000..3e2f204 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + public event Action OnUserEarnedReward; + + public AndroidRewardedAd() + { + OnAdLoad += ((ad) => + { + RewardedAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoRewardedRequest request) + { + if (request == null) + { + return; + } + var rewardedAdLoaderBuilder = new AndroidJavaObject(RewardedAdLoaderClassName); + rewardedAdLoaderBuilder?.Call(RewardedAdLoaderExtMethod, request.ExtraInfoJson); + rewardedAdLoaderBuilder?.Call(RewardedAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var rewardedAdLoader = rewardedAdLoaderBuilder?.Call(RewardedAdBuildMethod); + + var rewardedAdRequestBuilder = new AndroidJavaObject(RewardedAdRequestClassName); + rewardedAdRequestBuilder?.Call("withSlotId", slotId); + rewardedAdRequestBuilder?.Call("withAge", request.Age); + rewardedAdRequestBuilder?.Call("withGender", (int)(request.Gender)); + rewardedAdRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var RewardedAdRequest = rewardedAdRequestBuilder?.Call(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("isExpired"); + } + + public bool IsClientBidding() + { + if (RewardedAd == null) return false; + AndroidJavaObject bid = RewardedAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (RewardedAd == null) return ""; + return RewardedAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (RewardedAd == null) return 0; + AndroidJavaObject bid = RewardedAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (RewardedAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + RewardedAd.Call("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 ("valueOf", firstPrice); + RewardedAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs.meta new file mode 100644 index 0000000..d075733 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidRewardedAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6bca6ddceb592449c9606175e8f5f77e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs b/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs new file mode 100644 index 0000000..ae9afce --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs @@ -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 OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + + public AndroidSplashAd() + { + OnAdLoad += ((ad) => + { + SplashAd = ad; + OnLoad?.Invoke(); + }); + } + + private event Action OnAdLoad; + + public void Load(string slotId, BigoSplashRequest request) + { + if (request == null) + { + return; + } + var SplashLoaderBuilder = new AndroidJavaObject(SplashAdLoaderClassName); + SplashLoaderBuilder?.Call(SplashAdLoaderExtMethod, request.ExtraInfoJson); + SplashLoaderBuilder?.Call(SplashAdLoaderBuildMethod, new AdLoadCallback(OnAdLoad, OnLoadFailed)); + var SplashLoader = SplashLoaderBuilder?.Call(SplashBuildMethod); + + var SplashRequestBuilder = new AndroidJavaObject(SplashAdRequestClassName); + SplashRequestBuilder?.Call("withSlotId", slotId); + SplashRequestBuilder?.Call("withAge", request.Age); + SplashRequestBuilder?.Call("withGender", (int)(request.Gender)); + SplashRequestBuilder?.Call("withActivatedTime", request.ActivatedTime); + + var SplashRequest = SplashRequestBuilder?.Call(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("isExpired"); + } + + public bool IsClientBidding() + { + if (SplashAd == null) return false; + AndroidJavaObject bid = SplashAd.Call("getBid"); + return bid != null; + } + + public string GetExtraInfo(string key) + { + if (SplashAd == null) return ""; + return SplashAd.Call("getExtraInfo", key); + } + + /// get price + public double getPrice() + { + if (SplashAd == null) return 0; + AndroidJavaObject bid = SplashAd.Call("getBid"); + return bid == null ? 0 : bid.Call("getPrice"); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + if (SplashAd == null) return; + var secPriceDouble = new AndroidJavaClass("java.lang.Double").CallStatic ("valueOf", secPrice); + SplashAd.Call("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 ("valueOf", firstPrice); + SplashAd.Call("getBid")?.Call("notifyLoss", firstPriceDouble, firstBidder, (int)lossReason); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs.meta new file mode 100644 index 0000000..23d0ec2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/AndroidSplashAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cdf1866c87531416d8159aae83c6e470 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs b/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs new file mode 100644 index 0000000..98acbc9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs @@ -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(InitSuccessMethod); + } + + public string GetSDKVersion() + { + return InvokeNativeMethod("getSDKVersion"); + } + + public string GetSDKVersionName() + { + return InvokeNativeMethod("getSDKVersionName"); + } + + public void SetUserConsent(ConsentOptions option, bool consent) + { + var clazz = new AndroidJavaClass(ConsentOptionsClassName); + AndroidJavaObject obj = null; + switch (option) + { + case ConsentOptions.GDPR: + obj = clazz.GetStatic("GDPR"); + break; + case ConsentOptions.CCPA: + obj = clazz.GetStatic("CCPA"); + break; + case ConsentOptions.LGPD: + obj = clazz.GetStatic("LGPD"); + break; + case ConsentOptions.COPPA: + obj = clazz.GetStatic("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(string methodName, params object[] args) + { + return new AndroidJavaClass(SDKClientClassName).CallStatic(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 \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs.meta new file mode 100644 index 0000000..aa9e2ee --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/BigoSdkClient.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a768d78eefdf84ba4bcbfa8077fe6a62 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs b/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs new file mode 100644 index 0000000..6774e3e --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs @@ -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 onAdError, + Action userEarnedReward) : base( + onAdShowed, onAdClicked, onAdDismissed, onAdError, ListenerName) + { + OnUserEarnedReward = userEarnedReward; + } + + public void onAdRewarded() + { + OnUserEarnedReward?.Invoke(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs.meta new file mode 100644 index 0000000..6645f1d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/RewardedAdInteractionCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 679833dea127f43cebbb043ff2a1c2f2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs b/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs new file mode 100644 index 0000000..854829d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs @@ -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 onAdError) : base( + onAdShowed, onAdClicked, onAdDismissed, onAdError, ListenerName) + { + + } + + public void onAdSkipped() + { + + } + + public void onAdFinished() + { + + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs.meta b/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs.meta new file mode 100644 index 0000000..8e4456f --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/Android/SplashAdInteractionCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02f23872f0193427487d67e2373c8e41 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS.meta b/Assets/BigoAds/Scripts/Platforms/iOS.meta new file mode 100644 index 0000000..d66d3ec --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc250d638e6404797a830f56c2b7e40e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter.meta new file mode 100644 index 0000000..0abfc3e --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e1921a1c99c3c47ae95c0103939e6ffa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd.meta new file mode 100644 index 0000000..1935887 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7eed132e5c97a47718143d7e692cafda +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner.meta new file mode 100644 index 0000000..3b590a4 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aaf596d8ee1bd409e831a2c8c6919580 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs new file mode 100644 index 0000000..3fb5612 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs @@ -0,0 +1,112 @@ +#if UNITY_IOS +using System; +using System.Threading; +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Api.Constant; +using BigoAds.Scripts.Common; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + using System; + using BigoAds.Scripts.Api; + using BigoAds.Scripts.Common; + using BigoAds.Scripts.Platforms.iOS; + using System.Runtime.InteropServices; + public class BigoUnityBannerAd: BigoIOSBaseAd, IBannerAd + { + private BigoBannerRequest bannerRequest; + //TODO:线程问题需要考虑下 + public void Load(string slotId, BigoBannerRequest request) + { + bannerRequest = request; + adType = 2; + this.unityAdPtr = (IntPtr)GCHandle.Alloc (this); + IntPtr ptr = this.unityAdPtr; + + int width = request.Size.Width; + int height = request.Size.Height; + + int x = CalculateMiddleX(width); + int y = CalculatePositionY(request.Position,height); + + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"calculate-origin:{x},{y}-size:{width},{height}"); + BigoIOS_loadBannerAdData(ptr, + slotId, + request.ToJson(), + x, + y, + width, + height, + cs_adDidLoadCallback, + cs_adLoadFailCallBack, + cs_adDidShowCallback, + cs_adDidClickCallback, + cs_adDidDismissCallback, + cs_adDidErrorCallBack + ); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"request.position:{request.Position},slotId:{slotId}"); + } + + private int CalculatePositionY(BigoPosition position, int bannerHeight) + { + int screenHeight = BigoIOS_getScreenHeight(); + float y = BigoIOS_getScreenSafeTop(); + if (position == BigoPosition.Middle) + { + y = (float)((screenHeight - bannerHeight) * 0.5); + } + else if (position == BigoPosition.Bottom) + { + y = (float)(screenHeight - bannerHeight - BigoIOS_getScreenSafeBottom()); + } + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position:{position},screenHeight:{screenHeight}-y:{y}"); + return (int)y; + } + + private int CalculateMiddleX(int bannerWidth) + { + int screenWidth = BigoIOS_getScreenWidth(); + int x = (int)((screenWidth - bannerWidth) * 0.5); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"screenWidth:{screenWidth}-x:{x}"); + return x; + } + + public void SetPosition(BigoPosition position) + { + int x = CalculateMiddleX(bannerRequest.Size.Width); + int y = CalculatePositionY(position, bannerRequest.Size.Height); + BigoIOS_SetBannerAdPosition(unityAdPtr,x,y); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position-{position}"); + } + //MARK: c# - oc + [DllImport("__Internal")] + static extern void BigoIOS_loadBannerAdData(IntPtr unityAdPtr, + string slotId, + string requestJson, + int x, + int y, + int width, + int height, + adDidLoadCallback_delegate successCallback, + adLoadFailCallBack_delegate failCallback, + adDidShowCallback_delegate showCallback, + adDidClickCallback_delegate clickCallback, + adDidDismissCallback_delegate dismissCallback, + adDidErrorCallback_delegate adErrorCallback + ); + + [DllImport("__Internal")] + static extern void BigoIOS_SetBannerAdPosition(IntPtr unityAdPtr, int x, int y); + + [DllImport("__Internal")] + static extern int BigoIOS_getScreenWidth(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenHeight(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenSafeTop(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenSafeBottom(); + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs.meta new file mode 100644 index 0000000..2928e7d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f3106d1522ac4b95a8f73c101387f8a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h new file mode 100644 index 0000000..006c016 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h @@ -0,0 +1,24 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load banner Ad + void BigoIOS_loadBannerAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + int x, + int y, + int width, + int height, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ); + //show banner ad + void BigoIOS_showBannerAd(UnityAd unityAd); + void BigoIOS_SetBannerAdPosition(UnityAd unityAd,int x, int y); + void BigoIOS_removeBannerView(UnityAd unityAd); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h.meta new file mode 100644 index 0000000..d82d603 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: a86c122698a834a0e868b3d38d576442 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm new file mode 100644 index 0000000..a2ff068 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm @@ -0,0 +1,133 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" + +extern "C"{ + + +int BigoIOS_getScreenWidth () { + __block int width = 0; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + width = (int)vc.view.frame.size.width; + }); + return width; +} + +int BigoIOS_getScreenHeight () { + __block int height = 0; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + height = (int)vc.view.frame.size.height; + }); + return height; +} + +int BigoIOS_getScreenSafeBottom() { + __block int bottom = 0; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + bottom = (int)vc.view.safeAreaInsets.bottom; + }); + return bottom; +} + +int BigoIOS_getScreenSafeTop() { + __block int top = 0; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + top = (int)vc.view.safeAreaInsets.top; + }); + return top; +} + +//load Banner ad +void BigoIOS_loadBannerAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + int x, + int y, + int width, + int height, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ) { + BigoIOS_dispatchSyncMainQueue(^{ + BigoAdSize *size = BigoAdSize.BANNER; + if (width == 300 && height == 250) { + size = BigoAdSize.MEDIUM_RECTANGLE; + } + NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson); + BigoUnityBannerAdHandler *adHandler = [[BigoUnityBannerAdHandler alloc] init]; + BigoBannerAdRequest *request = [[BigoBannerAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId) adSizes:@[size]]; + request.age = [requestDict[@"age"] intValue]; + request.gender = (BigoAdGender)[requestDict[@"gender"] intValue]; + request.activatedTime = [requestDict[@"activatedTime"] longLongValue]; + BigoBannerAdLoader *adLoader = [[BigoBannerAdLoader alloc] initWithBannerAdLoaderDelegate:adHandler]; + adLoader.ext = requestDict[@"extraInfo"]; + adHandler.adLoader = adLoader; + adHandler.unityAd = unityAd; + adHandler.showCallback = showCallback; + adHandler.clickCallback = clickCallback; + adHandler.dismissCallback = dismissCallback; + adHandler.adErrorCallback = adErrorCallback; + adHandler.successCallback = successCallback; + adHandler.failCallback = failCallback; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey]; + [adLoader loadAd:request]; + }); + +} + +BigoUnityBannerAdHandler* BigoIOS_getBannerAdHandler(UnityAd unityAd) { + if (!unityAd) return nil; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBannerAdHandler *handler = (BigoUnityBannerAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + if (!handler || ![handler isMemberOfClass:[BigoUnityBannerAdHandler class]]) { + return nil; + } + return handler; +} + +void BigoIOS_showBannerAd(UnityAd unityAd) { + BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd); + if (!handler) return; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + BigoBannerAd *ad = (BigoBannerAd *)handler.ad; + [vc.view addSubview:ad.adView]; + }); +} + +void BigoIOS_SetBannerAdPosition(UnityAd unityAd,int x, int y) { + BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + BigoBannerAd *ad = (BigoBannerAd *)handler.ad; + CGRect frame = ad.adView.frame; + frame.origin.x = x; + frame.origin.y = y; + ad.adView.frame = frame; + }); +} + +void BigoIOS_removeBannerView(UnityAd unityAd) { + BigoUnityBannerAdHandler *handler = BigoIOS_getBannerAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + BigoBannerAd *ad = (BigoBannerAd *)handler.ad; + [ad.adView removeFromSuperview]; + }); +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm.meta new file mode 100644 index 0000000..7b0acc0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Banner/BigoUnityBannerAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: fd1772b6ab58f4e74ac7e89d3fd471c3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs new file mode 100644 index 0000000..5ff22cc --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs @@ -0,0 +1,265 @@ +#if UNITY_IOS + +using System.Collections.Generic; +using AOT; +using UnityEngine; +using BigoAds.Scripts.Api.Constant; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + using System; + using BigoAds.Scripts.Api; + using BigoAds.Scripts.Common; + using BigoAds.Scripts.Platforms.iOS; + using System.Runtime.InteropServices; + public class BigoIOSBaseAd : IBigoAd + { + public event Action OnLoad; + public event Action OnLoadFailed; + public event Action OnAdShowed; + public event Action OnAdClicked; + public event Action OnAdDismissed; + public event Action OnAdError; + public void Load(string slotId, BigoRequest request) + { + + } + + protected void LoadAdData(string slotId, BigoRequest request) { + this.unityAdPtr = (IntPtr)GCHandle.Alloc (this); + IntPtr ptr = this.unityAdPtr; + + BigoIOS_loadAdData(adType, + ptr, + slotId, + request.ToJson(), + cs_adDidLoadCallback, + cs_adLoadFailCallBack, + cs_adDidShowCallback, + cs_adDidClickCallback, + cs_adDidDismissCallback, + cs_adDidErrorCallBack + ); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"slotId:{slotId},request{request}"); + } + + public bool IsLoaded() + { + return bigoAdLoaded; + } + + public virtual void Show() + { + LOGWithMessage("Show"); + BigoIOS_showAd(adType,this.unityAdPtr); + } + + public virtual bool IsExpired() + { + return BigoIOS_IsExpired(unityAdPtr); + } + + public void Destroy() + { + BigoIOS_destroyAd(adType,unityAdPtr); + if (unityAdPtr != IntPtr.Zero) + { + GCHandle unityAdhandle = (GCHandle)this.unityAdPtr; + unityAdhandle.Free(); + } + unityAdPtr = IntPtr.Zero; + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"unityPtr:{unityAdPtr}"); + } + + public bool IsClientBidding() + { + return BigoIOS_IsClientBidding(unityAdPtr); + } + + public string GetExtraInfo(String key) + { + //todo + return ""; + } + + /// get price + public double getPrice() + { + return BigoIOS_GetPrice(unityAdPtr); + } + + ///notify win + public void notifyWin(double secPrice, string secBidder) + { + BigoIOS_NotifyWin(unityAdPtr, secPrice, secBidder); + } + + ///notify loss + public void notifyLoss(double firstPrice, string firstBidder, BGAdLossReason lossReason) + { + BigoIOS_NotifyLoss(unityAdPtr, firstPrice, firstBidder, (int)lossReason); + } + + protected void LOGWithMessage(string method) + { + LOGWithMessage(method,string.Empty); + } + protected void LOGWithMessage(string method,string msg) + { + //native = 1, banner = 2, interstitial = 3, rewarded = 4, appOpen = 5 + int adtype = adType; + string adTypeString = "unknown"; + if (adtype == 1) + { + adTypeString = "native"; + } + else if (adtype == 2) + { + adTypeString = "banner"; + } + else if (adtype == 3) + { + adTypeString = "interstitial"; + } + else if (adtype == 4) + { + adTypeString = "rewarded"; + } + else if (adtype == 5) + { + adTypeString = "appOpen"; + } + + //System.Reflection.MethodBase.GetCurrentMethod()?.Name + Type classType = this.GetType(); + string className = $"{adTypeString}-{classType.Name}"; + BigoUnityTools.LOGWithMessage(className,method,msg); + } + + protected static BigoIOSBaseAd GetUnityAd(IntPtr unityAdPtr) + { + GCHandle handle = (GCHandle) unityAdPtr; + BigoIOSBaseAd unityAd = handle.Target as BigoIOSBaseAd; + // handle.Free (); + return unityAd; + } + + protected int adType = 0; + private bool bigoAdLoaded = false; + protected IntPtr unityAdPtr = IntPtr.Zero; + //MARK: c --> oc + [DllImport("__Internal")] + static extern void BigoIOS_loadAdData(int adType, + IntPtr unityAdPtr, + string slotId, + string requestJson, + adDidLoadCallback_delegate successCallback, + adLoadFailCallBack_delegate failCallback, + adDidShowCallback_delegate showCallback, + adDidClickCallback_delegate clickCallback, + adDidDismissCallback_delegate dismissCallback, + adDidErrorCallback_delegate adErrorCallback); + [DllImport("__Internal")] + static extern void BigoIOS_showAd(int adType,IntPtr unityAdPtr); + + [DllImport("__Internal")] + static extern void BigoIOS_destroyAd(int adType, IntPtr unityAdPtr); + + [DllImport("__Internal")] + static extern bool BigoIOS_IsExpired(IntPtr unityAdPtr); + + [DllImport("__Internal")] + static extern bool BigoIOS_IsClientBidding(IntPtr unityAdPtr); + + [DllImport("__Internal")] + static extern double BigoIOS_GetPrice(IntPtr unityAdPtr); + + [DllImport("__Internal")] + static extern void BigoIOS_NotifyWin(IntPtr unityAdPtr, double secPrice, string secBidder); + + [DllImport("__Internal")] + static extern void BigoIOS_NotifyLoss(IntPtr unityAdPtr, double firstPrice, string firstBidder, int lossReason); + + //callback method + protected delegate void adDidLoadCallback_delegate(IntPtr unityAdPtr); + protected delegate void adLoadFailCallBack_delegate(IntPtr unityAdPtr, int code, string msg); + + protected delegate void adDidShowCallback_delegate(IntPtr unityAdPtr); + protected delegate void adDidClickCallback_delegate(IntPtr unityAdPtr); + protected delegate void adDidDismissCallback_delegate(IntPtr unityAdPtr); + protected delegate void adDidErrorCallback_delegate(IntPtr unityAdPtr, int code, string msg); + + [MonoPInvokeCallback(typeof(adDidLoadCallback_delegate))] + protected static void cs_adDidLoadCallback(IntPtr unityAdPtr) + { + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd == null) + { + return; + } + unityAd.bigoAdLoaded = true; + unityAd.OnLoad?.Invoke(); + unityAd.LOGWithMessage("cs_adDidLoad"); + } + + [MonoPInvokeCallback(typeof(adLoadFailCallBack_delegate))] + protected static void cs_adLoadFailCallBack(IntPtr unityAdPtr, int code, string msg) + { + + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd.OnLoadFailed != null) + { + unityAd.OnLoadFailed(code, msg); + } + unityAd.LOGWithMessage("cs_adLoadFail",$"code:{code},msg:{msg}"); + } + + [MonoPInvokeCallback(typeof(adDidShowCallback_delegate))] + protected static void cs_adDidShowCallback(IntPtr unityAdPtr) + { + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd == null) + { + return; + } + unityAd.OnAdShowed?.Invoke(); + unityAd.LOGWithMessage($"cs_show"); + } + + [MonoPInvokeCallback(typeof(adDidClickCallback_delegate))] + protected static void cs_adDidClickCallback(IntPtr unityAdPtr) + { + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd == null) + { + return; + } + unityAd.OnAdClicked?.Invoke(); + unityAd.LOGWithMessage("cs_click"); + } + + [MonoPInvokeCallback(typeof(adDidDismissCallback_delegate))] + protected static void cs_adDidDismissCallback(IntPtr unityAdPtr) + { + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd == null) + { + return; + } + unityAd.OnAdDismissed?.Invoke(); + unityAd.LOGWithMessage("cs_dismiss"); + } + + [MonoPInvokeCallback(typeof(adDidErrorCallback_delegate))] + protected static void cs_adDidErrorCallBack(IntPtr unityAdPtr, int code, string msg) + { + BigoIOSBaseAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr); + if (unityAd.OnAdError != null) + { + unityAd.OnAdError(code, msg); + } + unityAd.LOGWithMessage("cs_aderror",$"code:{code},msg:{msg}"); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs.meta new file mode 100644 index 0000000..68b37d0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9b8d512f4ea0948bb8110a2eee062858 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm new file mode 100644 index 0000000..43f18d4 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm @@ -0,0 +1,109 @@ +#import +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdHandlerManager.h" +#import "BigoUnityBannerAd.h" +#import "BigoUnityInterstitialAd.h" +#import "BigoUnityRewardedAd.h" +#import "BigoUnitySplashAd.h" +#import "BigoUnityNativeAd.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityPopupAd.h" + +extern "C" { +enum BigoIOSAdType { + native = 1, banner = 2, interstitial = 3, rewarded = 4, splash = 5, popup = 6 +}; +void BigoIOS_loadAdData(int adType, + UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback) { + if (adType == rewarded || adType == banner) {//custom load + return; + } + + if (adType == interstitial) { + BigoIOS_loadInterstitialAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback); + } + else if (adType == splash) { + BigoIOS_loadSplashAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback); + } + else if (adType == native) { + BigoIOS_loadNativeAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback); + } else if (adType == popup) { + BigoIOS_loadPopupAdData(unityAd, slotId, requestJson, successCallback, failCallback, showCallback, clickCallback, dismissCallback, adErrorCallback); + } + +} +void BigoIOS_showAd(int adType, UnityAd unityAd) { + if (adType == interstitial) { + BigoIOS_showInterstitialAd(unityAd); + } + else if (adType == splash) { + BigoIOS_showSplashAd(unityAd); + } + else if (adType == rewarded) { + BigoIOS_showRewardedAd(unityAd); + } + else if (adType == banner) { + BigoIOS_showBannerAd(unityAd); + } + else if (adType == native) { + BigoIOS_showNativeAd(unityAd); + } +} + +void BigoIOS_destroyAd(int adType, UnityAd unityAd) { + if (adType == banner) { + BigoIOS_removeBannerView(unityAd); + } + else if (adType == native) { + BigoIOS_removeNativeView(unityAd); + } + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager removeAdHandlerWithKey:unityAdKey]; +} + +BOOL BigoIOS_IsExpired(UnityAd unityAd) { + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + BigoAd *ad = (BigoAd *)(handler.ad); + return ad.isExpired; +} + +BOOL BigoIOS_IsClientBidding(UnityAd unityAd) { + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + BigoAd *ad = (BigoAd *)(handler.ad); + return ad.getBid != nil; +} + +CGFloat BigoIOS_GetPrice(UnityAd unityAd) { + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + BigoAd *ad = (BigoAd *)(handler.ad); + return ad.getBid.getPrice; +} + +void BigoIOS_NotifyWin(UnityAd unityAd, CGFloat secPrice, const char* secBidder) { + NSString *secBidderString = BigoIOS_transformNSStringForm(secBidder); + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + BigoAd *ad = (BigoAd *)(handler.ad); + [ad.getBid notifyWinWithSecPrice:secPrice secBidder:secBidderString]; +} + +void BigoIOS_NotifyLoss(UnityAd unityAd, CGFloat firstPrice , const char* firstBidder, int lossReason) { + NSString *firstBidderString = BigoIOS_transformNSStringForm(firstBidder); + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityBaseAdHandler *handler = (BigoUnityBaseAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + BigoAd *ad = (BigoAd *)(handler.ad); + [ad.getBid notifyLossWithFirstPrice:firstPrice firstBidder:firstBidderString lossReason:(BGAdLossReasonType)lossReason]; +} + +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm.meta new file mode 100644 index 0000000..00a8018 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoIOSBaseAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 75401cc01b4054f97931486033a4c690 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h new file mode 100644 index 0000000..acf3ece --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h @@ -0,0 +1,22 @@ + +#import +#import "BigoUnityBaseAdHandler.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface BigoUnityAdHandlerManager : NSObject + ++ (void)saveAdHandler:(BigoUnityBaseAdHandler *)adhandler withKey:(NSString *)key; + ++ (void)removeAdHandlerWithKey:(NSString *)key; + ++ (NSString *)createKeyUnityAd:(UnityAd)unityAd; + ++ (nullable BigoUnityBaseAdHandler *)handlerWithKey:(NSString *)key; + ++ (void)printList; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h.meta new file mode 100644 index 0000000..4aa61d9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: f39924fa7a4d144ee93ad3242f4c5e9f +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m new file mode 100644 index 0000000..2abc066 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m @@ -0,0 +1,70 @@ +#import "BigoUnityAdHandlerManager.h" + +@interface BigoUnityAdHandlerManager() + +@property (nonatomic, strong) dispatch_semaphore_t semaphore; +@property (nonatomic, strong) NSMutableDictionary *dictionary; + +@end + +@implementation BigoUnityAdHandlerManager + ++ (instancetype)sharedInstance { + static BigoUnityAdHandlerManager *manager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + manager = [[BigoUnityAdHandlerManager alloc] init]; + }); + return manager; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.dictionary = [NSMutableDictionary new]; + self.semaphore = dispatch_semaphore_create(1); + } + return self; +} + ++ (void)saveAdHandler:(BigoUnityBaseAdHandler *)adhandler withKey:(NSString *)key { + if (!adhandler || key.length == 0) { + return; + } + BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance]; + dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER); + [manager.dictionary setObject:adhandler forKey:key]; + dispatch_semaphore_signal(manager.semaphore); +} + ++ (void)removeAdHandlerWithKey:(NSString *)key { + if (key.length == 0) { + return; + } + BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance]; + dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER); + [manager.dictionary removeObjectForKey:key]; + dispatch_semaphore_signal(manager.semaphore); +} + ++ (NSString *)createKeyUnityAd:(UnityAd)unityAd { + return [NSString stringWithFormat:@"%p",unityAd]; +} + ++ (nullable BigoUnityBaseAdHandler *)handlerWithKey:(NSString *)key { + if (key.length == 0) { + return nil; + } + BigoUnityAdHandlerManager *manager = [BigoUnityAdHandlerManager sharedInstance]; + dispatch_semaphore_wait(manager.semaphore, DISPATCH_TIME_FOREVER); + BigoUnityBaseAdHandler *handler = [manager.dictionary objectForKey:key]; + dispatch_semaphore_signal(manager.semaphore); + return handler; +} + ++ (void)printList { + NSLog(@"bigo-ios-list:%@",[BigoUnityAdHandlerManager sharedInstance].dictionary); +} + +@end diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m.meta new file mode 100644 index 0000000..dcae4b1 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityAdHandlerManager.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 053a4c32bd9344bcd9a22f2e0c87f777 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h new file mode 100644 index 0000000..f703364 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h @@ -0,0 +1,62 @@ + +#import +#import +#import + +typedef void* UnityAd;//unity ad +typedef void* BigoAdSdkAd;//bigo ad +//int + +//callback of ad load +typedef void(*AdDidLoadCallback)(UnityAd unityAd); +typedef void (*AdLoadFailCallBack)(UnityAd unityAd, int code, const char *msg); + +//callback of ad event +typedef void(*AdDidShowCallback)(UnityAd unityAd); +typedef void(*AdDidClickCallback)(UnityAd unityAd); +typedef void(*AdDidDismissCallback)(UnityAd unityAd); +typedef void (*AdDidErrorCallback)(UnityAd unityAd, int code, const char *msg); + +typedef void (*AdDidEarnRewardCallback)(UnityAd unityA); + +@interface BigoUnityBaseAdHandler : NSObject + +@property (nonatomic, assign) UnityAd unityAd; +@property (nonatomic, strong) BigoAd *ad; + +@property (nonatomic, assign) AdDidShowCallback showCallback; +@property (nonatomic, assign) AdDidClickCallback clickCallback; +@property (nonatomic, assign) AdDidDismissCallback dismissCallback; +@property (nonatomic, assign) AdDidErrorCallback adErrorCallback; + +//强持有AdLoader +@property (nonatomic, strong) BigoAdLoader *adLoader; +@property (nonatomic, assign) AdDidLoadCallback successCallback; +@property (nonatomic, assign) AdLoadFailCallBack failCallback; + +@end + +@interface BigoUnityBannerAdHandler : BigoUnityBaseAdHandler + +@end + + +@interface BigoUnityInterstitialAdHandler : BigoUnityBaseAdHandler + +@end + +@interface BigoUnityRewardedAdHandler : BigoUnityBaseAdHandler + +@property (nonatomic, assign) AdDidEarnRewardCallback earnCallback; + +@end + +@interface BigoUnitySplashAdHandler : BigoUnityBaseAdHandler + +@end + +@interface BigoUnityNativeAdHandler : BigoUnityBaseAdHandler + +@property (nonatomic, strong) UIView *nativeView; + +@end diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h.meta new file mode 100644 index 0000000..7c85306 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 0f898c08506444b2cae9b6fb32656a61 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm new file mode 100644 index 0000000..d6c46ad --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm @@ -0,0 +1,170 @@ + +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdHandlerManager.h" + +@implementation BigoUnityBaseAdHandler + +//广告异常 +- (void)onAd:(BigoAd *)ad error:(BigoAdError *)error { + +} + +//广告展示 +- (void)onAdImpression:(BigoAd *)ad { + if (self.showCallback) { + self.showCallback(self.unityAd); + } +} + +//广告点击 +- (void)onAdClicked:(BigoAd *)ad { + if (self.clickCallback) { + self.clickCallback(self.unityAd); + } +} + +//广告打开 +- (void)onAdOpened:(BigoAd *)ad { + +} + +//广告关闭 +- (void)onAdClosed:(BigoAd *)ad { + if (self.dismissCallback) { + self.dismissCallback(self.unityAd); + } + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:self.unityAd]; + [BigoUnityAdHandlerManager removeAdHandlerWithKey:unityAdKey]; +} + +- (void)dealloc { + NSLog(@"BigoAd-iOS-[BigoUnityBaseAdHandler]-[dealloc]"); +} + +@end + +@implementation BigoUnityBannerAdHandler + + +#pragma mark - BigoBannerAdLoaderDelegate +- (void)onBannerAdLoaded:(BigoBannerAd *)ad { + [ad setAdInteractionDelegate:self]; + self.ad = ad; + if (self.successCallback) { + self.successCallback(self.unityAd); + } +} + + +- (void)onBannerAdLoadError:(BigoAdError *)error { + if (self.failCallback) { + self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String); + } +} + +@end + +@implementation BigoUnityInterstitialAdHandler + +#pragma mark - BigoInterstitialAdLoaderDelegate +- (void)onInterstitialAdLoaded:(BigoInterstitialAd *)ad { + [ad setAdInteractionDelegate:self]; + self.ad = ad; + if (self.successCallback) { + self.successCallback(self.unityAd); + } +} + +- (void)onInterstitialAdLoadError:(BigoAdError *)error { + if (self.failCallback) { + self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String); + } +} + +@end + +@implementation BigoUnityRewardedAdHandler + +#pragma mark - BigoRewardVideoAdLoaderDelegate +- (void)onRewardVideoAdLoaded:(BigoRewardVideoAd *)ad { + [ad setRewardVideoAdInteractionDelegate:self]; + self.ad = ad; + if (self.successCallback) { + self.successCallback(self.unityAd); + } +} + + +- (void)onRewardVideoAdLoadError:(BigoAdError *)error { + if (self.failCallback) { + self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String); + } +} + +#pragma mark - BigoRewardVideoAdInteractionDelegate +//激励视频激励回调 +- (void)onAdRewarded:(BigoRewardVideoAd *)ad { + if (self.earnCallback) { + self.earnCallback(self.unityAd); + } +} +@end + +@implementation BigoUnitySplashAdHandler + +#pragma mark - BigoSplashAdLoaderDelegate +- (void)onSplashAdLoaded:(BigoSplashAd *)ad { + [ad setSplashAdInteractionDelegate:self]; + self.ad = ad; + if (self.successCallback) { + self.successCallback(self.unityAd); + } +} + + +- (void)onSplashAdLoadError:(BigoAdError *)error { + if (self.failCallback) { + self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String); + } +} + +#pragma mark - BigoSplashAdInteractionDelegate + +/** + * 广告可跳过回调,通常是由用户点击了右上角 SKIP 按钮所触发 + */ +- (void)onAdSkipped:(BigoAd *)ad { + if (self.dismissCallback) { + self.dismissCallback(self.unityAd); + } +} + +/** + * 广告倒计时结束回调 + */ +- (void)onAdFinished:(BigoAd *)ad { + if (self.dismissCallback) { + self.dismissCallback(self.unityAd); + } +} + +@end + +@implementation BigoUnityNativeAdHandler + +#pragma mark - BigoNativeAdLoaderDelegate +- (void)onNativeAdLoaded:(BigoNativeAd *)ad { + [ad setAdInteractionDelegate:self]; + self.ad = ad; + if (self.successCallback) { + self.successCallback(self.unityAd); + } +} + +- (void)onNativeAdLoadError:(BigoAdError *)error { + if (self.failCallback) { + self.failCallback(self.unityAd, error.errorCode, error.errorMsg.UTF8String); + } +} + + @end \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm.meta new file mode 100644 index 0000000..94c261f --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityBaseAdHandler.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 956299e395371425abfa788d6f80bad9 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs new file mode 100644 index 0000000..2dcae70 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs @@ -0,0 +1,44 @@ +#if UNITY_IOS +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using BigoAds.Scripts.Api; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + class BigoUnityConfig + { + private IntPtr _config; + internal void Init(BigoAdConfig config) + { + _config = BigoIOS_config(config.AppId); + BigoIOS_configSetInfo(_config, config.DebugLog, config.Age, config.Gender, config.ActivatedTime); + // set extra + foreach (KeyValuePair item in config.ExtraDictionary) + { + BigoIOS_configSetExtra(_config, item.Key, item.Value); + } + + } + + public IntPtr getInternalConfig() + { + return _config; + } + + //c# - > oc + [DllImport("__Internal")] + private static extern IntPtr BigoIOS_config(string appID); + + [DllImport(dllName: "__Internal")] + private static extern void BigoIOS_configSetInfo(IntPtr configPt, bool debugLog, int age, int gender, long activatedTime); + + [DllImport(dllName: "__Internal")] + private static extern void BigoIOS_configSetExtra(IntPtr configPt, string key, string extra); + + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs.meta new file mode 100644 index 0000000..7bcbb35 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd95f8f9cd401477c8b11db40da15a59 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm new file mode 100644 index 0000000..a48bef4 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm @@ -0,0 +1,30 @@ +#import +#import +#import "BigoUnityAdapterTools.h" + +extern "C" { + +BigoAdConfig* BigoIOS_config(const char* appID) { + NSString *appId = BigoIOS_transformNSStringForm(appID); + return [[BigoAdConfig alloc] initWithAppId:appId]; +} +BigoAdConfig* BigoIOS_GetConfig(void* __nullable config) { + BigoAdConfig *bigoConfig = config ? (__bridge BigoAdConfig*)config : nil; + return bigoConfig; +} + +void BigoIOS_configSetExtra(void* __nullable config, const char* key, const char* extra) { + BigoAdConfig *bigoConfig = BigoIOS_GetConfig(config); + NSString *keyString = BigoIOS_transformNSStringForm(key); + NSString *extraString = BigoIOS_transformNSStringForm(extra); + [bigoConfig addExtraWithKey:keyString extra:extraString]; +} + +void BigoIOS_configSetInfo(void* config, bool debugLog, int age, int gender, long activatedTime) { + BigoIOS_GetConfig(config).testMode = debugLog; + BigoIOS_GetConfig(config).age = age; + BigoIOS_GetConfig(config).gender = (BigoAdGender)gender; + BigoIOS_GetConfig(config).activatedTime = activatedTime; +} + +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm.meta new file mode 100644 index 0000000..f9b5fbb --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityConfig.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: d89226cd1e10648008bd21184cd89fe0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs new file mode 100644 index 0000000..0db3486 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs @@ -0,0 +1,105 @@ +#if UNITY_IOS +using AOT; +using UnityEngine; +using BigoAds.Scripts.Api.Constant; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + using System; + using BigoAds.Scripts.Api; + using BigoAds.Scripts.Common; + using BigoAds.Scripts.Platforms.iOS; + using System.Runtime.InteropServices; + + class BigoUnitySdk : ISDK + { + private BigoAdSdk.InitResultDelegate resultDelegate; + + public void Init(BigoAdConfig config, BigoAdSdk.InitResultDelegate initResultDelegate) + { + BigoUnityConfig unityConfig = new BigoUnityConfig(); + unityConfig.Init(config); + resultDelegate = initResultDelegate; + IntPtr ptr = (IntPtr)GCHandle.Alloc(this); + BigoIOS_initSDK(ptr, unityConfig.getInternalConfig(), cs_successCallback); + } + + public bool IsInitSuccess() + { + return BigoIOS_sdkInitializationState(); + } + + public string GetSDKVersion() + { + return BigoIOS_sdkVersion(); + } + + public string GetSDKVersionName() + { + return BigoIOS_sdkVersionName(); + } + + public void SetUserConsent(ConsentOptions option, bool consent) + { + if (option == ConsentOptions.GDPR) { + BigoIOS_setConsentGDPR(consent); + } else if (option == ConsentOptions.CCPA) { + BigoIOS_setConsentCCPA(consent); + } else if (option == ConsentOptions.LGPD) { + BigoIOS_setConsentLGPD(consent); + } else if (option == ConsentOptions.COPPA) { + BigoIOS_setConsentCOPPA(consent); + } + } + + public void AddExtraHost(string country, string host) + { + BigoIOS_addExtraHost(country, host); + } + + [DllImport("__Internal")] + static extern void BigoIOS_initSDK(IntPtr unitySDK, IntPtr config, SuccessCallbackDelegate successCallback); + + [DllImport("__Internal")] + static extern bool BigoIOS_sdkInitializationState(); + + [DllImport("__Internal")] + static extern string BigoIOS_sdkVersion(); + + [DllImport("__Internal")] + static extern string BigoIOS_sdkVersionName(); + + [DllImport("__Internal")] + static extern void BigoIOS_setConsentGDPR(bool consent); + + [DllImport("__Internal")] + static extern void BigoIOS_setConsentCCPA(bool consent); + + [DllImport("__Internal")] + static extern void BigoIOS_setConsentLGPD(bool consent); + + [DllImport("__Internal")] + static extern void BigoIOS_setConsentCOPPA(bool consent); + + [DllImport("__Internal")] + static extern void BigoIOS_addExtraHost(string country, string host); + + private delegate void SuccessCallbackDelegate(IntPtr unitySDK); + + [MonoPInvokeCallback(typeof(SuccessCallbackDelegate))] + private static void cs_successCallback(IntPtr unitySDK) + { + BigoUnitySdk sdk = GetUnitySdk(unitySDK); + sdk.resultDelegate(); + } + + private static BigoUnitySdk GetUnitySdk(IntPtr unitySdkPtr) + { + GCHandle handle = (GCHandle) unitySdkPtr; + BigoUnitySdk unitysdk = handle.Target as BigoUnitySdk; + return unitysdk; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs.meta new file mode 100644 index 0000000..b71493a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0119df06271854e9497b8cab7cc3ef1b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm new file mode 100644 index 0000000..e416a88 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm @@ -0,0 +1,58 @@ + +#import +#import "BigoUnityAdapterTools.h" + +char* MakeStringCopy(const char* string) { + if (string == NULL) return NULL; + char* res = (char*)malloc(strlen(string) + 1); + strcpy(res, string); + return res; +} + +extern "C" { + + typedef void (*BigoSDKInitSuccessCallBack)(void* unitySDK); + + void BigoIOS_initSDK(void* unitySDK, void* config, BigoSDKInitSuccessCallBack successCallback) { + BigoAdConfig *adConfig = config ? (__bridge BigoAdConfig*)config : nil; + [[BigoAdSdk sharedInstance] initializeSdkWithAdConfig:adConfig completion:^{ + successCallback(unitySDK); + }]; + } + + BOOL BigoIOS_sdkInitializationState() { + return [[BigoAdSdk sharedInstance] isInitialized]; + } + + const char* BigoIOS_sdkVersion() { + NSString *version = [[BigoAdSdk sharedInstance] getSDKVersion]; + return MakeStringCopy([version UTF8String]); + } + + const char* BigoIOS_sdkVersionName() { + NSString *versionName = [[BigoAdSdk sharedInstance] getSDKVersionName]; + return MakeStringCopy([versionName UTF8String]); + } + + void BigoIOS_setConsentGDPR(bool consent) { + [BigoAdSdk setUserConsentWithOption:BigoConsentOptionsGDPR consent:consent]; + } + + void BigoIOS_setConsentCCPA(bool consent) { + [BigoAdSdk setUserConsentWithOption:BigoConsentOptionsCCPA consent:consent]; + } + + void BigoIOS_setConsentCOPPA(bool consent) { + [BigoAdSdk setUserConsentWithOption:BigoConsentOptionsCOPPA consent:consent]; + } + + void BigoIOS_setConsentLGPD(bool consent) { + [BigoAdSdk setUserConsentWithOption:BigoConsentOptionsLGPD consent:consent]; + } + + void BigoIOS_addExtraHost(const char* country, const char* host) { + NSString *countryString = BigoIOS_transformNSStringForm(country); + NSString *hostString = BigoIOS_transformNSStringForm(host); + [BigoAdSdk addExtraHostWithCountry:countryString host:hostString]; + } +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm.meta new file mode 100644 index 0000000..69f7ba3 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnitySdk.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 2a926ae7c93f34a81ad8c0dca79dbe9f +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs new file mode 100644 index 0000000..584ffe2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs @@ -0,0 +1,22 @@ +#if UNITY_IOS +using System.Collections.Generic; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + public class BigoUnityTools + { + private static int mainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; + + internal static bool isMainThread() + { + return System.Threading.Thread.CurrentThread.ManagedThreadId == mainThreadID; + } + + internal static void LOGWithMessage(string className,string methodName,string msg) + { + Debug.Log($"BigoAds-iOS-[{className}]-[{methodName}]-{msg}"); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs.meta new file mode 100644 index 0000000..71bc64c --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/BigoUnityTools.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2171856213534228be217d8b18397ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial.meta new file mode 100644 index 0000000..80d9b73 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3d154fcfff71f4a50bbcb02fe73c8a63 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs new file mode 100644 index 0000000..eb1f860 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs @@ -0,0 +1,17 @@ +#if UNITY_IOS +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + + class BigoUnityinterstitialAd : BigoIOSBaseAd, IInterstitialAd + { + public void Load(string slotId, BigoInterstitialRequest request) + { + adType = 3; + LoadAdData(slotId,request); + } + } +} +#endif diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs.meta new file mode 100644 index 0000000..8887e68 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 439e9f1b2a72c4d52bbba125c8625121 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h new file mode 100644 index 0000000..a6152f3 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h @@ -0,0 +1,17 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load appOpen Ad + void BigoIOS_loadInterstitialAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback); + //show open ad + void BigoIOS_showInterstitialAd(UnityAd unityAd); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h.meta new file mode 100644 index 0000000..220ea50 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 09b930587afa743ca93ec5ae2d427b8a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm new file mode 100644 index 0000000..9ae2677 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm @@ -0,0 +1,67 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" + +extern "C"{ + +//load interstitial ad +void BigoIOS_loadInterstitialAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ) { + BigoIOS_dispatchSyncMainQueue(^{ + + BigoUnityInterstitialAdHandler *adHandler = [[BigoUnityInterstitialAdHandler alloc] init]; + BigoInterstitialAdRequest *request = [[BigoInterstitialAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)]; + NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson); + request.age = [requestDict[@"age"] intValue]; + request.gender = (BigoAdGender)[requestDict[@"gender"] intValue]; + request.activatedTime = [requestDict[@"activatedTime"] longLongValue]; + BigoInterstitialAdLoader *adLoader = [[BigoInterstitialAdLoader alloc] initWithInterstitialAdLoaderDelegate:adHandler]; + adLoader.ext = requestDict[@"extraInfo"]; + adHandler.adLoader = adLoader; + adHandler.unityAd = unityAd; + adHandler.showCallback = showCallback; + adHandler.clickCallback = clickCallback; + adHandler.dismissCallback = dismissCallback; + adHandler.adErrorCallback = adErrorCallback; + adHandler.successCallback = successCallback; + adHandler.failCallback = failCallback; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey]; + [adLoader loadAd:request]; + }); + +} + +BigoUnityInterstitialAdHandler* BigoIOS_getInterstitialAdHandler(UnityAd unityAd) { + if (!unityAd) return nil; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityInterstitialAdHandler *handler = (BigoUnityInterstitialAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + if (!handler || ![handler isMemberOfClass:[BigoUnityInterstitialAdHandler class]]) { + return nil; + } + return handler; +} + +void BigoIOS_showInterstitialAd(UnityAd unityAd) { + BigoUnityInterstitialAdHandler *handler = BigoIOS_getInterstitialAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + BigoInterstitialAd *ad = (BigoInterstitialAd *)handler.ad; + [ad show:vc]; + }); +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm.meta new file mode 100644 index 0000000..793758a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Interstitial/BigoUnityInterstitialAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 0ed50328a865a41e6a0c4c862dfc3a20 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native.meta new file mode 100644 index 0000000..0c6a97d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 91d71cd2823ff4f758ffc2f9340dd36a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs new file mode 100644 index 0000000..d4ee571 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs @@ -0,0 +1,84 @@ +#if UNITY_IOS +using System; +using System.Threading; +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Api.Constant; +using BigoAds.Scripts.Common; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + using System; + using BigoAds.Scripts.Api; + using BigoAds.Scripts.Common; + using BigoAds.Scripts.Platforms.iOS; + using System.Runtime.InteropServices; + public class BigoUnityNativeAd : BigoIOSBaseAd, INativeAd + { + public void Load(string slotId, BigoNativeRequest request) + { + adType = 1; + LoadAdData(slotId,request); + } + + private int CalculatePositionY(BigoPosition position, int nativeHeight) + { + int screenHeight = BigoIOS_getScreenHeight(); + float y = BigoIOS_getScreenSafeTop(); + if (position == BigoPosition.Middle) + { + y = (float)((screenHeight - nativeHeight) * 0.5); + } + else if (position == BigoPosition.Bottom) + { + y = (float)(screenHeight - nativeHeight - BigoIOS_getScreenSafeBottom()); + } + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position:{position},screenHeight:{screenHeight}-y:{y}"); + return (int)y; + } + + private int CalculateMiddleX(int nativeWidth) + { + int screenWidth = BigoIOS_getScreenWidth(); + int x = (int)((screenWidth - nativeWidth) * 0.5); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"screenWidth:{screenWidth}-x:{x}"); + return x; + } + + public void SetPosition(BigoPosition position) + { + int x = 0; + int y = CalculatePositionY(position, 300); //dafault 300 + BigoIOS_SetNativeAdPosition(unityAdPtr,x,y); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"position-{position}"); + } + //MARK: c# - oc + [DllImport("__Internal")] + static extern void BigoIOS_loadNativeAdData(IntPtr unityAdPtr, + string slotId, + string requestJson, + int x, + int y, + int width, + int height, + adDidLoadCallback_delegate successCallback, + adLoadFailCallBack_delegate failCallback, + adDidShowCallback_delegate showCallback, + adDidClickCallback_delegate clickCallback, + adDidDismissCallback_delegate dismissCallback + ); + + [DllImport("__Internal")] + static extern void BigoIOS_SetNativeAdPosition(IntPtr unityAdPtr, int x, int y); + + [DllImport("__Internal")] + static extern int BigoIOS_getScreenWidth(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenHeight(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenSafeTop(); + [DllImport("__Internal")] + static extern int BigoIOS_getScreenSafeBottom(); + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs.meta new file mode 100644 index 0000000..772f5dd --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2826ac57d309146a69194c7d0ba5764b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h new file mode 100644 index 0000000..1b150d9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h @@ -0,0 +1,21 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load Native ad + void BigoIOS_loadNativeAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ); + + void BigoIOS_SetNativeAdPosition(UnityAd unityAd,int x, int y); + void BigoIOS_showNativeAd(UnityAd unityAd); + void BigoIOS_removeNativeView(UnityAd unityAd); + +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h.meta new file mode 100644 index 0000000..fba7f26 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 7e57a1c9615984eaa8fcabfd30911db3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm new file mode 100644 index 0000000..3b58da9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm @@ -0,0 +1,102 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" +#import "BigoUnityNativeCustomView.h" + +extern "C"{ + +//load interstitial ad +void BigoIOS_loadNativeAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ) { + BigoIOS_dispatchSyncMainQueue(^{ + + UIViewController *vc = GetAppController().rootViewController; + BigoUnityNativeCustomView *nativeView = [[BigoUnityNativeCustomView alloc] initWithFrame:CGRectMake(0, 0, vc.view.frame.size.width, 300)]; + NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson); + BigoUnityNativeAdHandler *adHandler = [[BigoUnityNativeAdHandler alloc] init]; + BigoNativeAdRequest *request = [[BigoNativeAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)]; + request.age = [requestDict[@"age"] intValue]; + request.gender = (BigoAdGender)[requestDict[@"gender"] intValue]; + request.activatedTime = [requestDict[@"activatedTime"] longLongValue]; + BigoNativeAdLoader *adLoader = [[BigoNativeAdLoader alloc] initWithNativeAdLoaderDelegate:adHandler]; + adLoader.ext = requestDict[@"extraInfo"]; + adHandler.nativeView = nativeView; + adHandler.adLoader = adLoader; + adHandler.unityAd = unityAd; + adHandler.showCallback = showCallback; + adHandler.clickCallback = clickCallback; + adHandler.dismissCallback = dismissCallback; + adHandler.adErrorCallback = adErrorCallback; + adHandler.successCallback = successCallback; + adHandler.failCallback = failCallback; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey]; + [adLoader loadAd:request]; + }); + +} + +BigoUnityNativeAdHandler* BigoIOS_getNativeAdHandler(UnityAd unityAd) { + if (!unityAd) return nil; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityNativeAdHandler *handler = (BigoUnityNativeAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + if (!handler || ![handler isMemberOfClass:[BigoUnityNativeAdHandler class]]) { + return nil; + } + return handler; +} + +void BigoIOS_showNativeAd(UnityAd unityAd) { + BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd); + if (!handler) return; + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + BigoNativeAd *ad = (BigoNativeAd *)handler.ad; + //render + BigoUnityNativeCustomView *nativeView = (BigoUnityNativeCustomView *)handler.nativeView; + [ad registerViewForInteraction:nativeView mediaView:nativeView.mediaView adIconView:nativeView.adIconView adOptionsView:nativeView.adOptionsView clickableViews:nativeView.clickAbleViews]; + [nativeView refreshNativeView:ad]; + + CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; + CGRect frame = nativeView.frame; + frame.origin.y = screenHeight - frame.size.height; + nativeView.frame = frame; + + [vc.view addSubview:handler.nativeView]; + + }); +} + +void BigoIOS_SetNativeAdPosition(UnityAd unityAd,int x, int y) { + BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + CGRect frame = handler.nativeView.frame; + frame.origin.x = x; + frame.origin.y = y; + handler.nativeView.frame = frame; + }); +} + +void BigoIOS_removeNativeView(UnityAd unityAd) { + BigoUnityNativeAdHandler *handler = BigoIOS_getNativeAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + [handler.nativeView removeFromSuperview]; + }); +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm.meta new file mode 100644 index 0000000..1609c82 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 6e061b29b36eb4be7a56af7098092fb3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h new file mode 100644 index 0000000..ffbdb68 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h @@ -0,0 +1,17 @@ +#import +#import + +@interface BigoUnityNativeCustomView : UIView + +@property (nonatomic, strong) BigoAdMediaView *mediaView; +@property (nonatomic, strong) UIImageView *adIconView; +@property (nonatomic, strong) BigoAdOptionsView *adOptionsView; +@property (nonatomic, strong) UILabel *titleLabel; +@property (nonatomic, strong) UILabel *detailLabel; +@property (nonatomic, strong) UIButton *cta; + +- (NSArray *)clickAbleViews; + +- (void)refreshNativeView:(BigoNativeAd *)nativeAd; + +@end diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h.meta new file mode 100644 index 0000000..10dea82 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 1d74138abaf434fd38dce6301cac1107 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m new file mode 100644 index 0000000..87accfe --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m @@ -0,0 +1,72 @@ + +#import "BigoUnityNativeCustomView.h" + +@implementation BigoUnityNativeCustomView + +- (instancetype)initWithFrame:(CGRect)frame { + + if (self = [super initWithFrame:frame]) { + + self.backgroundColor = UIColor.whiteColor; + + self.mediaView = [BigoAdMediaView new]; + self.mediaView.bigoNativeAdViewTag = BigoNativeAdViewTagMedia; + self.mediaView.frame = CGRectMake(0, 50, CGRectGetWidth(self.bounds) , CGRectGetHeight(self.bounds) - 100); + + self.adIconView = [UIImageView new]; + self.adIconView.bigoNativeAdViewTag = BigoNativeAdViewTagIcon; + self.adIconView.frame = CGRectMake(0, 0, 50, 50); + + self.cta = [UIButton new]; + self.cta.bigoNativeAdViewTag = BigoNativeAdViewTagCallToAction; + self.cta.titleLabel.textColor = [UIColor colorWithRed:0 green:0 blue:255 alpha:255]; + self.cta.bigoNativeAdViewTag = BigoNativeAdViewTagCallToAction; + [self.cta setBackgroundColor:[UIColor grayColor]]; + + self.adOptionsView = [BigoAdOptionsView new]; + self.adOptionsView.bigoNativeAdViewTag = BigoNativeAdViewTagOption; + self.adOptionsView.frame = CGRectMake(CGRectGetWidth(self.bounds) - 20, 0, 20, 20); + + [self addSubview:self.mediaView]; + [self addSubview:self.adOptionsView]; + [self addSubview:self.adIconView]; + [self addSubview:self.cta]; + + self.titleLabel = UILabel.new; + self.titleLabel.textColor = UIColor.blackColor; + self.titleLabel.bigoNativeAdViewTag = BigoNativeAdViewTagTitle; + self.titleLabel.font = [UIFont systemFontOfSize:18]; + [self addSubview:self.titleLabel]; + + self.detailLabel = UILabel.new; + self.detailLabel.textColor = UIColor.lightGrayColor; + self.detailLabel.bigoNativeAdViewTag = BigoNativeAdViewTagDescription; + self.detailLabel.font = [UIFont systemFontOfSize:18]; + [self addSubview:self.detailLabel]; + + self.titleLabel.frame = CGRectMake(65, 5, CGRectGetWidth(self.bounds)-95, 20); + self.detailLabel.frame = CGRectMake(65, 30, CGRectGetWidth(self.bounds)-95, 20); + + self.cta.frame = CGRectMake(CGRectGetWidth(self.bounds)-100, 250, 100, 50); + + + } + return self; +} + +- (NSArray *)clickAbleViews { + return @[self.adIconView, self.titleLabel, self.detailLabel, self.cta]; +} + +- (void)refreshNativeView:(BigoNativeAd *)nativeAd { + self.titleLabel.text = nativeAd.title; + self.detailLabel.text = nativeAd.adDescription; + NSString *ctaTitle = nativeAd.callToAction.length > 0 ? nativeAd.callToAction : @"Install"; + [self.cta setTitle:ctaTitle forState:UIControlStateNormal]; + //设置按钮选择状态下的标题 + [self.cta setTitle:ctaTitle forState:UIControlStateSelected]; + //设置按钮高亮状态下的标题 + [self.cta setTitle:ctaTitle forState:UIControlStateHighlighted]; +} + +@end diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m.meta new file mode 100644 index 0000000..0fe8a60 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Native/BigoUnityNativeCustomView.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: d9e95ef6076f8408a98e195f9786007a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup.meta new file mode 100644 index 0000000..1be8634 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 24e19875a9807479e8e67ede8568a37d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs new file mode 100644 index 0000000..dcca3b9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs @@ -0,0 +1,17 @@ +#if UNITY_IOS +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + + class BigoUnitypopupAd : BigoIOSBaseAd, IPopupAd + { + public void Load(string slotId, BigoPopupRequest request) + { + adType = 6; + LoadAdData(slotId,request); + } + } +} +#endif diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs.meta new file mode 100644 index 0000000..b015e0d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6db3f7d6fb1a84a6eb484a3a8de4498a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h new file mode 100644 index 0000000..ed0d768 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h @@ -0,0 +1,17 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load appOpen Ad + void BigoIOS_loadPopupAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback); + //show open ad + void BigoIOS_showPopupAd(UnityAd unityAd); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h.meta new file mode 100644 index 0000000..d0d26d0 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 60f143a983fcf474f9c68938033d595e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm new file mode 100644 index 0000000..83ce26a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm @@ -0,0 +1,29 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" + +extern "C"{ + +//load popup ad +void BigoIOS_loadPopupAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ) { + + +} + +void BigoIOS_showPopupAd(UnityAd unityAd) { + +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm.meta new file mode 100644 index 0000000..3e2fce7 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Popup/BigoUnityPopupAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 1216b7bb5404a4e478138d98a4ceabc8 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded.meta new file mode 100644 index 0000000..83e47cd --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc24c03453ca84472831cbe13d0cd70d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs new file mode 100644 index 0000000..42bcde8 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs @@ -0,0 +1,63 @@ +#if UNITY_IOS +using System.Collections.Generic; +using AOT; +using UnityEngine; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + using System; + using BigoAds.Scripts.Api; + using BigoAds.Scripts.Common; + using BigoAds.Scripts.Platforms.iOS; + using System.Runtime.InteropServices; + class BigoUnityRewardedAd : BigoIOSBaseAd, IRewardedAd + { + public event Action OnUserEarnedReward; + + public void Load(string slotId, BigoRewardedRequest request) + { + adType = 4; + this.unityAdPtr = (IntPtr)GCHandle.Alloc (this); + IntPtr ptr = this.unityAdPtr; + + BigoIOS_loadRewardedAdData(ptr, + slotId, + request.ToJson(), + cs_adDidLoadCallback, + cs_adLoadFailCallBack, + cs_adDidShowCallback, + cs_adDidClickCallback, + cs_adDidDismissCallback, + cs_adDidErrorCallBack, + cs_adDidEarnRewardCallback); + LOGWithMessage(System.Reflection.MethodBase.GetCurrentMethod()?.Name,$"slotId:{slotId},request{request}"); + } + + // c-> oc + [DllImport("__Internal")] + static extern void BigoIOS_loadRewardedAdData(IntPtr unityAd, + string slotId, + string requestJson, + adDidLoadCallback_delegate successCallback, + adLoadFailCallBack_delegate failCallback, + adDidShowCallback_delegate showCallback, + adDidClickCallback_delegate clickCallback, + adDidDismissCallback_delegate dismissCallback, + adDidErrorCallback_delegate adErrorCallback, + adDidEarnRewardCallback_delegate earnCallback); + + private delegate void adDidEarnRewardCallback_delegate(IntPtr unityAdPtr); + + [MonoPInvokeCallback(typeof(adDidEarnRewardCallback_delegate))] + private static void cs_adDidEarnRewardCallback(IntPtr unityAdPtr) + { + BigoUnityRewardedAd unityAd = BigoIOSBaseAd.GetUnityAd(unityAdPtr) as BigoUnityRewardedAd; + if (unityAd == null) + { + return; + } + unityAd.OnUserEarnedReward?.Invoke(); + } + } +} +#endif diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs.meta new file mode 100644 index 0000000..cdab5d2 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63ac6f7f8298c4f2585c4847b19ae90d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h new file mode 100644 index 0000000..efe9083 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h @@ -0,0 +1,18 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load Rewarded Ad + void BigoIOS_loadRewardedAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback, + AdDidEarnRewardCallback earnCallback); + //show open ad + void BigoIOS_showRewardedAd(UnityAd unityAd); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h.meta new file mode 100644 index 0000000..1963bd9 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 780f30ce3796b4a89a92aa7e746d76bd +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm new file mode 100644 index 0000000..339e78b --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm @@ -0,0 +1,69 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" + +extern "C"{ + +//load rewarded ad +void BigoIOS_loadRewardedAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback, + AdDidEarnRewardCallback earnCallback + ) { + BigoIOS_dispatchSyncMainQueue(^{ + + BigoUnityRewardedAdHandler *adHandler = [[BigoUnityRewardedAdHandler alloc] init]; + BigoRewardVideoAdRequest *request = [[BigoRewardVideoAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)]; + NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson); + request.age = [requestDict[@"age"] intValue]; + request.gender = (BigoAdGender)[requestDict[@"gender"] intValue]; + request.activatedTime = [requestDict[@"activatedTime"] longLongValue]; + BigoRewardVideoAdLoader *adLoader = [[BigoRewardVideoAdLoader alloc] initWithRewardVideoAdLoaderDelegate:adHandler]; + adLoader.ext = requestDict[@"extraInfo"]; + adHandler.adLoader = adLoader; + adHandler.unityAd = unityAd; + adHandler.showCallback = showCallback; + adHandler.clickCallback = clickCallback; + adHandler.dismissCallback = dismissCallback; + adHandler.adErrorCallback = adErrorCallback; + adHandler.successCallback = successCallback; + adHandler.failCallback = failCallback; + adHandler.earnCallback = earnCallback; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey]; + [adLoader loadAd:request]; + }); + +} + +BigoUnityRewardedAdHandler* BigoIOS_getRewardedAdHandler(UnityAd unityAd) { + if (!unityAd) return nil; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnityRewardedAdHandler *handler = (BigoUnityRewardedAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + if (!handler || ![handler isMemberOfClass:[BigoUnityRewardedAdHandler class]]) { + return nil; + } + return handler; +} + +void BigoIOS_showRewardedAd(UnityAd unityAd) { + BigoUnityRewardedAdHandler *handler = BigoIOS_getRewardedAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + UIViewController *vc = GetAppController().rootViewController; + BigoRewardVideoAd *ad = (BigoRewardVideoAd *)handler.ad; + [ad show:vc]; + }); +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm.meta new file mode 100644 index 0000000..71a5f96 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Rewarded/BigoUnityRewardedAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: d8fabace3a5bc43d1909e6d2e3d11b76 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash.meta new file mode 100644 index 0000000..2dca882 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f81b17e4602f4d049f2f1679dd986df +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h new file mode 100644 index 0000000..0dd0477 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h @@ -0,0 +1,24 @@ +// +// BGSplashAdViewController.h +// demo +// +// Created by cai on 2022/5/23. +// + +#import +#import +#import "BigoUnityBaseAdHandler.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface BGSplashAdViewController : UIViewController + +@property (nonatomic, strong) UIViewController *rootVC; + +@property (nonatomic, strong) BigoSplashAd *ad; + +@property (nonatomic, weak) BigoUnitySplashAdHandler *adHandle; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h.meta new file mode 100644 index 0000000..6a06c0e --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: fb04cd43cee464aaca615d708992dd8c +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m new file mode 100644 index 0000000..2ab13ff --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m @@ -0,0 +1,71 @@ +// +// BGSplashAdViewController.m +// demo +// +// Created by cai on 2022/5/23. +// + +#import "BGSplashAdViewController.h" + +@interface BGSplashAdViewController () + +@end + +@implementation BGSplashAdViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.view.backgroundColor = [UIColor whiteColor]; + + [self.ad setSplashAdInteractionDelegate:self]; + [self.ad showInAdContainer:self.view]; +} + +- (void)dismissSplashController:(BigoAd *)ad { + [self.adHandle onAdClosed:ad]; + [[UIApplication sharedApplication].keyWindow setRootViewController:self.rootVC]; +} + +/** + * 广告可跳过回调,通常是由用户点击了右上角 SKIP 按钮所触发 + */ +- (void)onAdSkipped:(BigoAd *)ad { + [self dismissSplashController:ad]; +} + +/** + * 广告倒计时结束回调 + */ +- (void)onAdFinished:(BigoAd *)ad { + +} + +- (void)onAd:(BigoAd *)ad error:(BigoAdError *)error { + [self dismissSplashController:ad]; +} + +//广告展示 +- (void)onAdImpression:(BigoAd *)ad { + [self.adHandle onAdImpression:ad]; +} + +//广告点击 +- (void)onAdClicked:(BigoAd *)ad { + [self.adHandle onAdClicked:ad]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self.navigationController setNavigationBarHidden:YES animated:animated]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [self.navigationController setNavigationBarHidden:NO animated:animated]; +} + +- (BOOL)prefersStatusBarHidden { + return YES; +} + +@end diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m.meta new file mode 100644 index 0000000..21558bd --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BGSplashAdViewController.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 39e7476be840e4443b46b46741933efe +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs new file mode 100644 index 0000000..3d524cf --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs @@ -0,0 +1,17 @@ +#if UNITY_IOS +using BigoAds.Scripts.Api; +using BigoAds.Scripts.Common; + +namespace BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd +{ + + class BigoUnitySplashAd : BigoIOSBaseAd, ISplashAd + { + public void Load(string slotId, BigoSplashRequest request) + { + adType = 5; + LoadAdData(slotId,request); + } + } +} +#endif diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs.meta new file mode 100644 index 0000000..f7fd32d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 75707b903f9fd4fdaa3146b0ec0fad6b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h new file mode 100644 index 0000000..f2a616a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h @@ -0,0 +1,17 @@ +#import "BigoUnityBaseAdHandler.h" + +extern "C" { + + //load appOpen Ad + void BigoIOS_loadSplashAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback); + //show open ad + void BigoIOS_showSplashAd(UnityAd unityAd); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h.meta new file mode 100644 index 0000000..265c352 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: b558ab701b1ae4f74a9bf6908be239c4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm new file mode 100644 index 0000000..4024579 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm @@ -0,0 +1,71 @@ +#import +#import "UnityAppController.h" +#import "BigoUnityBaseAdHandler.h" +#import "BigoUnityAdapterTools.h" +#import "BigoUnityAdHandlerManager.h" +#import "BGSplashAdViewController.h" + +extern "C"{ + +//load splash ad +void BigoIOS_loadSplashAdData(UnityAd unityAd, + const char *slotId, + const char *requestJson, + AdDidLoadCallback successCallback, + AdLoadFailCallBack failCallback, + AdDidShowCallback showCallback, + AdDidClickCallback clickCallback, + AdDidDismissCallback dismissCallback, + AdDidErrorCallback adErrorCallback + ) { + BigoIOS_dispatchSyncMainQueue(^{ + + BigoUnitySplashAdHandler *adHandler = [[BigoUnitySplashAdHandler alloc] init]; + BigoSplashAdRequest *request = [[BigoSplashAdRequest alloc] initWithSlotId:BigoIOS_transformNSStringForm(slotId)]; + NSDictionary *requestDict = BigoIOS_requestJsonObjectFromJsonString(requestJson); + request.age = [requestDict[@"age"] intValue]; + request.gender = (BigoAdGender)[requestDict[@"gender"] intValue]; + request.activatedTime = [requestDict[@"activatedTime"] longLongValue]; + BigoSplashAdLoader *adLoader = [[BigoSplashAdLoader alloc] initWithSplashAdLoaderDelegate:adHandler]; + adLoader.ext = requestDict[@"extraInfo"]; + adHandler.adLoader = adLoader; + adHandler.unityAd = unityAd; + adHandler.showCallback = showCallback; + adHandler.clickCallback = clickCallback; + adHandler.dismissCallback = dismissCallback; + adHandler.adErrorCallback = adErrorCallback; + adHandler.successCallback = successCallback; + adHandler.failCallback = failCallback; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + [BigoUnityAdHandlerManager saveAdHandler:adHandler withKey:unityAdKey]; + [adLoader loadAd:request]; + }); + +} + +BigoUnitySplashAdHandler* BigoIOS_getSplashAdHandler(UnityAd unityAd) { + if (!unityAd) return nil; + NSString *unityAdKey = [BigoUnityAdHandlerManager createKeyUnityAd:unityAd]; + BigoUnitySplashAdHandler *handler = (BigoUnitySplashAdHandler*)[BigoUnityAdHandlerManager handlerWithKey:unityAdKey]; + if (!handler || ![handler isMemberOfClass:[BigoUnitySplashAdHandler class]]) { + return nil; + } + return handler; +} + +void BigoIOS_showSplashAd(UnityAd unityAd) { + BigoUnitySplashAdHandler *handler = BigoIOS_getSplashAdHandler(unityAd); + if (!handler) return; + + BigoIOS_dispatchSyncMainQueue(^{ + BGSplashAdViewController *vc = [BGSplashAdViewController new]; + BigoSplashAd *ad = (BigoSplashAd *)handler.ad; + vc.ad = ad; + vc.adHandle = handler; + vc.rootVC = [UIApplication sharedApplication].keyWindow.rootViewController; + [[UIApplication sharedApplication].keyWindow setRootViewController:vc]; + }); +} + +} + diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm.meta new file mode 100644 index 0000000..fad9286 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoAd/Splash/BigoUnitySplashAd.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 8235e7e5bc3aa4161911cbb121a01ed6 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h new file mode 100644 index 0000000..d78de0d --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h @@ -0,0 +1,6 @@ +extern "C" { + NSString* BigoIOS_transformNSStringForm(const char * string); + void BigoIOS_dispatchSyncMainQueue(void (^block)(void)); + NSDictionary* BigoIOS_jsonObjectFromJsonString(NSString *jsonString); + NSDictionary* BigoIOS_requestJsonObjectFromJsonString(const char * json); +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h.meta new file mode 100644 index 0000000..a39f59f --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: b79d02d93f49840b7ad17017bcb5f3fe +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm new file mode 100644 index 0000000..36c107a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm @@ -0,0 +1,43 @@ +#import + +extern "C" { +//字符串转化工具 +NSString* BigoIOS_transformNSStringForm(const char * string) +{ + if (!string) + { + string = ""; + } + return [NSString stringWithUTF8String:string]; +} + +void BigoIOS_dispatchSyncMainQueue(void (^block)(void)) { + if (!block) return; + if ([[NSThread currentThread] isMainThread]){ + block(); + return; + } + dispatch_sync(dispatch_get_main_queue(), ^{ block(); }); +} + +NSDictionary* BigoIOS_jsonObjectFromJsonString(NSString *jsonString) { + if (jsonString.length == 0) { + return [[NSDictionary alloc] init]; + } + NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; + if (error || ![obj isKindOfClass:[NSDictionary class]]) { + return [[NSDictionary alloc] init]; + } + return obj; +} + +NSDictionary* BigoIOS_requestJsonObjectFromJsonString(const char * json) { + NSString *string = BigoIOS_transformNSStringForm(json); + return BigoIOS_jsonObjectFromJsonString(string); +} + + + +} diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm.meta b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm.meta new file mode 100644 index 0000000..d1965c5 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/Adapter/BigoUnityAdapterTools.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 486cb19aab9734f3182b6ff6dc3d23b4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs b/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs new file mode 100644 index 0000000..8f03a0a --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs @@ -0,0 +1,46 @@ +#if UNITY_IOS +using BigoAds.Scripts.Common; +using BigoAds.Scripts.Platforms.iOS; +using BigoAds.Scripts.Platforms.iOS.Adapter.BigoAd; + +namespace BigoAds.Scripts.Platforms.iOS +{ + class IOSClientFactory : IClientFactory + { + + public ISDK BuildSDKClient() + { + return new BigoUnitySdk(); + } + + public IBannerAd BuildBannerAdClient() + { + return new BigoUnityBannerAd(); + } + + public INativeAd BuildNativeAdClient() + { + return new BigoUnityNativeAd(); + } + + public IInterstitialAd BuildInterstitialAdClient() + { + return new BigoUnityinterstitialAd(); + } + + public ISplashAd BuildSplashAdClient() + { + return new BigoUnitySplashAd(); + } + + public IRewardedAd BuildRewardedAdClient() + { + return new BigoUnityRewardedAd(); + } + public IPopupAd BuildPopupAdClient() + { + return new BigoUnitypopupAd(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs.meta b/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs.meta new file mode 100644 index 0000000..3c9b051 --- /dev/null +++ b/Assets/BigoAds/Scripts/Platforms/iOS/IOSClientFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19b9b3ee98a034640a2530047c2a4d7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoSDK.meta b/Assets/BigoSDK.meta new file mode 100644 index 0000000..ba780c9 --- /dev/null +++ b/Assets/BigoSDK.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2154e3fcfcb7f460db1c13464bb1355f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoSDK/Editor.meta b/Assets/BigoSDK/Editor.meta new file mode 100644 index 0000000..39c97da --- /dev/null +++ b/Assets/BigoSDK/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ec31bab3b8560467a9ec89b7934596bd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BigoSDK/Editor/Dependencies.xml b/Assets/BigoSDK/Editor/Dependencies.xml new file mode 100644 index 0000000..4627456 --- /dev/null +++ b/Assets/BigoSDK/Editor/Dependencies.xml @@ -0,0 +1,13 @@ + + + + + + + + + https://repo1.maven.org/maven2/ + + + + diff --git a/Assets/BigoSDK/Editor/Dependencies.xml.meta b/Assets/BigoSDK/Editor/Dependencies.xml.meta new file mode 100644 index 0000000..f60ea08 --- /dev/null +++ b/Assets/BigoSDK/Editor/Dependencies.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1b669f66367be4697b7819f165f9842b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/AndroidPlatformTool.cs b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/AndroidPlatformTool.cs index 1285bfe..7a9249b 100644 --- a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/AndroidPlatformTool.cs +++ b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/AndroidPlatformTool.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace BigoAds.Scripts.Platforms.Android { - internal static class AndroidPlatformTool + internal static class KwaiAndroidPlatformTool { public const string ClassPackage = "com.kwai.network.sdk"; private const string CurrentActivityMethod = "currentActivity"; diff --git a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiAdSDKInit.cs b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiAdSDKInit.cs index deddfa1..98a3f23 100644 --- a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiAdSDKInit.cs +++ b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiAdSDKInit.cs @@ -10,9 +10,9 @@ 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 const string SDKClientClassName = KwaiAndroidPlatformTool.ClassPackage + ".KwaiAdSDK"; + private const string SDKClientBuilder = KwaiAndroidPlatformTool.ClassPackage + ".api.SdkConfig$Builder"; + private const string SDKClientInitCallback = KwaiAndroidPlatformTool.ClassPackage + ".api.KwaiInitCallback"; private static AndroidJavaClass kwaiAdSdkClass; private static KwaiAdConfig config; @@ -121,7 +121,7 @@ namespace KwaiAds.Scripts.Platforms.Android sdkConfigBuilder.Call("debug", config.DebugLog); } - AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity(); + AndroidJavaObject currentActivity = KwaiAndroidPlatformTool.GetGameActivity(); if (currentActivity != null) { AndroidJavaObject contextObject = currentActivity.Call("getApplicationContext"); diff --git a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiInterstitialAdController.cs b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiInterstitialAdController.cs index 612e521..55a033a 100644 --- a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiInterstitialAdController.cs +++ b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiInterstitialAdController.cs @@ -9,10 +9,10 @@ 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 InterstitialAdConfigBuilderClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.interstitial.data.KwaiInterstitialAdConfig$Builder"; + private const string KwaiInterstitialAdListenerClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.interstitial.interf.IKwaiInterstitialAdListener"; + private const string AdLoadListenerClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.common.interf.AdLoadListener"; + private const string KwaiInterstitialAdRequestClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.interstitial.data.KwaiInterstitialAdRequest"; private const string KwaiAdLoaderManagerMethodName = "getKwaiAdLoaderManager"; private const string WithKwaiInterstitialAdListenerMethodName = "withKwaiInterstitialAdListener"; private const string BuildInterstitialAdLoaderMethodName = "buildInterstitialAdLoader"; @@ -66,7 +66,7 @@ namespace KwaiAds.Scripts.Platforms.Android { if (IsReady()) { - AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity(); + AndroidJavaObject currentActivity = KwaiAndroidPlatformTool.GetGameActivity(); if (currentActivity == null) { Debug.Log($"{TAG}: Current Game Activity not found."); diff --git a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiRewardAdController.cs b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiRewardAdController.cs index 69d2c9e..f766ef1 100644 --- a/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiRewardAdController.cs +++ b/Assets/rd3/AdsSDK/KwaiAds/Scripts/Platform/Android/KwaiRewardAdController.cs @@ -9,10 +9,10 @@ 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 RewardedAdConfigBuilderClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.reward.data.KwaiRewardAdConfig$Builder"; + private const string KwaiRewardAdListenerClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.reward.interf.IKwaiRewardAdListener"; + private const string AdLoadListenerClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.common.interf.AdLoadListener"; + private const string KwaiRewardAdRequestClassName = KwaiAndroidPlatformTool.ClassPackage + ".loader.business.reward.data.KwaiRewardAdRequest"; private const string KwaiAdLoaderManagerMethodName = "getKwaiAdLoaderManager"; private const string WithKwaiRewardAdListenerMethodName = "withKwaiRewardAdListener"; private const string BuildRewardAdLoaderMethodName = "buildRewardAdLoader"; @@ -66,7 +66,7 @@ namespace KwaiAds.Scripts.Platforms.Android { if (IsReady()) { - AndroidJavaObject currentActivity = AndroidPlatformTool.GetGameActivity(); + AndroidJavaObject currentActivity = KwaiAndroidPlatformTool.GetGameActivity(); if (currentActivity == null) { Debug.Log($"{TAG}: Current Game Activity not found.");