init commit

feature/ball_only_mintegral 1.0.0
胡宇飞 2023-12-26 11:47:44 +08:00
commit 5ab0b8da41
627 changed files with 46921 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Mac auto-generated system files
*.DS_Store*

8
Amazon.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 474c0b17d00314c9d8b205e3c753661e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

17
Amazon/Amazon.asmdef Normal file
View File

@ -0,0 +1,17 @@
{
"name": "Amazon",
"rootNamespace": "",
"references": [
"MaxSdk",
"MaxSdk.Scripts"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6beff6c8cf8014e6084bc2f82cc4cef0
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Amazon/Plugins.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c161f427aca604d4d81f018fddaae5d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Amazon/Plugins/iOS.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fd97fc7641615462abc63e027208b9a2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = 'Amazon-SDK-Plugin'
s.version = '5.12.1'
s.summary = 'Unity wrapper for APS iOS SDK'
s.homepage = 'https://github.com/amazon/amazon-unity-sdk'
s.license = { :type => 'Amazon', :file => 'APS_IOS_SDK-4.4.1/LICENSE.txt' }
s.author = { 'Amazon' => 'aps-github@amazon.com' }
s.ios.deployment_target = '12.5'
s.source = { :tag => "v#{s.version}" }
s.source_files = '*.{h,m,mm}'
s.dependency 'AmazonPublisherServicesSDK'
s.pod_target_xcconfig = {
'OTHER_CPLUSPLUSFLAGS' => '-fcxx-modules',
}
end

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ce7a667caa6f64752b219fe8edd61617
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,283 @@
#import "AmazonManager.h"
#import "AmazonUnityCallback.h"
#import "DTBBannerDelegate.h"
#import "DTBInterstitialDelegate.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Helpers
// Converts C style string to NSString
#define GetStringParam(_x_) ((_x_) != NULL ? [NSString stringWithUTF8String:_x_] : [NSString stringWithUTF8String:""])
#define GetNullableStringParam(_x_) ((_x_) != NULL ? [NSString stringWithUTF8String:_x_] : nil)
static char* amazonStringCopy(NSString* input)
{
const char* string = [input UTF8String];
return string ? strdup(string) : NULL;
}
void _amazonInitialize(const char* appKey)
{
[[AmazonManager sharedManager] initialize:GetStringParam(appKey)];
}
bool _amazonIsInitialized(){
return [[AmazonManager sharedManager] isInitialized];
}
void _amazonSetUseGeoLocation(bool flag){
[[AmazonManager sharedManager] setUseGeoLocation:flag];
}
bool _amazonGetUseGeoLocation(){
return [[AmazonManager sharedManager] getUseGeoLocation];
}
void _amazonSetLogLevel(int logLevel){
[[AmazonManager sharedManager] setLogLevel:logLevel];
}
bool _amazonGetLogLevel(){
return [[AmazonManager sharedManager] getLogLevel];
}
void _amazonSetTestMode(bool flag){
[[AmazonManager sharedManager] setTestMode:flag];
}
bool _amazonIsTestModeEnabled(){
return [[AmazonManager sharedManager] isTestModeEnabled];
}
DTBAdSize* _createBannerAdSize(int width, int height, const char* uuid){
return [[AmazonManager sharedManager] createBannerAdSize:width height:height uuid:GetStringParam(uuid)];
}
DTBAdSize* _createVideoAdSize(int width, int height, const char* uuid){
return [[AmazonManager sharedManager] createVideoAdSize:width height:height uuid:GetStringParam(uuid)];
}
DTBAdSize* _createInterstitialAdSize(const char* uuid){
return [[AmazonManager sharedManager] createInterstitialAdSize:GetStringParam(uuid)];
}
DTBAdLoader* _createAdLoader(){
return [[AmazonManager sharedManager]createAdLoader];
}
void _setSizes(DTBAdLoader* adLoader, DTBAdSize* size){
[[AmazonManager sharedManager]setSizes:adLoader size:size];
}
void _loadAd(DTBAdLoader* adLoader, AmazonUnityCallback* callback){
[[AmazonManager sharedManager]loadAd:adLoader callback:callback];
}
void _loadSmartBanner(DTBAdLoader* adLoader, AmazonUnityCallback* callback){
[[AmazonManager sharedManager]loadSmartBanner:adLoader callback:callback];
}
void _amazonSetMRAIDPolicy(int policy){
[[AmazonManager sharedManager] setMRAIDPolicy:(DTBMRAIDPolicy)policy];
}
int _amazonGetMRAIDPolicy(){
return [[AmazonManager sharedManager] getMRAIDPolicy];
}
void _amazonSetMRAIDSupportedVersions(const char* newVersion){
[[AmazonManager sharedManager] setMRAIDSupportedVersions:GetStringParam(newVersion)];
}
void _amazonSetListeners(DTBAdCallbackClientRef* ptr, AmazonUnityCallback* callbackPtr, SuccessResponse onSuccessCallback, ErrorResponse onErrorCallback) {
[callbackPtr setListeners:ptr success:onSuccessCallback errorCallback:onErrorCallback];
}
void _amazonSetListenersWithInfo(DTBAdCallbackClientRef* ptr, AmazonUnityCallback* callbackPtr, SuccessResponse onSuccessCallback, ErrorResponseWithInfo onErrorCallbackWithInfo) {
[callbackPtr setListenersWithInfo:ptr success:onSuccessCallback errorCallbackWithInfo:onErrorCallbackWithInfo];
}
void _setBannerDelegate(DTBCallbackBannerRef* ptr, DTBBannerDelegate* callbackPtr, DTBAdDidLoadType adLoad, DTBAdFailedToLoadType adFailLoad, DTBBannerWillLeaveApplicationType leaveApp, DTBImpressionFiredType impFired) {
[callbackPtr setDelegate:ptr adLoad:adLoad adFailLoad:adFailLoad leaveApp:leaveApp impFired:impFired];
}
void _setInterstitialDelegate(DTBCallbackInterstitialRef* ptr, DTBInterstitialDelegate* callbackPtr, DTBInterstitialDidLoadType adLoad, DTBDidFailToLoadAdWithErrorCodeType adFailLoad, DTBInterstitialWillLeaveApplicationType leaveApp, DTBInterstitialImpressionFiredType impFired, DTBInterstitialDidPresentScreenType didOpen, DTBInterstitialDidDismissScreenType didDismiss) {
[callbackPtr setDelegate:ptr adLoad:adLoad adFailLoad:adFailLoad leaveApp:leaveApp impFired:impFired didOpen:didOpen didDismiss:didDismiss];
}
AmazonUnityCallback* _createCallback() {
return [[AmazonManager sharedManager] createCallback];
}
DTBBannerDelegate* _createBannerDelegate() {
return [[AmazonManager sharedManager] createBannerDelegate];
}
DTBInterstitialDelegate* _createInterstitialDelegate() {
return [[AmazonManager sharedManager] createInterstitialDelegate];
}
DTBFetchManager* _getFetchManager(int autoRefreshID, bool isSmartBanner){
return [[AmazonManager sharedManager] getFetchManager:autoRefreshID isSmartBanner:isSmartBanner];
}
void _fetchManagerPop(DTBFetchManager* fetchManager){
[[AmazonManager sharedManager] fetchManagerPop:fetchManager];
}
void _putCustomTarget(DTBAdLoader* adLoader, const char* key, const char* value){
[[AmazonManager sharedManager] putCustomTarget:adLoader key:GetStringParam(key) value:GetStringParam(value)];
}
void _createFetchManager(DTBAdLoader* adLoader, bool isSmartBanner){
[[AmazonManager sharedManager] createFetchManager:adLoader isSmartBanner:isSmartBanner];
}
void _startFetchManager(DTBFetchManager* fetchManager){
[[AmazonManager sharedManager] startFetchManager:fetchManager];
}
void _stopFetchManager(DTBFetchManager* fetchManager){
[[AmazonManager sharedManager] stopFetchManager:fetchManager];
}
bool _isEmptyFetchManager(DTBFetchManager* fetchManager){
return [[AmazonManager sharedManager] isEmptyFetchManager:fetchManager];
}
void _destroyFetchManager(int autoRefreshID){
[[AmazonManager sharedManager] destroyFetchManager:autoRefreshID];
}
void _setSlotGroup(DTBAdLoader* adLoader, const char* slotGroupName){
[[AmazonManager sharedManager] setSlotGroup:adLoader slotGtoupName:GetStringParam(slotGroupName)];
}
DTBSlotGroup* _createSlotGroup(const char* slotGroupName){
return [[AmazonManager sharedManager] createSlotGroup:GetStringParam(slotGroupName)];
}
void _addSlot(DTBSlotGroup* slot, DTBAdSize* size){
[[AmazonManager sharedManager] addSlot:slot size:size];
}
void _addSlotGroup(DTBSlotGroup* slot){
[[AmazonManager sharedManager] addSlotGroup:slot];
}
const char* _fetchMoPubKeywords(DTBAdResponse* response){
return amazonStringCopy([[AmazonManager sharedManager] fetchMoPubKeywords:response]);
}
const char* _fetchAmznSlots(DTBAdResponse* response){
return amazonStringCopy([[AmazonManager sharedManager] fetchAmznSlots:response]);
}
int _fetchAdHeight(DTBAdResponse* response){
return [[AmazonManager sharedManager] fetchAdHeight:response];
}
int _fetchAdWidth(DTBAdResponse* response){
return [[AmazonManager sharedManager] fetchAdWidth:response];
}
const char* _fetchMediationHints(DTBAdResponse* response, bool isSmartBanner){
NSString* str = [[AmazonManager sharedManager] fetchMediationHints:response isSmart:isSmartBanner];
return amazonStringCopy(str);
}
void _setCMPFlavor (int cFlavor){
[[AmazonManager sharedManager] setCMPFlavor:(DTBCMPFlavor)cFlavor];
}
void _setConsentStatus (int consentStatus){
[[AmazonManager sharedManager] setConsentStatus:(DTBConsentStatus)consentStatus];
}
NSMutableArray* _createArray(){
return [[AmazonManager sharedManager] createArray];
}
void _addToArray (NSMutableArray* dictionary, int item) {
[[AmazonManager sharedManager] addToArray:dictionary item:item];
}
void _setVendorList(NSMutableArray* dictionary){
[[AmazonManager sharedManager] setVendorList:dictionary];
}
void _setAutoRefreshNoArgs(DTBAdLoader* adLoader){
[[AmazonManager sharedManager] setAutoRefresh:adLoader];
}
void _setAutoRefresh(DTBAdLoader* adLoader, int secs){
[[AmazonManager sharedManager] setAutoRefresh:adLoader secs:secs];
}
void _pauseAutoRefresh(DTBAdLoader* adLoader){
[[AmazonManager sharedManager] pauseAutorefresh:adLoader];
}
void _stopAutoRefresh(DTBAdLoader* adLoader){
[[AmazonManager sharedManager] stopAutoRefresh:adLoader];
}
void _resumeAutoRefresh(DTBAdLoader* adLoader){
[[AmazonManager sharedManager] resumeAutoRefresh:adLoader];
}
void _setAPSPublisherExtendedIdFeatureEnabled(bool isEnabled) {
[[AmazonManager sharedManager] setAPSPublisherExtendedIdFeatureEnabled:isEnabled];
}
void _addCustomAttribute(const char *withKey, const void *value) {
[[AmazonManager sharedManager] addCustomAttribute:GetStringParam(withKey) value:GetStringParam(value)];
}
void _removeCustomAttribute(const char* forKey) {
[[AmazonManager sharedManager] removeCustomAttribute:GetStringParam(forKey)];
}
void _setAdNetworkInfo(int adNetworkId) {
DTBAdNetworkInfo *dtbAdNetworkInfo = [[DTBAdNetworkInfo alloc]initWithNetworkName:(DTBAdNetwork)adNetworkId];
[[AmazonManager sharedManager] setAdNetworkInfo:dtbAdNetworkInfo];
}
void _setLocalExtras(const char *adUnitId, NSDictionary *localExtras) {
[DTBAds setLocalExtras:GetStringParam(adUnitId) localExtras:localExtras];
}
DTBAdBannerDispatcher* _createAdView(int width, int height, DTBBannerDelegate* delegate) {
CGRect rect = CGRectMake(0.0f, 0.0f, (CGFloat)width, (CGFloat)height);
return [[DTBAdBannerDispatcher alloc] initWithAdFrame:rect delegate:delegate];
}
DTBAdInterstitialDispatcher* _createAdInterstitial(DTBInterstitialDelegate* delegate) {
return [[DTBAdInterstitialDispatcher alloc] initWithDelegate:delegate];
}
void _fetchBannerAd(DTBAdBannerDispatcher* dispatcher, DTBAdResponse* adResponse) {
[dispatcher fetchBannerAdWithParameters:[adResponse mediationHints]];
}
void _fetchInterstitialAd(DTBAdInterstitialDispatcher* dispatcher, DTBAdResponse* adResponse) {
[dispatcher fetchAdWithParameters:[adResponse mediationHints]];
}
void _showInterstitial(DTBAdInterstitialDispatcher* dispatcher) {
[[AmazonManager sharedManager] showInterstitialAd:dispatcher];
}
NSDictionary* _getMediationHintsDict(DTBAdResponse* response, bool isSmartBanner){
return [[AmazonManager sharedManager] getMediationHintsDict:response isSmart:isSmartBanner];
}
void _setRefreshFlag(DTBAdLoader* adLoader, bool flag) {
[adLoader setRefreshFlag:flag];
}
DTBAdLoader* _getAdLoaderFromResponse(DTBAdResponse* adResponse) {
return [adResponse getAdLoader];
}
DTBAdLoader* _getAdLoaderFromAdError(DTBAdErrorInfo* errorInfo) {
return [errorInfo getAdLoader];
}

View File

@ -0,0 +1,104 @@
fileFormatVersion: 2
guid: bc75c2542fbb6469798f0dc4baf0100e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <DTBiOSSDK/DTBiOSSDK.h>
#import <DTBiOSSDK/DTBAdCallback.h>
#import <DTBiOSSDK/DTBAdBannerDispatcher.h>
#import <DTBiOSSDK/DTBAdInterstitialDispatcher.h>
#import "AmazonUnityCallback.h"
#import "DTBBannerDelegate.h"
#import "DTBInterstitialDelegate.h"
@interface AmazonManager: NSObject { }
+ (AmazonManager*)sharedManager;
- (void)initialize:(NSString*)keywords;
- (BOOL)isInitialized;
- (void)setUseGeoLocation:(bool)flag;
- (BOOL)getUseGeoLocation;
- (void)setLogLevel:(int)logLevel;
- (int)getLogLevel;
- (void)setTestMode:(bool)flag;
- (BOOL)isTestModeEnabled;
- (DTBAdSize*)createBannerAdSize:(int)width height:(int)height uuid:(NSString*)uuid;
- (DTBAdSize*)createVideoAdSize:(int)width height:(int)height uuid:(NSString*)uuid;
- (DTBAdSize*)createInterstitialAdSize:(NSString*)uuid;
- (DTBAdLoader*)createAdLoader;
- (void)setSizes:(DTBAdLoader*)adLoader size:(DTBAdSize*)size;
- (void)loadAd:(DTBAdLoader*)adLoader callback:(AmazonUnityCallback*)callback;
- (void)loadSmartBanner:(DTBAdLoader*)adLoader callback:(AmazonUnityCallback*)callback;
- (void)setMRAIDPolicy:(DTBMRAIDPolicy)policy;
- (int)getMRAIDPolicy;
- (void)setMRAIDSupportedVersions:(NSArray<NSString *> *)versions;
- (NSString*)jsonFromDict:(NSDictionary *)dict;
- (AmazonUnityCallback*)createCallback;
- (DTBBannerDelegate*)createBannerDelegate;
- (DTBInterstitialDelegate*)createInterstitialDelegate;
- (void)createFetchManager:(DTBAdLoader*)adLoader isSmartBanner:(BOOL)isSmartBanner;
- (DTBFetchManager*)getFetchManager:(int)slotType isSmartBanner:(BOOL)isSmartBanner;
-(void)fetchManagerPop:(DTBFetchManager*)fetchManager;
-(void)putCustomTarget:(DTBAdLoader*)adLoader key:(NSString*)key value:(NSString*)value;
-(void)startFetchManager:(DTBFetchManager*)fetchManager;
-(void)stopFetchManager:(DTBFetchManager*)fetchManager;
-(BOOL)isEmptyFetchManager:(DTBFetchManager*)fetchManager;
-(void)destroyFetchManager:(int)slotType;
-(void)setSlotGroup:(DTBAdLoader*)adLoader slotGtoupName:(NSString*)slotGtoupName;
-(DTBSlotGroup*)createSlotGroup:(NSString*)slotGroupName;
-(void)addSlot:(DTBSlotGroup*)slot size:(DTBAdSize*)size;
-(void)addSlotGroup:(DTBSlotGroup*)group;
-(NSString*)fetchMoPubKeywords:(DTBAdResponse*)response;
-(NSString*)fetchAmznSlots:(DTBAdResponse*)response;
-(int)fetchAdWidth:(DTBAdResponse*)response;
-(int)fetchAdHeight:(DTBAdResponse*)response;
-(NSString*)fetchMediationHints:(DTBAdResponse*)response isSmart:(BOOL)isSmart;
-(void)setCMPFlavor:(DTBCMPFlavor)cFlavor;
-(void)setConsentStatus:(DTBConsentStatus)consentStatus;
-(NSMutableArray*)createArray;
-(void)addToArray:(NSMutableArray*)dictionary item:(int)item;
-(void)setVendorList:(NSMutableArray*)dictionary;
-(void)setAutoRefresh:(DTBAdLoader*)adLoader;
-(void)setAutoRefresh:(DTBAdLoader*)adLoader secs:(int)secs;
-(void)pauseAutorefresh:(DTBAdLoader*)adLoader;
-(void)stopAutoRefresh:(DTBAdLoader*)adLoader;
-(void)resumeAutoRefresh:(DTBAdLoader*)adLoader;
-(void)setAPSPublisherExtendedIdFeatureEnabled:(BOOL)isEnabled;
-(void)addCustomAttribute:(NSString *)withKey value:(id)value;
-(void)removeCustomAttribute:(NSString *)forKey;
-(void)setAdNetworkInfo:(DTBAdNetworkInfo *)dtbAdNetworkInfo;
-(void)setLocalExtras:(NSString *)adUnitId localExtras:(NSDictionary *)localExtras;
-(NSDictionary *)getMediationHintsDict:(DTBAdResponse*)response isSmart:(BOOL)isSmart;
-(void)showInterstitialAd:(DTBAdInterstitialDispatcher*)dispatcher;
@end

View File

@ -0,0 +1,89 @@
fileFormatVersion: 2
guid: 9d0a8448aa0c147e8a0225de1609f269
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,295 @@
#import "AmazonManager.h"
@implementation AmazonManager
#pragma mark NSObject
+ (AmazonManager*)sharedManager
{
static AmazonManager* sharedManager = nil;
if (!sharedManager)
sharedManager = [[AmazonManager alloc] init];
return sharedManager;
}
- (void)initialize:(NSString*)keywords
{
[[DTBAds sharedInstance] setAppKey: keywords];
}
- (BOOL)isInitialized
{
return [[DTBAds sharedInstance] isReady];
}
- (void)setUseGeoLocation:(bool)flag
{
[[DTBAds sharedInstance] setUseGeoLocation:flag];
}
- (BOOL)getUseGeoLocation
{
return [[DTBAds sharedInstance] useGeoLocation];
}
- (void)setLogLevel:(int)logLevel
{
DTBLogLevel level = (DTBLogLevel) logLevel;
[[DTBAds sharedInstance] setLogLevel:level];
}
- (int)getLogLevel
{
return 0;
}
- (void)setTestMode:(bool)flag
{
[[DTBAds sharedInstance] setTestMode:flag];
}
- (BOOL)isTestModeEnabled
{
return [[DTBAds sharedInstance] testMode];
}
- (DTBAdSize*)createBannerAdSize:(int)width height:(int)height uuid:(NSString*)uuid{
return [[DTBAdSize alloc] initBannerAdSizeWithWidth:width height:height andSlotUUID:uuid];
}
- (DTBAdSize*)createVideoAdSize:(int)width height:(int)height uuid:(NSString*)uuid{
return [[DTBAdSize alloc] initVideoAdSizeWithPlayerWidth:width height: height andSlotUUID: uuid];;
}
- (DTBAdSize*)createInterstitialAdSize:(NSString*)uuid{
return [[DTBAdSize alloc] initInterstitialAdSizeWithSlotUUID:uuid];
}
- (DTBAdLoader*)createAdLoader{
return [DTBAdLoader new];
}
- (void)setSizes:(DTBAdLoader*)adLoader size:(DTBAdSize*)size{
[adLoader setSizes:size, nil];
}
- (void)loadAd:(DTBAdLoader*)adLoader callback:(AmazonUnityCallback*)callback{
[adLoader loadAd:callback];
}
- (void)loadSmartBanner:(DTBAdLoader*)adLoader callback:(AmazonUnityCallback*)callback{
[adLoader loadSmartBanner:callback];
}
- (void)setMRAIDPolicy:(DTBMRAIDPolicy)policy
{
[DTBAds sharedInstance].mraidPolicy = policy;
}
- (int) getMRAIDPolicy{
return [DTBAds sharedInstance].mraidPolicy;
}
- (void)setMRAIDSupportedVersions:(NSString* _Nullable)versions
{
[DTBAds sharedInstance].mraidCustomVersions = nil;
}
- (NSString *)jsonFromDict:(NSDictionary *)dict {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:0
error:&error];
if (!jsonData) {
NSLog(@"Error converting JSON from VCS response dict: %@", error);
return @"";
} else {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
- (AmazonUnityCallback*)createCallback{
AmazonUnityCallback* newCallback = [[AmazonUnityCallback alloc] init];
return newCallback;
}
- (DTBBannerDelegate*)createBannerDelegate{
return [[DTBBannerDelegate alloc] init];
}
- (DTBInterstitialDelegate*)createInterstitialDelegate{
return [[DTBInterstitialDelegate alloc] init];
}
- (void)createFetchManager:(DTBAdLoader*)adLoader isSmartBanner:(BOOL)isSmartBanner{
NSError *error = [DTBFetchFactory.sharedInstance createFetchManagerForLoader:adLoader isSmartBanner:isSmartBanner];
if(error == nil){
NSLog(@"FetchManager created");
} else {
NSLog(@"failed with error = %@", [error localizedDescription]);
}
}
- (DTBFetchManager*)getFetchManager:(int)slotType isSmartBanner:(BOOL)isSmartBanner{
if( !isSmartBanner ){
return [[DTBFetchFactory sharedInstance] fetchManagerBySlotType:(DTBSlotType)slotType];
}else {
return [[DTBFetchFactory sharedInstance] fetchManagerBySlotType:SLOT_SMART];
}
}
-(void)fetchManagerPop:(DTBFetchManager*)fetchManager{
[fetchManager pop];
}
-(void)putCustomTarget:(DTBAdLoader*)adLoader key:(NSString*)key value:(NSString*)value{
[adLoader putCustomTarget:value withKey:key];
}
-(void)startFetchManager:(DTBFetchManager*)fetchManager{
[fetchManager start];
}
-(void)stopFetchManager:(DTBFetchManager*)fetchManager{
[fetchManager stop];
}
-(BOOL)isEmptyFetchManager:(DTBFetchManager*)fetchManager{
return [fetchManager isEmpty];
}
-(void)destroyFetchManager:(int)slotType{
[[DTBFetchFactory sharedInstance] removeFetchManagerForSlotType:(DTBSlotType)slotType];
}
-(void)setSlotGroup:(DTBAdLoader*)adLoader slotGtoupName:(NSString*)slotGtoupName{
[adLoader setSlotGroup:slotGtoupName];
}
-(DTBSlotGroup*)createSlotGroup:(NSString*)slotGroupName{
DTBSlotGroup *group = [[DTBSlotGroup alloc] initWithName:slotGroupName];
return group;
}
-(void)addSlot:(DTBSlotGroup*)slot size:(DTBAdSize*)size{
[slot addSize:size];
}
-(void)addSlotGroup:(DTBSlotGroup*)group{
[DTBAds.sharedInstance addSlotGroup:group];
}
-(NSString*)fetchMoPubKeywords:(DTBAdResponse*)response {
return [response keywordsForMopub];
}
-(NSString*)fetchAmznSlots:(DTBAdResponse *)response {
return [response amznSlots];
}
-(int)fetchAdWidth:(DTBAdResponse *)response {
DTBAdSize *adSize = [response adSize];
return adSize.width;
}
-(int)fetchAdHeight:(DTBAdResponse *)response {
DTBAdSize *adSize = [response adSize];
return adSize.height;
}
-(NSString*)fetchMediationHints:(DTBAdResponse*)response isSmart:(BOOL)isSmart{
NSError * err;
NSDictionary * hint = [response mediationHints:isSmart];
NSMutableDictionary *mHint = [hint mutableCopy];
NSDate* myDate = mHint[@"load_start"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSString *stringDate = [dateFormatter stringFromDate:myDate];
[mHint setValue:stringDate forKey:@"load_start"];
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:mHint options:0 error:&err];
NSString * mediationHints = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
return mediationHints;
}
-(void)setCMPFlavor:(DTBCMPFlavor)cFlavor {
[DTBAds.sharedInstance setCmpFlavor:cFlavor];
}
-(void)setConsentStatus:(DTBConsentStatus)consentStatus{
[DTBAds.sharedInstance setConsentStatus:consentStatus];
}
-(NSMutableArray*)createArray{
return [[NSMutableArray alloc] init];
}
-(void)addToArray:(NSMutableArray*)dictionary item:(int)item{
NSNumber* num = [NSNumber numberWithInt:item];
[dictionary addObject:num];
}
-(void)setVendorList:(NSMutableArray*)dictionary{
[DTBAds.sharedInstance setVendorList:dictionary];
}
-(void)setAutoRefresh:(DTBAdLoader*)adLoader{
[adLoader setAutoRefresh];
}
-(void)setAutoRefresh:(DTBAdLoader*)adLoader secs:(int)secs{
[adLoader setAutoRefresh:secs];
}
-(void)pauseAutorefresh:(DTBAdLoader*)adLoader{
[adLoader pauseAutorefresh];
}
-(void)stopAutoRefresh:(DTBAdLoader*)adLoader{
[adLoader stop];
}
-(void)resumeAutoRefresh:(DTBAdLoader*)adLoader{
[adLoader resumeAutorefresh];
}
-(void)setAPSPublisherExtendedIdFeatureEnabled:(BOOL)isEnabled {
[DTBAds.sharedInstance setAPSPublisherExtendedIdFeatureEnabled:isEnabled];
}
-(void)addCustomAttribute:(NSString *)withKey value:(id)value {
[DTBAds.sharedInstance addCustomAttribute:withKey value:value];
}
-(void)removeCustomAttribute:(NSString *)forKey {
[DTBAds.sharedInstance removeCustomAttribute:forKey];
}
-(void)setAdNetworkInfo:(DTBAdNetworkInfo *)dtbAdNetworkInfo {
[[DTBAds sharedInstance] setAdNetworkInfo:dtbAdNetworkInfo];
}
-(void)setLocalExtras:(NSString *)adUnitId localExtras:(NSDictionary *)localExtras {
[DTBAds setLocalExtras:adUnitId localExtras:localExtras];
}
-(NSDictionary *)getMediationHintsDict:(DTBAdResponse*)response isSmart:(BOOL)isSmart{
return [response mediationHints:isSmart];
}
-(void)showInterstitialAd:(DTBAdInterstitialDispatcher*)dispatcher {
[dispatcher showFromController:[self unityRootViewController]];
}
-(UIViewController *)unityRootViewController {
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
// @TODO Check whether the appDelegate implements rootViewController. Refer to CR-68240623 for discussions.
if ([appDelegate respondsToSelector:@selector(rootViewController)]) {
return [[[UIApplication sharedApplication].delegate window] rootViewController];
}
return nil;
}
@end

View File

@ -0,0 +1,110 @@
fileFormatVersion: 2
guid: 65a7bcd4e95cc47c88cd2b6280e00c17
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
#import <DTBiOSSDK/DTBiOSSDK.h>
#import <DTBiOSSDK/DTBAdCallback.h>
typedef const void *DTBAdCallbackClientRef;
typedef void (*SuccessResponse) (DTBAdCallbackClientRef* callback, DTBAdResponse* dataPtr);
typedef void (*ErrorResponse) (DTBAdCallbackClientRef* callback, int errorCode);
typedef void (*ErrorResponseWithInfo) (DTBAdCallbackClientRef* callback, int errorCode, DTBAdErrorInfo* adErrorInfoPtr);
@interface AmazonUnityCallback : NSObject <DTBAdCallback> {
SuccessResponse _successCallback;
ErrorResponse _errorCallback;
ErrorResponseWithInfo _errorCallbackWithInfo;
DTBAdCallbackClientRef* _callbackClient;
}
- (void)setListeners:(DTBAdCallbackClientRef*)client success:(SuccessResponse)success errorCallback:(ErrorResponse)error;
- (void)setListenersWithInfo:(DTBAdCallbackClientRef*)client success:(SuccessResponse)success errorCallbackWithInfo:(ErrorResponseWithInfo)errorCallbackWithInfo;
@end

View File

@ -0,0 +1,105 @@
fileFormatVersion: 2
guid: 4ab68d8321afe4cca8177a404f816891
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@
#import "AmazonUnityCallback.h"
#import "AmazonManager.h"
@implementation AmazonUnityCallback
- (void)setListeners:(DTBAdCallbackClientRef*)client success:(SuccessResponse)success errorCallback:(ErrorResponse)error {
_callbackClient = client;
_successCallback = success;
_errorCallback = error;
}
- (void)setListenersWithInfo:(DTBAdCallbackClientRef*)client success:(SuccessResponse)success errorCallbackWithInfo:(ErrorResponseWithInfo)errorCallbackWithInfo {
_callbackClient = client;
_successCallback = success;
_errorCallbackWithInfo = errorCallbackWithInfo;
}
#pragma mark - AmazonUnityCallback
- (void)onFailure:(DTBAdError)error {
if (_errorCallback != nil) {
_errorCallback( _callbackClient, (int)error );
}
}
- (void)onFailure:(DTBAdError)error
dtbAdErrorInfo:(DTBAdErrorInfo *) dtbAdErrorInfo {
if (_errorCallbackWithInfo != nil) {
_errorCallbackWithInfo( _callbackClient, (int)error, dtbAdErrorInfo );
}
}
- (void)onSuccess:(DTBAdResponse *)adResponse {
if (_successCallback != nil) {
_successCallback( _callbackClient, adResponse );
}
}
@end

View File

@ -0,0 +1,85 @@
fileFormatVersion: 2
guid: ab36449d445ac4544afe77c7c0539ec0
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,26 @@
#import <DTBiOSSDK/DTBiOSSDK.h>
#import <DTBiOSSDK/DTBAdBannerDispatcher.h>
typedef const void *DTBCallbackBannerRef;
typedef void (*DTBAdDidLoadType) (DTBCallbackBannerRef* callback);
typedef void (*DTBAdFailedToLoadType) (DTBCallbackBannerRef* callback);
typedef void (*DTBBannerWillLeaveApplicationType) (DTBCallbackBannerRef* callback);
typedef void (*DTBImpressionFiredType) (DTBCallbackBannerRef* callback);
@interface DTBBannerDelegate : NSObject <DTBAdBannerDispatcherDelegate>
{
DTBAdDidLoadType _adDidLoadDelegate;
DTBAdFailedToLoadType _adFailedToLoadDelegate;
DTBBannerWillLeaveApplicationType _bannerWillLeaveApplicationDelegate;
DTBImpressionFiredType _impressionFiredDelegate;
DTBCallbackBannerRef* _callbackClient;
}
- (void)setDelegate:(DTBCallbackBannerRef*)client
adLoad:(DTBAdDidLoadType)adLoad
adFailLoad:(DTBAdFailedToLoadType)adFailLoad
leaveApp:(DTBBannerWillLeaveApplicationType)leaveApp
impFired:(DTBImpressionFiredType)impFired;
@end

View File

@ -0,0 +1,80 @@
fileFormatVersion: 2
guid: a58dbc723902c4dd6a148f77e0845a3c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
#import "DTBBannerDelegate.h"
@implementation DTBBannerDelegate
- (void)setDelegate:(DTBCallbackBannerRef*)client
adLoad:(DTBAdDidLoadType)adLoad
adFailLoad:(DTBAdFailedToLoadType)adFailLoad
leaveApp:(DTBBannerWillLeaveApplicationType)leaveApp
impFired:(DTBImpressionFiredType)impFired
{
_callbackClient = client;
_adDidLoadDelegate = adLoad;
_adFailedToLoadDelegate = adFailLoad;
_bannerWillLeaveApplicationDelegate = leaveApp;
_impressionFiredDelegate = impFired;
}
#pragma mark - DTBBannerDelegate
- (void)adDidLoad:(UIView * _Nonnull)adView {
if (_adDidLoadDelegate != nil) {
_adDidLoadDelegate(_callbackClient);
}
}
- (void)adFailedToLoad:(UIView * _Nullable)banner errorCode:(NSInteger)errorCode {
if (_adFailedToLoadDelegate != nil) {
_adFailedToLoadDelegate(_callbackClient);
}
}
- (void)bannerWillLeaveApplication:(UIView *)adView {
if (_bannerWillLeaveApplicationDelegate != nil) {
_bannerWillLeaveApplicationDelegate(_callbackClient);
}
}
- (void)impressionFired {
if (_impressionFiredDelegate != nil) {
_impressionFiredDelegate(_callbackClient);
}
}
@end

View File

@ -0,0 +1,85 @@
fileFormatVersion: 2
guid: 64f2586d9fb3549848bbd34f6f8085d2
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,31 @@
#import <DTBiOSSDK/DTBiOSSDK.h>
#import <DTBiOSSDK/DTBAdInterstitialDispatcher.h>
typedef const void *DTBCallbackInterstitialRef;
typedef void (*DTBInterstitialDidLoadType) (DTBCallbackInterstitialRef* callback);
typedef void (*DTBDidFailToLoadAdWithErrorCodeType) (DTBCallbackInterstitialRef* callback);
typedef void (*DTBInterstitialDidPresentScreenType) (DTBCallbackInterstitialRef* callback);
typedef void (*DTBInterstitialDidDismissScreenType) (DTBCallbackInterstitialRef* callback);
typedef void (*DTBInterstitialWillLeaveApplicationType) (DTBCallbackInterstitialRef* callback);
typedef void (*DTBInterstitialImpressionFiredType) (DTBCallbackInterstitialRef* callback);
@interface DTBInterstitialDelegate : NSObject <DTBAdInterstitialDispatcherDelegate> {
DTBInterstitialDidLoadType _didLoadDelegate;
DTBDidFailToLoadAdWithErrorCodeType _didFailToLoadDelegate;
DTBInterstitialDidPresentScreenType _didPresentScreenDelegate;
DTBInterstitialDidDismissScreenType _didDismissScreenDelegate;
DTBInterstitialWillLeaveApplicationType _leaveAppDelegate;
DTBInterstitialImpressionFiredType _impFiredDelegate;
DTBCallbackInterstitialRef* _callbackClient;
}
- (void)setDelegate:(DTBCallbackInterstitialRef*)client
adLoad:(DTBInterstitialDidLoadType)adLoad
adFailLoad:(DTBDidFailToLoadAdWithErrorCodeType)adFailLoad
leaveApp:(DTBInterstitialWillLeaveApplicationType)leaveApp
impFired:(DTBInterstitialImpressionFiredType)impFired
didOpen:(DTBInterstitialDidPresentScreenType)didOpen
didDismiss:(DTBInterstitialDidDismissScreenType)didDismiss;
@end

View File

@ -0,0 +1,80 @@
fileFormatVersion: 2
guid: ec64dc94f39894ffba7e39a14f3b2102
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,69 @@
#import "DTBInterstitialDelegate.h"
@implementation DTBInterstitialDelegate
- (void)setDelegate:(DTBCallbackInterstitialRef*)client
adLoad:(DTBInterstitialDidLoadType)adLoad
adFailLoad:(DTBDidFailToLoadAdWithErrorCodeType)adFailLoad
leaveApp:(DTBInterstitialWillLeaveApplicationType)leaveApp
impFired:(DTBInterstitialImpressionFiredType)impFired
didOpen:(DTBInterstitialDidPresentScreenType)didOpen
didDismiss:(DTBInterstitialDidDismissScreenType)didDismiss
{
_callbackClient = client;
_didLoadDelegate = adLoad;
_didFailToLoadDelegate = adFailLoad;
_leaveAppDelegate = leaveApp;
_impFiredDelegate = impFired;
_didPresentScreenDelegate = didOpen;
_didDismissScreenDelegate = didDismiss;
}
#pragma mark - DTBInterstitialDelegate
- (void)interstitialDidLoad:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
if (_didLoadDelegate != nil) {
_didLoadDelegate(_callbackClient);
}
}
- (void)interstitial:(DTBAdInterstitialDispatcher * _Nullable )interstitial
didFailToLoadAdWithErrorCode:(DTBAdErrorCode)errorCode {
if (_didFailToLoadDelegate != nil) {
_didFailToLoadDelegate(_callbackClient);
}
}
- (void)interstitialWillPresentScreen:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
}
- (void)interstitialDidPresentScreen:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
if (_didPresentScreenDelegate != nil) {
_didPresentScreenDelegate(_callbackClient);
}
}
- (void)interstitialWillDismissScreen:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
}
- (void)interstitialDidDismissScreen:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
if (_didDismissScreenDelegate != nil) {
_didDismissScreenDelegate(_callbackClient);
}
}
- (void)interstitialWillLeaveApplication:(DTBAdInterstitialDispatcher * _Nullable )interstitial {
if (_leaveAppDelegate != nil) {
_leaveAppDelegate(_callbackClient);
}
}
- (void)showFromRootViewController:(UIViewController *_Nonnull)controller {
}
- (void)impressionFired {
if (_impFiredDelegate != nil) {
_impFiredDelegate(_callbackClient);
}
}
@end

View File

@ -0,0 +1,85 @@
fileFormatVersion: 2
guid: 4f43b5dc42cf54011b96f66d261f2619
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

8
Amazon/Sample.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6a17d7d5a68624567861d0e1822b24a9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fb8e1477d33cb4076b8aa247ae7dd237
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,297 @@

using System;
using AmazonAds;
using UnityEngine;
using System.Collections.Generic;
public class AmazonMaxDemo : MonoBehaviour {
private const string maxKey = "l-_TbRRFRIhI2bN388lTNzh0k_83nqhSLMkFs2ATgT_y4GPxCqSQOdiDV3WgHf01C4N9r53JvUp-N_65kdcdro";
#if UNITY_ANDROID
private const string appId = "7873ab072f0647b8837748312c7b8b5a";
private const string maxBannerAdId = "989798cb31a0d25f";
private const string maxInterstitialAdId = "7e3a01318c888038";
private const string maxVideoAdId = "09d9041492d1d0d9";
private const string amazonBannerSlotId = "ed3b9f16-4497-4001-be7d-2e8ca679ee73"; //320x50
private const string amzonInterstitialSlotId = "394133e6-27fe-477d-816b-4a00cdaa54b6";
private const string amazonInterstitialVideoSlotId = "b9f9a2aa-72d8-4cb3-83db-949ebb53836f";
private const string amazonRewardedVideoSlotId = "1ed9fa0b-3cf0-4326-8c35-c0e9ddcdb765";
#else
private const string appId = "c5f20fe6e37146b08749d09bb2b6a4dd";
private const string maxBannerAdId = "d7dc4c6c1d6886fb";
private const string maxInterstitialAdId = "928de5b2fa152dac";
private const string maxVideoAdId = "57e0224b0c29607c";
private const string amazonBannerSlotId = "88e6293b-0bf0-43fc-947b-925babe7bf3f"; //320x50
private const string amzonInterstitialSlotId = "424c37b6-38e0-4076-94e6-0933a6213496";
private const string amazonInterstitialVideoSlotId = "671086df-06f2-4ee7-86f6-e578d10b3128";
private const string amazonRewardedVideoSlotId = "08892e57-35ff-450c-8b35-4d261251f7c7";
#endif
public UnityEngine.UI.Button isInitializedBut;
private bool isAutoRefresh = true;
private bool isFirstInterstitialRequest = true;
private bool isFirstVideoInterstitialRequest = true;
private bool isFirstRewardedVideoRequest = true;
private APSBannerAdRequest bannerAdRequest;
private APSInterstitialAdRequest interstitialAdRequest;
private APSVideoAdRequest interstitialVideoAdRequest;
private APSVideoAdRequest rewardedVideoAdRequest;
public void InitializeMax () {
Amazon.Initialize(appId);
Amazon.EnableTesting(true);
Amazon.EnableLogging(true);
Amazon.UseGeoLocation(true);
Amazon.SetMRAIDPolicy(Amazon.MRAIDPolicy.CUSTOM);
Amazon.SetAdNetworkInfo(new AdNetworkInfo(DTBAdNetwork.MAX));
Amazon.SetMRAIDSupportedVersions(new string[] { "1.0", "2.0", "3.0" });
MaxSdk.SetSdkKey(maxKey);
MaxSdk.InitializeSdk();
MaxSdk.SetCreativeDebuggerEnabled(true);
MaxSdk.SetVerboseLogging(true);
MaxSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerAdLoadedEvent;
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerAdLoadFailedEvent;
MaxSdkCallbacks.Banner.OnAdClickedEvent += OnBannerAdClickedEvent;
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerAdRevenuePaidEvent;
MaxSdkCallbacks.Banner.OnAdExpandedEvent += OnBannerAdExpandedEvent;
MaxSdkCallbacks.Banner.OnAdCollapsedEvent += OnBannerAdCollapsedEvent;
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialLoadFailedEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickedEvent;
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialHiddenEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdFailedEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
}
public void IsInitialized(){
if (isInitializedBut == null ) return;
if( Amazon.IsInitialized() ) {
isInitializedBut.GetComponent<UnityEngine.UI.Image>().color = Color.green;
} else {
isInitializedBut.GetComponent<UnityEngine.UI.Image>().color = Color.red;
}
}
public void RequestInterstitial () {
if (isFirstInterstitialRequest) {
isFirstInterstitialRequest = false;
interstitialAdRequest = new APSInterstitialAdRequest(amzonInterstitialSlotId);
interstitialAdRequest.onSuccess += (adResponse) =>
{
MaxSdk.SetInterstitialLocalExtraParameter(maxInterstitialAdId, "amazon_ad_response", adResponse.GetResponse());
MaxSdk.LoadInterstitial(maxInterstitialAdId);
};
interstitialAdRequest.onFailedWithError += (adError) =>
{
MaxSdk.SetInterstitialLocalExtraParameter(maxInterstitialAdId, "amazon_ad_error", adError.GetAdError());
MaxSdk.LoadInterstitial(maxInterstitialAdId);
};
interstitialAdRequest.LoadAd();
} else {
MaxSdk.LoadInterstitial(maxInterstitialAdId);
}
}
private void CreateMaxBannerAd()
{
MaxSdk.CreateBanner(maxBannerAdId, MaxSdkBase.BannerPosition.BottomCenter);
MaxSdk.SetBannerPlacement(maxBannerAdId, "MY_BANNER_PLACEMENT");
}
public void RequestBanner () {
const int width = 320;
const int height = 50;
if (bannerAdRequest != null) bannerAdRequest.DestroyFetchManager();
bannerAdRequest = new APSBannerAdRequest(width, height, amazonBannerSlotId);
bannerAdRequest.onFailedWithError += (adError) =>
{
MaxSdk.SetBannerLocalExtraParameter(maxBannerAdId, "amazon_ad_error", adError.GetAdError());
CreateMaxBannerAd();
};
bannerAdRequest.onSuccess += (adResponse) =>
{
MaxSdk.SetBannerLocalExtraParameter(maxBannerAdId, "amazon_ad_response", adResponse.GetResponse());
CreateMaxBannerAd();
};
bannerAdRequest.LoadAd();
}
public void RequestInterstitialVideo () {
if(isFirstVideoInterstitialRequest) {
isFirstVideoInterstitialRequest = false;
interstitialVideoAdRequest = new APSVideoAdRequest(320, 480, amazonInterstitialVideoSlotId);
interstitialVideoAdRequest.onSuccess += (adResponse) =>
{
MaxSdk.SetInterstitialLocalExtraParameter(maxInterstitialAdId, "amazon_ad_response", adResponse.GetResponse());
MaxSdk.LoadInterstitial(maxInterstitialAdId);
};
interstitialVideoAdRequest.onFailedWithError += (adError) =>
{
MaxSdk.SetInterstitialLocalExtraParameter(maxInterstitialAdId, "amazon_ad_error", adError.GetAdError());
MaxSdk.LoadInterstitial(maxInterstitialAdId);
};
interstitialVideoAdRequest.LoadAd();
} else {
MaxSdk.LoadInterstitial(maxInterstitialAdId);
}
}
public void RequestRewardedVideo () {
if (isFirstRewardedVideoRequest) {
isFirstRewardedVideoRequest = false;
rewardedVideoAdRequest = new APSVideoAdRequest(320, 480, amazonRewardedVideoSlotId);
rewardedVideoAdRequest.onSuccess += (adResponse) =>
{
MaxSdk.SetRewardedAdLocalExtraParameter(maxVideoAdId, "amazon_ad_response", adResponse.GetResponse());
MaxSdk.LoadRewardedAd(maxVideoAdId);
};
rewardedVideoAdRequest.onFailedWithError += (adError) =>
{
MaxSdk.SetRewardedAdLocalExtraParameter(maxVideoAdId, "amazon_ad_error", adError.GetAdError());
MaxSdk.LoadRewardedAd(maxVideoAdId);
};
rewardedVideoAdRequest.LoadAd();
} else {
MaxSdk.LoadRewardedAd(maxVideoAdId);
}
}
private void OnBannerAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
MaxSdk.ShowBanner(maxBannerAdId);
}
private void OnBannerAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
}
private void OnBannerAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
private void OnBannerAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
private void OnBannerAdExpandedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
private void OnBannerAdCollapsedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
private void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnInterstitialLoadedEvent:" + MaxSdk.IsInterstitialReady(maxInterstitialAdId));
if (MaxSdk.IsInterstitialReady(maxInterstitialAdId))
{
MaxSdk.ShowInterstitial(maxInterstitialAdId);
}
}
private void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
Debug.Log("OnInterstitialLoadFailedEvent");
}
private void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnInterstitialDisplayedEvent");
}
private void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnInterstitialAdFailedToDisplayEvent");
}
private void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnInterstitialClickedEvent");
}
private void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnInterstitialHiddenEvent");
}
private void ShowRewardedAd()
{
Debug.Log("ShowRewardedAd:" + MaxSdk.IsRewardedAdReady(maxVideoAdId));
if (MaxSdk.IsRewardedAdReady(maxVideoAdId))
{
MaxSdk.ShowRewardedAd(maxVideoAdId);
}
}
private void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnRewardedAdLoadedEvent");
ShowRewardedAd();
}
private void OnRewardedAdFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
Debug.Log("OnRewardedAdFailedEvent");
}
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad failed to display. We recommend loading the next ad
Debug.Log("Rewarded ad failed to display with error code: " + errorInfo.Code);
//MaxSdk.LoadRewardedAd(maxVideoAdId);
}
private void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("Rewarded ad displayed");
}
private void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("Rewarded ad clicked");
}
private void OnRewardedAdDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad is hidden. Pre-load the next ad
Debug.Log("Rewarded ad dismissed");
//MaxSdk.LoadRewardedAd(RewardedAdUnitId);
}
private void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad was displayed and user should receive the reward
Debug.Log("HERE:Rewarded ad received reward");
}
private void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("OnRewardedAdRevenuePaidEvent");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 34ed58385e8924837ad87a1f2966e16b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Amazon/Scripts.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 296ee3b3b262345f6bfe2f066958a91d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

123
Amazon/Scripts/Amazon.cs Normal file
View File

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmazonAds {
public class Amazon {
private static PlatformApi api;
public delegate void OnFailureDelegate (string errorMsg);
public delegate void OnFailureWithErrorDelegate (AdError adError);
public delegate void OnSuccessDelegate (AdResponse response);
public delegate void OnApplicationPauseDelegate(bool pauseStatus);
public static OnApplicationPauseDelegate OnApplicationPause = (pauseStatus) => { };
public enum MRAIDPolicy {
AUTO_DETECT,
MOPUB,
DFP,
CUSTOM,
NONE
}
public enum ConsentStatus {
CONSENT_NOT_DEFINED,
EXPLICIT_YES,
EXPLICIT_NO,
UNKNOWN
}
public enum CMPFlavor {
CMP_NOT_DEFINED,
GOOGLE_CMP,
MOPUB_CMP
}
public static void Initialize (string key) {
#if UNITY_IOS
api = new AmazonAds.IOS.IOSPlatform ();
#elif UNITY_ANDROID
api = new AmazonAds.Android.AndroidPlatform ();
#endif
api.Initialization (key);
}
public static void SetMRAIDPolicy (Amazon.MRAIDPolicy policy) {
api.SetMRAIDPolicy (policy);
}
public static void SetCMPFlavor(Amazon.CMPFlavor cFlavor){
api.SetCMPFlavor(cFlavor);
}
public static void SetConsentStatus(Amazon.ConsentStatus consentStatus){
api.SetConsentStatus(consentStatus);
}
public static void SetVendorList(List<int> vendorList){
api.SetVendorList(vendorList);
}
public static void AddSlotGroup (SlotGroup group) {
api.AddSlotGroup (group);
}
public static MRAIDPolicy GetMRAIDPolicy () {
return api.GetMRAIDPolicy ();
}
public static void SetMRAIDSupportedVersions (String[] versions) {
api.SetMRAIDSupportedVersions (versions);
}
public static void EnableLogging (bool flag) {
api.EnableLogging (flag);
}
public static void UseGeoLocation (bool isLocationEnabled) {
api.UseGeoLocation (isLocationEnabled);
}
public static bool IsLocationEnabled () {
return api.IsLocationEnabled ();
}
public static bool IsInitialized () {
return api.IsInitialized ();
}
public static bool IsTestMode () {
return api.IsTestMode ();
}
public static void EnableTesting (bool flag) {
api.EnableTesting (flag);
}
public static void AddCustomAttribute(string withKey, string value)
{
api.AddCustomAttribute(withKey, value);
}
public static void RemoveCustomAttribute(string forKey)
{
api.RemoveCustomAttr(forKey);
}
public static void SetAdNetworkInfo(AdNetworkInfo adNetworkInfo)
{
api.SetAdNetworkInfo(adNetworkInfo);
}
#if UNITY_IOS
public static void SetAPSPublisherExtendedIdFeatureEnabled(bool isEnabled)
{
api.SetAPSPublisherExtendedIdFeatureEnabled(isEnabled);
}
public static void SetMediationLocalExtras(string adUnitId, AdResponse adResponse)
{
api.SetLocalExtras(adUnitId, adResponse);
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d5987cccc71fa4c51877e7c22d2d5f56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
using System;
public static class AmazonConstants
{
public const string VERSION = "1.4.3";
public const string RELEASE_NOTES_URL = "https://ams.amazon.com/webpublisher/uam/docs/aps-mobile/resources"; //TODO : add Unity Release Notes link
public const string titleAboutDialog = "About Amazon SDK";
public const string labelSdkVersion = "Amazon SDK version " + AmazonConstants.VERSION;
public const string buttonReleaseNotes = "Release Notes";
public const string labelReportIssues = "Report Issues: " + "Mobile-aps-support@amazon.com";
public const string aboutDialogOk = "OK";
public const string manifestURL = "https://mdtb-sdk-packages.s3-us-west-2.amazonaws.com/Unity/aps_unity.json";
public const string helpLink = "https://ams.amazon.com/webpublisher/uam/docs/aps-mobile/resources";
public const string docUrl = "https://ams.amazon.com/webpublisher/uam/docs/aps-mobile";
internal const string unityPlayerClass = "com.unity3d.player.UnityPlayer";
// Android constant names
internal const string sdkUtilitiesClass = "com.amazon.device.ads.SDKUtilities";
internal const string dtbAdViewClass = "com.amazon.device.ads.DTBAdView";
internal const string dtbAdInterstitialClass = "com.amazon.device.ads.DTBAdInterstitial";
internal const string dtbAdNetworkClass = "com.amazon.device.ads.DTBAdNetwork";
internal const string dtbAdNetworkInfoClass = "com.amazon.device.ads.DTBAdNetworkInfo";
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a4c36066dbdad415b978c38a01a2b675
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8c45974962ec542baad78d4c30cd0056
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace AmazonAds {
public abstract class IAdInterstitial {
public abstract void FetchAd (AdResponse adResponse);
public abstract void Show ();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4da15e7be3dc455d97abce962533892
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using UnityEngine;
namespace AmazonAds {
public abstract class IAdRequest {
protected int refreshTime = 60;
protected string autoRefreshID = "0"; //FetchManageerUniqueID
protected bool isAutoRefreshAdMob = false;
protected bool isAutoRefreshMoPub = false;
protected bool requestHasBeenUsed = false;
protected IFetchManager fetchManager;
public abstract void PutCustomTarget (string key, string value);
public abstract void SetSizes (IAdSize sizes);
public abstract void SetSizes (IInterstitialAdSize sizes);
public abstract void SetSizes (IVideo sizes);
public abstract void SetSlotGroup (string slotGroupName);
public abstract void LoadAd (Amazon.OnFailureDelegate failure, Amazon.OnSuccessDelegate success);
public abstract void LoadAd (Amazon.OnFailureWithErrorDelegate failure, Amazon.OnSuccessDelegate success);
public abstract void LoadSmartBanner (Amazon.OnFailureDelegate failure, Amazon.OnSuccessDelegate success);
public abstract void LoadSmartBanner (Amazon.OnFailureWithErrorDelegate failure, Amazon.OnSuccessDelegate success);
public abstract void SetAutoRefreshAdMob (bool flag, bool isSmartBanner = false);
public abstract void SetAutoRefreshMoPub (bool flag);
public abstract void SetAutoRefreshMoPub (bool flag, int refreshTime);
public abstract void SetAutoRefresh();
public abstract void SetAutoRefresh(int secs);
public abstract void ResumeAutoRefresh();
public abstract void StopAutoRefresh();
public abstract void PauseAutoRefresh();
public bool IsAutoRefreshAdMob (){ return isAutoRefreshAdMob;}
public bool IsAutoRefreshMoPub (){ return isAutoRefreshMoPub;}
public string AutoRefreshID (){return autoRefreshID.ToString ();}
public abstract void DisposeAd ();
public abstract void CreateFetchManager (bool isSmartBanner = false);
public abstract void DestroyFetchManager ();
public abstract void StopFetchManager();
public abstract void StartFetchManager();
public abstract void SetRefreshFlag(bool flag);
protected static class Schedule {
private class Runner : MonoBehaviour { }
private static Runner _backer;
private static Runner Backer {
get {
if (_backer == null) {
var go = new GameObject ("Scheduler");
GameObject.DontDestroyOnLoad (go);
_backer = go.AddComponent<Runner> ();
}
return _backer;
}
}
private static float expiration = 5f;
public static void WaitForAdResponce (IFetchManager fetchManager, Amazon.OnFailureDelegate failure, Amazon.OnSuccessDelegate success) {
Schedule.Backer.StartCoroutine (WaitForAdResponceCoroutine (fetchManager, failure, success));
}
static IEnumerator WaitForAdResponceCoroutine (IFetchManager fetchManager, Amazon.OnFailureDelegate failure, Amazon.OnSuccessDelegate success) {
float timerExp = 0;
bool flagResp = true;
while (fetchManager.isEmpty()) {
timerExp += Time.deltaTime;
if (timerExp > expiration) {
flagResp = false;
failure ("no ads from fetchManager");
break;
}
yield return null;
}
if (flagResp) {
success( fetchManager.peek () );
}
Schedule.Clear ();
}
public static void Clear () {
GameObject.Destroy (Backer);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba13283bbee174961b809f3b9e502094
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
namespace AmazonAds {
public interface IAdSize {
int GetWidth ();
int GetHeight ();
string GetSlotUUID ();
}
public interface IInterstitialAdSize { }
public interface IVideo { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33e37a43420f84a408938af12117ff08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace AmazonAds {
public abstract class IAdView {
public abstract void FetchAd (AdResponse adResponse);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: adeba99c4a0f04b54b8af9623665e2d5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using UnityEngine;
namespace AmazonAds {
public interface IFetchManager {
void dispense ();
void start ();
void stop ();
bool isEmpty ();
AmazonAds.AdResponse peek ();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dec92b206e59e400c8706ec073e326d1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
namespace AmazonAds{
public interface ISlotGroup
{
void AddSlot(int width, int height, string uid);
void AddSlot(AdSize size);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b1f29380367c47c6a1c112ddc47ad84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 60916135eefd74087bcd8ca80bd94ddc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
{
"name": "Amazon.Editor",
"references": [
"Amazon"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 59f42bdf21710439a90f93e01e1f8984
timeCreated: 1700190285

View File

@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
using AmazonAds;
public class AmazonAboutDialog : ScriptableWizard {
public static void ShowDialog () {
DisplayWizard<AmazonAboutDialog> (AmazonConstants.titleAboutDialog, AmazonConstants.aboutDialogOk);
}
protected override bool DrawWizardGUI () {
EditorGUILayout.LabelField (AmazonConstants.labelSdkVersion);
EditorGUILayout.Space ();
if (GUILayout.Button (AmazonConstants.buttonReleaseNotes))
Application.OpenURL (AmazonConstants.RELEASE_NOTES_URL);
EditorGUILayout.LabelField ("\n");
EditorGUILayout.LabelField (AmazonConstants.labelReportIssues);
return false;
}
private void OnWizardCreate () { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 431a6434bfc0a47e8a2c936e434c3d3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,104 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Linq;
using UnityEditor.Callbacks;
public class AmazonBuildScript
{
public static string DEFAULT_APK_NAME = "APSUnityTestApp.apk";
public static string DEFAULT_IOS_BUILD_DIR = "Builds/iOS";
public static void BuildIos()
{
string[] scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
string outputFileName = GetArg("-output", DEFAULT_IOS_BUILD_DIR);
BuildPipeline.BuildPlayer(scenes, outputFileName, BuildTarget.iOS, BuildOptions.Development);
}
public static void BuildAndroid()
{
string[] scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
string outputFileName = GetArg("-output", DEFAULT_APK_NAME);
BuildPipeline.BuildPlayer(scenes, outputFileName, BuildTarget.Android, BuildOptions.Development);
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
}
public static void SwitchToIos()
{
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS);
}
private static string GetArg(string name, string defaultVal)
{
var args = System.Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; i++)
{
if (args[i] == name && args.Length > i + 1)
{
return args[i + 1];
}
}
return defaultVal;
}
public static void BuildExternalAndroid()
{
string[] envvars = new string[]
{
"ANDROID_KEYSTORE_NAME", "ANDROID_KEYSTORE_PASSWORD", "ANDROID_KEYALIAS_NAME", "ANDROID_KEYALIAS_PASSWORD", "ANDROID_SDK_ROOT"
};
if (EnvironmentVariablesMissing(envvars))
{
Environment.ExitCode = -1;
return; // note, we can not use Environment.Exit(-1) - the buildprocess will just hang afterwards
}
//Available Playersettings: https://docs.unity3d.com/ScriptReference/PlayerSettings.Android.html
//set the internal apk version to the current unix timestamp, so this increases with every build
PlayerSettings.Android.bundleVersionCode = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
//set the other settings from environment variables
PlayerSettings.Android.keystoreName = Environment.GetEnvironmentVariable("ANDROID_KEYSTORE_NAME");
PlayerSettings.Android.keystorePass = Environment.GetEnvironmentVariable("ANDROID_KEYSTORE_PASSWORD");
PlayerSettings.Android.keyaliasName = Environment.GetEnvironmentVariable("ANDROID_KEYALIAS_NAME");
PlayerSettings.Android.keyaliasPass = Environment.GetEnvironmentVariable("ANDROID_KEYALIAS_PASSWORD");
EditorPrefs.SetString("AndroidSdkRoot", Environment.GetEnvironmentVariable("ANDROID_SDK_ROOT"));
//Get the apk file to be built from the command line argument
string outputapk = Environment.GetCommandLineArgs().Last();
BuildPipeline.BuildPlayer(GetScenePaths(), outputapk, BuildTarget.Android, BuildOptions.None);
}
static string[] GetScenePaths()
{
string[] scenes = new string[EditorBuildSettings.scenes.Length];
for (int i = 0; i < scenes.Length; i++)
{
scenes[i] = EditorBuildSettings.scenes[i].path;
}
return scenes;
}
static bool EnvironmentVariablesMissing(string[] envvars)
{
string value;
bool missing = false;
foreach (string envvar in envvars)
{
value = Environment.GetEnvironmentVariable(envvar);
if (value == null)
{
Console.Write("BUILD ERROR: Required Environment Variable is not set: ");
Console.WriteLine(envvar);
missing = true;
}
}
return missing;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c1378b372e98d4b56a16725bf370ae6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
/*
Copyright (c) 2017 Marijn Zwemmer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using System.Collections;
using UnityEditor;
namespace AmazonInternal.ThirdParty {
public static class AmazonCoroutineExtensions {
public static AmazonCoroutines.AmazonCoroutine StartCoroutine (this EditorWindow thisRef, IEnumerator coroutine) {
return AmazonCoroutines.StartCoroutine (coroutine, thisRef);
}
public static AmazonCoroutines.AmazonCoroutine StartCoroutine (this EditorWindow thisRef, string methodName) {
return AmazonCoroutines.StartCoroutine (methodName, thisRef);
}
public static AmazonCoroutines.AmazonCoroutine StartCoroutine (this EditorWindow thisRef, string methodName, object value) {
return AmazonCoroutines.StartCoroutine (methodName, value, thisRef);
}
public static void StopCoroutine (this EditorWindow thisRef, IEnumerator coroutine) {
AmazonCoroutines.StopCoroutine (coroutine, thisRef);
}
public static void StopCoroutine (this EditorWindow thisRef, string methodName) {
AmazonCoroutines.StopCoroutine (methodName, thisRef);
}
public static void StopAllCoroutines (this EditorWindow thisRef) {
AmazonCoroutines.StopAllCoroutines (thisRef);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aae61b43441904bbcbf7f24ff05e20d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,351 @@
/*
Copyright (c) 2017 Marijn Zwemmer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace AmazonInternal.ThirdParty {
public class AmazonCoroutines {
public class AmazonCoroutine {
public ICoroutineYield currentYield = new YieldDefault ();
public IEnumerator routine;
public string routineUniqueHash;
public string ownerUniqueHash;
public string MethodName = "";
public int ownerHash;
public string ownerType;
public bool finished = false;
public AmazonCoroutine (IEnumerator routine, int ownerHash, string ownerType) {
this.routine = routine;
this.ownerHash = ownerHash;
this.ownerType = ownerType;
ownerUniqueHash = ownerHash + "_" + ownerType;
if (routine != null) {
string[] split = routine.ToString ().Split ('<', '>');
if (split.Length == 3) {
this.MethodName = split[1];
}
}
routineUniqueHash = ownerHash + "_" + ownerType + "_" + MethodName;
}
public AmazonCoroutine (string methodName, int ownerHash, string ownerType) {
MethodName = methodName;
this.ownerHash = ownerHash;
this.ownerType = ownerType;
ownerUniqueHash = ownerHash + "_" + ownerType;
routineUniqueHash = ownerHash + "_" + ownerType + "_" + MethodName;
}
}
public interface ICoroutineYield {
bool IsDone (float deltaTime);
}
struct YieldDefault : ICoroutineYield {
public bool IsDone (float deltaTime) {
return true;
}
}
struct YieldWaitForSeconds : ICoroutineYield {
public float timeLeft;
public bool IsDone (float deltaTime) {
timeLeft -= deltaTime;
return timeLeft < 0;
}
}
struct YieldCustomYieldInstruction : ICoroutineYield {
public CustomYieldInstruction customYield;
public bool IsDone (float deltaTime) {
return !customYield.keepWaiting;
}
}
struct YieldWWW : ICoroutineYield {
public WWW Www;
public bool IsDone (float deltaTime) {
return Www.isDone;
}
}
struct YieldAsync : ICoroutineYield {
public AsyncOperation asyncOperation;
public bool IsDone (float deltaTime) {
return asyncOperation.isDone;
}
}
struct YieldNestedCoroutine : ICoroutineYield {
public AmazonCoroutine coroutine;
public bool IsDone (float deltaTime) {
return coroutine.finished;
}
}
static AmazonCoroutines instance = null;
Dictionary<string, List<AmazonCoroutine>> coroutineDict = new Dictionary<string, List<AmazonCoroutine>> ();
List<List<AmazonCoroutine>> tempCoroutineList = new List<List<AmazonCoroutine>> ();
Dictionary<string, Dictionary<string, AmazonCoroutine>> coroutineOwnerDict =
new Dictionary<string, Dictionary<string, AmazonCoroutine>> ();
DateTime previousTimeSinceStartup;
/// <summary>Starts a coroutine.</summary>
/// <param name="routine">The coroutine to start.</param>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static AmazonCoroutine StartCoroutine (IEnumerator routine, object thisReference) {
CreateInstanceIfNeeded ();
return instance.GoStartCoroutine (routine, thisReference);
}
/// <summary>Starts a coroutine.</summary>
/// <param name="methodName">The name of the coroutine method to start.</param>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static AmazonCoroutine StartCoroutine (string methodName, object thisReference) {
return StartCoroutine (methodName, null, thisReference);
}
/// <summary>Starts a coroutine.</summary>
/// <param name="methodName">The name of the coroutine method to start.</param>
/// <param name="value">The parameter to pass to the coroutine.</param>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static AmazonCoroutine StartCoroutine (string methodName, object value, object thisReference) {
MethodInfo methodInfo = thisReference.GetType ()
.GetMethod (methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (methodInfo == null) {
Debug.LogError ("Coroutine '" + methodName + "' couldn't be started, the method doesn't exist!");
}
object returnValue;
if (value == null) {
returnValue = methodInfo.Invoke (thisReference, null);
} else {
returnValue = methodInfo.Invoke (thisReference, new object[] { value });
}
if (returnValue is IEnumerator) {
CreateInstanceIfNeeded ();
return instance.GoStartCoroutine ((IEnumerator) returnValue, thisReference);
} else {
Debug.LogError ("Coroutine '" + methodName + "' couldn't be started, the method doesn't return an IEnumerator!");
}
return null;
}
/// <summary>Stops all coroutines being the routine running on the passed instance.</summary>
/// <param name="routine"> The coroutine to stop.</param>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static void StopCoroutine (IEnumerator routine, object thisReference) {
CreateInstanceIfNeeded ();
instance.GoStopCoroutine (routine, thisReference);
}
/// <summary>
/// Stops all coroutines named methodName running on the passed instance.</summary>
/// <param name="methodName"> The name of the coroutine method to stop.</param>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static void StopCoroutine (string methodName, object thisReference) {
CreateInstanceIfNeeded ();
instance.GoStopCoroutine (methodName, thisReference);
}
/// <summary>
/// Stops all coroutines running on the passed instance.</summary>
/// <param name="thisReference">Reference to the instance of the class containing the method.</param>
public static void StopAllCoroutines (object thisReference) {
CreateInstanceIfNeeded ();
instance.GoStopAllCoroutines (thisReference);
}
static void CreateInstanceIfNeeded () {
if (instance == null) {
instance = new AmazonCoroutines ();
instance.Initialize ();
}
}
void Initialize () {
previousTimeSinceStartup = DateTime.Now;
EditorApplication.update += OnUpdate;
}
void GoStopCoroutine (IEnumerator routine, object thisReference) {
GoStopActualRoutine (CreateCoroutine (routine, thisReference));
}
void GoStopCoroutine (string methodName, object thisReference) {
GoStopActualRoutine (CreateCoroutineFromString (methodName, thisReference));
}
void GoStopActualRoutine (AmazonCoroutine routine) {
if (coroutineDict.ContainsKey (routine.routineUniqueHash)) {
coroutineOwnerDict[routine.ownerUniqueHash].Remove (routine.routineUniqueHash);
coroutineDict.Remove (routine.routineUniqueHash);
}
}
void GoStopAllCoroutines (object thisReference) {
AmazonCoroutine coroutine = CreateCoroutine (null, thisReference);
if (coroutineOwnerDict.ContainsKey (coroutine.ownerUniqueHash)) {
foreach (var couple in coroutineOwnerDict[coroutine.ownerUniqueHash]) {
coroutineDict.Remove (couple.Value.routineUniqueHash);
}
coroutineOwnerDict.Remove (coroutine.ownerUniqueHash);
}
}
AmazonCoroutine GoStartCoroutine (IEnumerator routine, object thisReference) {
if (routine == null) {
Debug.LogException (new Exception ("IEnumerator is null!"), null);
}
AmazonCoroutine coroutine = CreateCoroutine (routine, thisReference);
GoStartCoroutine (coroutine);
return coroutine;
}
void GoStartCoroutine (AmazonCoroutine coroutine) {
if (!coroutineDict.ContainsKey (coroutine.routineUniqueHash)) {
List<AmazonCoroutine> newCoroutineList = new List<AmazonCoroutine> ();
coroutineDict.Add (coroutine.routineUniqueHash, newCoroutineList);
}
coroutineDict[coroutine.routineUniqueHash].Add (coroutine);
if (!coroutineOwnerDict.ContainsKey (coroutine.ownerUniqueHash)) {
Dictionary<string, AmazonCoroutine> newCoroutineDict = new Dictionary<string, AmazonCoroutine> ();
coroutineOwnerDict.Add (coroutine.ownerUniqueHash, newCoroutineDict);
}
// If the method from the same owner has been stored before, it doesn't have to be stored anymore,
// One reference is enough in order for "StopAllCoroutines" to work
if (!coroutineOwnerDict[coroutine.ownerUniqueHash].ContainsKey (coroutine.routineUniqueHash)) {
coroutineOwnerDict[coroutine.ownerUniqueHash].Add (coroutine.routineUniqueHash, coroutine);
}
MoveNext (coroutine);
}
AmazonCoroutine CreateCoroutine (IEnumerator routine, object thisReference) {
return new AmazonCoroutine (routine, thisReference.GetHashCode (), thisReference.GetType ().ToString ());
}
AmazonCoroutine CreateCoroutineFromString (string methodName, object thisReference) {
return new AmazonCoroutine (methodName, thisReference.GetHashCode (), thisReference.GetType ().ToString ());
}
void OnUpdate () {
float deltaTime = (float) (DateTime.Now.Subtract (previousTimeSinceStartup).TotalMilliseconds / 1000.0f);
previousTimeSinceStartup = DateTime.Now;
if (coroutineDict.Count == 0) {
return;
}
tempCoroutineList.Clear ();
foreach (var pair in coroutineDict)
tempCoroutineList.Add (pair.Value);
for (var i = tempCoroutineList.Count - 1; i >= 0; i--) {
List<AmazonCoroutine> coroutines = tempCoroutineList[i];
for (int j = coroutines.Count - 1; j >= 0; j--) {
AmazonCoroutine coroutine = coroutines[j];
if (!coroutine.currentYield.IsDone (deltaTime)) {
continue;
}
if (!MoveNext (coroutine)) {
coroutines.RemoveAt (j);
coroutine.currentYield = null;
coroutine.finished = true;
}
if (coroutines.Count == 0) {
coroutineDict.Remove (coroutine.ownerUniqueHash);
}
}
}
}
static bool MoveNext (AmazonCoroutine coroutine) {
if (coroutine.routine.MoveNext ()) {
return Process (coroutine);
}
return false;
}
// returns false if no next, returns true if OK
static bool Process (AmazonCoroutine coroutine) {
object current = coroutine.routine.Current;
if (current == null) {
coroutine.currentYield = new YieldDefault ();
} else if (current is WaitForSeconds) {
float seconds = float.Parse (GetInstanceField (typeof (WaitForSeconds), current, "m_Seconds").ToString ());
coroutine.currentYield = new YieldWaitForSeconds () { timeLeft = seconds };
} else if (current is CustomYieldInstruction) {
coroutine.currentYield = new YieldCustomYieldInstruction () {
customYield = current as CustomYieldInstruction
};
} else if (current is WWW) {
coroutine.currentYield = new YieldWWW { Www = (WWW) current };
} else if (current is WaitForFixedUpdate || current is WaitForEndOfFrame) {
coroutine.currentYield = new YieldDefault ();
} else if (current is AsyncOperation) {
coroutine.currentYield = new YieldAsync { asyncOperation = (AsyncOperation) current };
} else if (current is AmazonCoroutine) {
coroutine.currentYield = new YieldNestedCoroutine { coroutine = (AmazonCoroutine) current };
} else {
Debug.LogException (
new Exception ("<" + coroutine.MethodName + "> yielded an unknown or unsupported type! (" + current.GetType () + ")"),
null);
coroutine.currentYield = new YieldDefault ();
}
return true;
}
static object GetInstanceField (Type type, object instance, string fieldName) {
BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
FieldInfo field = type.GetField (fieldName, bindFlags);
return field.GetValue (instance);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dcee96832dc4141299f36d8b10b10467
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="androidx.appcompat:appcompat:1.1.0" />
<androidPackage spec="com.google.android.gms:play-services-ads-lite:20.0.0" />
<androidPackage spec="com.amazon.android:aps-sdk:9.5.4@aar">
<repositories>
<repository>https://aws.oss.sonatype.org/content/repositories/releases/</repository>
</repositories>
</androidPackage>
</androidPackages>
<iosPods>
<iosPod name="Amazon-SDK-Plugin" minTargetSdk="12.5" path="Packages/com.guru.unity.max/Amazon/Plugins/iOS" />
<iosPod name="AmazonPublisherServicesSDK" version="~> 4.5.0" />
</iosPods>
</dependencies>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c9bc3db2384e74f03ae6d3b496e9fdc9
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,54 @@
#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace AmazonInternal.Editor.Postbuild {
public static class AmazonPostBuildiOS {
[PostProcessBuild( 45 )]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iOS)
return;
string pbxProjectPath = PBXProject.GetPBXProjectPath(path);
PBXProject project = new PBXProject();
project.ReadFromFile(pbxProjectPath);
#if UNITY_2019_3_OR_NEWER
string targetGuid = project.GetUnityFrameworkTargetGuid();
#else
string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName());
#endif
project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited)");
project.SetBuildProperty(targetGuid, "CLANG_ENABLE_MODULES", "YES");
project.AddBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
project.WriteToFile(pbxProjectPath);
#if UNITY_2019_3_OR_NEWER
if (buildTarget == BuildTarget.iOS)
{
bool iPhoneExist = false;
using (StreamReader sr = new StreamReader(path + "/Podfile"))
{
string contents = sr.ReadToEnd();
if (contents.Contains("Unity-iPhone"))
{
iPhoneExist = true;
}
}
if ( !iPhoneExist ){
using (StreamWriter sw = File.AppendText(path + "/Podfile"))
{
sw.WriteLine("\ntarget 'Unity-iPhone' do\nend");
}
}
}
#endif
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7474cff9dfc144e89f4e7696b4b8d9c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,400 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using AmazonInternal.ThirdParty;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using UnityEngine.Networking;
public class AmazonSDKManager : EditorWindow {
static string AmazonSdkVersion;
static AddRequest Request;
static void AddEditorCoroutine () {
// Add a package to the Project
Request = Client.Add ("com.unity.editorcoroutine");
EditorApplication.update += Progress;
}
static void Progress () {
if (Request.IsCompleted) {
if (Request.Status == StatusCode.Success)
Debug.Log ("Installed: " + Request.Result.packageId);
else if (Request.Status >= StatusCode.Failure)
Debug.Log (Request.Error.message);
EditorApplication.update -= Progress;
}
}
// [MenuItem ("Amazon/About Amazon SDK", false, 0)]
public static void About () {
AmazonAboutDialog.ShowDialog ();
}
// [MenuItem ("Amazon/Documentation...", false, 1)]
public static void Documentation () {
Application.OpenURL (AmazonConstants.docUrl);
}
// [MenuItem ("Amazon/Manage SDKs...", false, 4)]
public static void SdkManagerProd () {
AmazonSDKManager.ShowSDKManager ();
}
private const string downloadDir = "Assets/Amazon";
private struct SdkInfo {
public string Name;
public string Key;
public string Url;
public string LatestVersion;
public string CurrentVersion;
public string Filename;
public bool FromJson (string name, Dictionary<string, object> dict) {
if (string.IsNullOrEmpty (name) || dict == null)
return false;
object obj;
Key = name;
if (dict.TryGetValue ("name", out obj))
Name = obj as string;
if (dict.TryGetValue ("link", out obj))
Url = obj as string;
if (dict.TryGetValue ("version", out obj))
LatestVersion = obj as string;
if (!string.IsNullOrEmpty (Url)) {
var uri = new Uri (Url);
var path = uri.IsAbsoluteUri ? uri.AbsolutePath : uri.LocalPath;
Filename = Path.GetFileName (path);
}
return true;
}
public bool FromConfig(AmazonPackageConfig config)
{
if (config == null || string.IsNullOrEmpty(config.Name) || !string.IsNullOrEmpty(Key) && Key != config.Name)
return false;
CurrentVersion = config.Version;
return true;
}
}
// Version and download info for the SDK and network mediation adapters.
private static SdkInfo amazonSdkInfo;
private static readonly SortedDictionary<string, SdkInfo> sdkInfo = new SortedDictionary<string, SdkInfo> ();
// Async download operations tracked here.
private AmazonCoroutines.AmazonCoroutine coroutine;
private UnityWebRequest downloader;
private string activity;
// Custom style for LabelFields. (Don't make static or the dialog doesn't recover well from Unity compiling
// a new or changed editor script.)
private GUIStyle labelStyle;
private GUIStyle labelStyleArea;
private GUIStyle labelStyleLink;
private GUIStyle headerStyle;
private readonly GUILayoutOption fieldWidth = GUILayout.Width (60);
private Vector2 scrollPos;
public static void ShowSDKManager () {
var win = GetWindow<AmazonSDKManager> (true);
win.titleContent = new GUIContent ("Amazon SDK Manager");
win.Focus ();
}
void Awake () {
labelStyle = new GUIStyle (EditorStyles.label) {
fontSize = 14,
fontStyle = FontStyle.Bold
};
labelStyleArea = new GUIStyle (EditorStyles.label) {
wordWrap = true
};
labelStyleLink = new GUIStyle (EditorStyles.label) {
normal = { textColor = Color.blue },
active = { textColor = Color.white },
};
headerStyle = new GUIStyle (EditorStyles.label) {
fontSize = 12,
fontStyle = FontStyle.Bold,
fixedHeight = 18
};
CancelOperation ();
}
void OnEnable () {
coroutine = this.StartCoroutine (GetSDKVersions ());
}
void OnDisable () {
CancelOperation ();
}
public void deleteUnwantedFiles()
{
String[] filesToDel =
{
"Assets/Amazon/Scripts/Internal/AdResponce.cs",
"Assets/Amazon/Scripts/Internal/AdResponce.cs.meta",
"Assets/Amazon/Scripts/Internal/IOS/IOSAdResponce.cs",
"Assets/Amazon/Scripts/Internal/IOS/IOSAdResponce.cs.meta",
"Assets/Amazon/Scripts/Internal/Android/AndroidAdResponce.cs",
"Assets/Amazon/Scripts/Internal/Android/AndroidAdResponce.cs.meta",
"Assets/Amazon/Plugins/Android/aps-sdk.aar",
"Assets/Amazon/Plugins/Android/aps-sdk.aar.meta",
"Assets/Amazon/Scripts/Mediations/AdMobMediation/Plugins/Android/aps-admob-adapter.aar",
"Assets/Amazon/Scripts/Mediations/AdMobMediation/Plugins/Android/aps-admob-adapter.aar.meta",
"Assets/Amazon/Scripts/Mediations/APSConnectionUtil",
"Assets/Amazon/Scripts/Mediations/APSConnectionUtil.meta",
"Assets/Amazon/Scripts/Mediations/MoPubMediation",
"Assets/Amazon/Scripts/Mediations/MoPubMediation.meta",
"Assets/APSConnectionUtil",
"Assets/APSConnectionUtil.meta",
"Assets/Amazon/Sample/AmazonMoPubDemo.cs",
"Assets/Amazon/Sample/AmazonMoPubDemo.cs.meta",
"Assets/Amazon/Sample/APSMoPubMediation.unity",
"Assets/Amazon/Sample/APSMoPubMediation.unity.meta"
};
foreach (String fileToDel in filesToDel)
{
if (Directory.Exists(fileToDel))
{
Directory.Delete(fileToDel, true);
} else if (File.Exists(fileToDel))
{
File.Delete(fileToDel);
}
}
}
private IEnumerator GetSDKVersions () {
// Wait one frame so that we don't try to show the progress bar in the middle of OnGUI().
yield return null;
activity = "Downloading SDK version manifest...";
UnityWebRequest www = new UnityWebRequest (AmazonConstants.manifestURL) {
downloadHandler = new DownloadHandlerBuffer (),
timeout = 10, // seconds
};
yield return www.SendWebRequest ();
if (!string.IsNullOrEmpty (www.error)) {
Debug.LogError (www.error);
EditorUtility.DisplayDialog (
"SDK Manager Service",
"The services we need are not accessible. Please consider integrating manually.\n\n" +
"For instructions, see " + AmazonConstants.helpLink,
"OK");
}
var json = www.downloadHandler.text;
if (string.IsNullOrEmpty (json)) {
json = "{}";
Debug.LogError ("Unable to retrieve SDK version manifest. Showing installed SDKs only.");
}
www.Dispose ();
// Got the file. Now extract info on latest SDKs available.
amazonSdkInfo = new SdkInfo ();
sdkInfo.Clear ();
var dict = Json.Deserialize (json) as Dictionary<string, object>;
if (dict != null) {
object obj;
if (dict.TryGetValue ("sdk", out obj)) {
amazonSdkInfo.FromJson ("sdk", obj as Dictionary<string, object>);
amazonSdkInfo.CurrentVersion = AmazonConstants.VERSION;
}
if (dict.TryGetValue ("adapters", out obj)){
var info = new SdkInfo ();
foreach (var item in obj as Dictionary<string, object>) {
if (info.FromJson (item.Key, item.Value as Dictionary<string, object>))
sdkInfo[info.Key] = info;
}
}
}
var baseType = typeof(AmazonPackageConfig);
var configs = from t in Assembly.GetExecutingAssembly().GetTypes()
where t.IsSubclassOf(baseType) && !t.IsAbstract
select Activator.CreateInstance(t) as AmazonPackageConfig;
foreach (var config in configs) {
SdkInfo info;
sdkInfo.TryGetValue(config.Name, out info);
if (info.FromConfig(config) && info.Key != null)
sdkInfo[info.Key] = info;
}
coroutine = null;
deleteUnwantedFiles();
Repaint ();
}
void OnGUI () {
// Is any async job in progress?
var stillWorking = coroutine != null || downloader != null;
GUILayout.Space (5);
EditorGUILayout.LabelField ("Amazon SDKs", labelStyle, GUILayout.Height (20));
using (new EditorGUILayout.VerticalScope("box")) {
SdkHeaders();
SdkRow(amazonSdkInfo);
}
if (sdkInfo.Count > 0) {
GUILayout.Space (5);
EditorGUILayout.LabelField ("Mediated Networks", labelStyle, GUILayout.Height (20));
using (new EditorGUILayout.VerticalScope ("box"))
using (var s = new EditorGUILayout.ScrollViewScope (scrollPos, false, false)) {
scrollPos = s.scrollPosition;
SdkHeaders ();
foreach (var item in sdkInfo)
SdkRow (item.Value);
}
}
// Indicate async operation in progress.
using (new EditorGUILayout.HorizontalScope (GUILayout.ExpandWidth (false)))
EditorGUILayout.LabelField (stillWorking ? activity : " ");
using (new EditorGUILayout.HorizontalScope ()) {
GUILayout.Space (10);
if (!stillWorking) {
if (GUILayout.Button ("Done", fieldWidth))
Close ();
} else {
if (GUILayout.Button ("Cancel", fieldWidth))
CancelOperation ();
}
if (GUILayout.Button ("Help", fieldWidth))
Application.OpenURL (AmazonConstants.helpLink);
}
}
private void SdkHeaders () {
using (new EditorGUILayout.HorizontalScope (GUILayout.ExpandWidth (false))) {
GUILayout.Space (10);
EditorGUILayout.LabelField ("Package", headerStyle);
GUILayout.Button ("Version", headerStyle);
GUILayout.Space (3);
GUILayout.Button ("Action", headerStyle, fieldWidth);
GUILayout.Button (" ", headerStyle, GUILayout.Width (1));
GUILayout.Space (5);
}
GUILayout.Space (4);
}
private void SdkRow (SdkInfo info, Func<bool, bool> customButton = null) {
var lat = info.LatestVersion;
var cur = info.CurrentVersion;
var isInst = !string.IsNullOrEmpty (cur);
var canInst = !string.IsNullOrEmpty (lat) && (!isInst || AmazonUtils.CompareVersions (cur, lat) < 0);
// Is any async job in progress?
var stillWorking = coroutine != null || downloader != null;
string tooltip = string.Empty;
if (isInst && (AmazonUtils.CompareVersions (cur, lat) != 0))
tooltip += "\n Installed: " + cur;
if (!string.IsNullOrEmpty (tooltip))
tooltip = info.Name + "\n Package: " + (lat ?? "n/a") + tooltip;
GUILayout.Space (4);
using (new EditorGUILayout.HorizontalScope (GUILayout.ExpandWidth (false))) {
GUILayout.Space (10);
EditorGUILayout.LabelField (new GUIContent { text = info.Name, tooltip = tooltip });
GUILayout.Button (new GUIContent {
text = lat ?? "--",
tooltip = tooltip
}, canInst ? EditorStyles.boldLabel : EditorStyles.label);
GUILayout.Space (3);
if (customButton == null || !customButton (canInst)) {
GUI.enabled = !stillWorking && (canInst);
if (GUILayout.Button (new GUIContent {
text = isInst ? "Upgrade" : "Install",
tooltip = tooltip
}, fieldWidth))
this.StartCoroutine (DownloadSDK (info));
GUI.enabled = true;
}
// Need to fill space so that the Install/Upgrade buttons all line up nicely.
GUILayout.Button (" ", EditorStyles.label, GUILayout.Width (17));
GUILayout.Space (5);
}
GUILayout.Space (4);
}
private void CancelOperation () {
// Stop any async action taking place.
if (downloader != null) {
downloader.Abort (); // The coroutine should resume and clean up.
return;
}
if (coroutine != null)
this.StopCoroutine (coroutine.routine);
coroutine = null;
downloader = null;
}
private IEnumerator DownloadSDK (SdkInfo info) {
var path = Path.Combine (downloadDir, info.Filename);
activity = string.Format ("Downloading {0}...", info.Filename);
Debug.Log (activity);
// Start the async download job.
downloader = new UnityWebRequest (info.Url) {
downloadHandler = new DownloadHandlerFile (path),
timeout = 60, // seconds
};
downloader.SendWebRequest ();
// Pause until download done/cancelled/fails, keeping progress bar up to date.
while (!downloader.isDone) {
yield return null;
var progress = Mathf.FloorToInt (downloader.downloadProgress * 100);
if (EditorUtility.DisplayCancelableProgressBar ("Amazon SDK Manager", activity, progress))
downloader.Abort ();
}
EditorUtility.ClearProgressBar ();
if (string.IsNullOrEmpty (downloader.error))
AssetDatabase.ImportPackage (path, true); // OK, got the file, so let the user import it if they want.
else {
var error = downloader.error;
if (downloader.isNetworkError) {
if (error.EndsWith ("destination host"))
error += ": " + info.Url;
} else if (downloader.isHttpError) {
switch (downloader.responseCode) {
case 404:
var file = Path.GetFileName (new Uri (info.Url).LocalPath);
error = string.Format ("File {0} not found on server.", file);
break;
default:
error = downloader.responseCode + "\n" + error;
break;
}
}
Debug.LogError (error);
}
// Reset async state so the GUI is operational again.
downloader.Dispose ();
downloader = null;
coroutine = null;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9436cb85e61464fbb8e7434090ec1af2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e64d0b097e7e04e59b22cd2d61ff42a5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,41 @@
using System;
using NUnit.Framework;
using UnityEngine;
// ReSharper disable Unity.IncorrectMonoBehaviourInstantiation
namespace Tests
{
public class AmazonSDKTests : AmazonTest
{
[Test]
public void EmitAdLoadedEventShouldTriggerOnAdLoadedEvent()
{
TestEmitAdLoadedEvent(new AmazonAds.Android.AndroidAdResponse());
}
private static void TestEmitAdLoadedEvent(AmazonAds.AdResponse response)
{
const string successMessage = "OnAdLoadedEvent triggered.";
AmazonAds.Amazon.OnSuccessDelegate successHandler = (_response) => {
Assert.That(_response, Is.EqualTo(response));
Debug.Log(successMessage);
};
const string failureMessage = "OnAdFailedEvent triggered.";
AmazonAds.Amazon.OnFailureDelegate failureHandler = (_error) => {
Debug.Log(failureMessage);
};
try {
successHandler.Invoke(response);
failureHandler.Invoke("123");
} finally {
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b00fb31f302f4b26a43151fd12cffbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using UnityEngine;
using UnityEngine.TestTools;
public class AmazonTest
{
public static class LogAssert
{
public static void Expect(LogType logType, string message)
{
UnityEngine.TestTools.LogAssert.Expect(logType, message);
Debug.LogFormat("The previous {0} log was expected.", logType);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe3a64de565fa4daa9ac26c80cdb1f6e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
using NUnit.Framework;
using UnityEngine;
namespace Tests
{
public class AmazonUtilsTests : AmazonTest
{
[Test]
public void CompareVersionsWithFirstSmaller()
{
Assert.That(AmazonUtils.CompareVersions("0", "1"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("0.9", "1.0"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("0.9.99", "1.0.0"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("0.9.99", "0.10.0"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("0.9.99", "0.9.100"), Is.EqualTo(-1));
}
[Test]
public void CompareVersionsWithFirstGreater()
{
Assert.That(AmazonUtils.CompareVersions("1", "0"), Is.EqualTo(1));
Assert.That(AmazonUtils.CompareVersions("1.0", "0.9"), Is.EqualTo(1));
Assert.That(AmazonUtils.CompareVersions("1.0.0", "0.9.99"), Is.EqualTo(1));
Assert.That(AmazonUtils.CompareVersions("0.10.0", "0.9.99"), Is.EqualTo(1));
Assert.That(AmazonUtils.CompareVersions("0.9.100", "0.9.99"), Is.EqualTo(1));
}
[Test]
public void CompareVersionsWithEqual()
{
Assert.That(AmazonUtils.CompareVersions("1", "1"), Is.EqualTo(0));
Assert.That(AmazonUtils.CompareVersions("1.0", "1.0"), Is.EqualTo(0));
Assert.That(AmazonUtils.CompareVersions("1.0.0", "1.0.0"), Is.EqualTo(0));
}
[Test]
public void CompareVersionsWithEmptyValues()
{
Assert.That(AmazonUtils.CompareVersions("", ""), Is.EqualTo(0));
Assert.That(AmazonUtils.CompareVersions("", "1"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("1", ""), Is.EqualTo(1));
Assert.That(AmazonUtils.CompareVersions(null, null), Is.EqualTo(0));
Assert.That(AmazonUtils.CompareVersions(null, "1"), Is.EqualTo(-1));
Assert.That(AmazonUtils.CompareVersions("1", null), Is.EqualTo(1));
}
[Test]
public void DecodeArgsWithNullShouldErrorAndYieldEmptyList()
{
var res = AmazonUtils.DecodeArgs(null, 0);
LogAssert.Expect(LogType.Error, "Invalid JSON data: ");
Assert.That(res, Is.Not.Null);
Assert.That(res.Length, Is.EqualTo(0));
}
[Test]
public void DecodeArgsWithInvalidShouldErrorAndYieldEmptyList()
{
var res = AmazonUtils.DecodeArgs("{\"a\"]", 0);
LogAssert.Expect(LogType.Error, "Invalid JSON data: {\"a\"]");
Assert.That(res, Is.Not.Null);
Assert.That(res.Length, Is.EqualTo(0));
}
[Test]
public void DecodeArgsWithValueShouldYieldListWithValue()
{
var res = AmazonUtils.DecodeArgs("[\"a\"]", 0);
Assert.That(res, Is.Not.Null);
Assert.That(res.Length, Is.EqualTo(1));
Assert.That(res[0], Is.EqualTo("a"));
}
[Test]
public void DecodeArgsWithoutMinimumValuesShouldErrorAndYieldListWithDesiredLength()
{
var res = AmazonUtils.DecodeArgs("[\"a\", \"b\"]", 3);
LogAssert.Expect(LogType.Error, "Missing one or more values: [\"a\", \"b\"] (expected 3)");
Assert.That(res, Is.Not.Null);
Assert.That(res.Length, Is.EqualTo(3));
Assert.That(res[0], Is.EqualTo("a"));
Assert.That(res[1], Is.EqualTo("b"));
Assert.That(res[2], Is.EqualTo(""));
}
[Test]
public void DecodeArgsWithExpectedValuesShouldYieldListWithDesiredValues()
{
var res = AmazonUtils.DecodeArgs("[\"a\", \"b\", \"c\"]", 3);
Assert.That(res, Is.Not.Null);
Assert.That(res.Length, Is.EqualTo(3));
Assert.That(res[0], Is.EqualTo("a"));
Assert.That(res[1], Is.EqualTo("b"));
Assert.That(res[2], Is.EqualTo("c"));
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4a38f41a15b0444380ccd4a74a12ac2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3eac84282b79049f0bbadc32296d7b29
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
namespace AmazonAds {
public class APSAdDelegate {
public delegate void OnAdLoaded ();
public delegate void OnAdFailed ();
public delegate void OnAdClicked ();
public delegate void OnAdOpen ();
public delegate void OnAdClosed ();
public delegate void OnImpressionFired ();
public delegate void OnVideoCompleted ();
public OnAdLoaded onAdLoaded = OnAdLoadedImpl;
public OnAdFailed onAdFailed = OnAdFailedImpl;
public OnAdClicked onAdClicked = OnAdClickedImpl;
public OnAdOpen onAdOpen = OnAdOpenImpl;
public OnAdClosed onAdClosed = OnAdClosedImpl;
public OnImpressionFired onImpressionFired = OnImpressionFiredImpl;
public OnVideoCompleted onVideoCompleted = OnVideoCompletedImpl;
public APSAdDelegate () {
}
private static void OnAdLoadedImpl () { }
private static void OnAdFailedImpl () { }
private static void OnAdClickedImpl () { }
private static void OnAdOpenImpl () { }
private static void OnAdClosedImpl () { }
private static void OnImpressionFiredImpl () { }
private static void OnVideoCompletedImpl () { }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d06f90422ce794d848656240f4d00aae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,88 @@
namespace AmazonAds {
public class APSBannerAdRequest : AdRequest {
public APSBannerAdRequest () : base() {
Amazon.OnApplicationPause += OnApplicationPause;
}
public APSBannerAdRequest (string slotGroupName) : base() {
Amazon.OnApplicationPause += OnApplicationPause;
client.SetSlotGroup (slotGroupName);
}
public APSBannerAdRequest (int width, int height, string uid) : base() {
Amazon.OnApplicationPause += OnApplicationPause;
AdSize size = new AdSize (width, height, uid);
client.SetSizes (size.GetInstance ());
}
public APSBannerAdRequest (AdSize size) {
Amazon.OnApplicationPause += OnApplicationPause;
client.SetSizes (size.GetInstance ());
}
public void LoadSmartBanner () {
if (onSuccess != null && onFailed != null) {
client.LoadSmartBanner (onFailed, onSuccess);
} else if (onSuccess != null && onFailedWithError != null) {
client.LoadSmartBanner (onFailedWithError, onSuccess);
}
}
public void SetSizes (int width, int height, string uid) {
AdSize size = new AdSize (width, height, uid);
SetSizes (size);
}
public void SetSizes (AdSize size) {
client.SetSizes (size.GetInstance ());
}
public void SetSlotGroup (string slotGroupName) {
client.SetSlotGroup (slotGroupName);
}
public void SetAutoRefreshAdMob (bool flag, bool isSmartBanner = false) {
client.SetAutoRefreshAdMob (flag, isSmartBanner);
}
public void SetAutoRefreshMoPub (bool flag, int refreshTime) {
client.SetAutoRefreshMoPub (flag, refreshTime);
}
public void DisposeAd () {
client.DisposeAd ();
}
public void IsAutoRefreshAdMob () {
client.IsAutoRefreshAdMob ();
}
public void IsAutoRefreshMoPub () {
client.IsAutoRefreshMoPub ();
}
public string AutoRefreshID () {
return client.AutoRefreshID ();
}
public void CreateFetchManager (bool isSmartBanner = false) {
client.CreateFetchManager (isSmartBanner);
}
public void DestroyFetchManager () {
client.DestroyFetchManager ();
}
public void OnApplicationPause (bool isPaused) {
if (isPaused) {
if( client.IsAutoRefreshAdMob() ){
client.StopFetchManager();
}
} else {
if( client.IsAutoRefreshAdMob() ){
client.StartFetchManager();
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 62abdd252c1aa49beb917ca0a7b4d3b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
namespace AmazonAds {
public class APSInterstitialAdRequest : AdRequest {
public APSInterstitialAdRequest (string uid) {
AdSize.InterstitialAdSize size = new AdSize.InterstitialAdSize (uid);
client.SetSizes (size.GetInstance ());
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a60589c70736841a6b26fa39087d8e98
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,41 @@
using System;
using UnityEngine;
namespace AmazonAds {
public class APSMediationUtils
{
public static string APS_IRON_SOURCE_NETWORK_KEY = "APS";
public static string GetInterstitialNetworkData(string amazonSlotId, string bidInfo, string pricePoint)
{
APSIronSourceNetworkBaseInputData ironSourceInputData = new APSIronSourceNetworkBaseInputData();
ironSourceInputData.bidInfo = bidInfo;
ironSourceInputData.pricePointEncoded = pricePoint;
ironSourceInputData.uuid = amazonSlotId;
APSIronSourceInterstitialNetworkData networkData = new APSIronSourceInterstitialNetworkData();
networkData.interstitial = ironSourceInputData;
string jsonData = "{ \"interstitial\" :" + JsonUtility.ToJson(ironSourceInputData) + "}";
return jsonData;
//return JsonUtility.ToJson(networkData);
}
public class APSIronSourceNetworkBaseInputData
{
public string bidInfo;
public string pricePointEncoded;
public string uuid;
}
public class APSIronSourceInterstitialNetworkData
{
public APSIronSourceNetworkBaseInputData interstitial;
}
private APSMediationUtils()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a9a84a300e9084005845d7561b5941de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
namespace AmazonAds {
public class APSVideoAdRequest : AdRequest {
public APSVideoAdRequest (int width, int height, string uid) {
AdSize.Video size = new AdSize.Video (width, height, uid);
client.SetSizes (size.GetInstance ());
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f887445d62a094bdcaeba6843c76de52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmazonAds {
public class AdError {
private int errorCode;
private String errorMessage;
private AdRequest adLoader;
private AndroidJavaObject adError;
private IntPtr adErrorPtr;
public AdError(int code, String message) {
errorCode = code;
errorMessage = message;
}
public int GetCode () {
return errorCode;
}
public String GetMessage() {
return errorMessage;
}
public AdRequest GetAdLoader() {
return adLoader;
}
#if UNITY_ANDROID
public AndroidJavaObject GetAdError() {
return adError;
}
#else
public IntPtr GetAdError()
{
return adErrorPtr;
}
#endif
public IntPtr GetInstance() {
return adErrorPtr;
}
internal void SetAdLoader(AdRequest adRequest) {
adLoader = adRequest;
}
internal void SetAdError(AndroidJavaObject error) {
adError = error;
}
internal void SetInstance(IntPtr inPtr) {
adErrorPtr = inPtr;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56cbe6c6e32004910b2c76cefbf4e0c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
namespace AmazonAds {
public class AdInterstitial {
internal IAdInterstitial adInterstital;
public AdInterstitial (APSAdDelegate delegates) {
#if UNITY_ANDROID
adInterstital = new Android.AndroidAdInterstitial(delegates);
#elif UNITY_IOS
adInterstital = new IOS.IOSAdInterstitial(delegates);
#else
//Other platforms not supported
#endif
}
public void FetchAd (AdResponse adResponse) {
adInterstital.FetchAd(adResponse);
}
public void Show () {
adInterstital.Show();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b6b4a1dc9a6eb4aac89ddfeb50a829a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
using System;
namespace AmazonAds {
public enum DTBAdNetwork {
GOOGLE_AD_MANAGER,
MOPUB_AD_SERVER,
ADMOB,
AD_GENERATION,
IRON_SOURCE,
MAX,
NIMBUS,
OTHER
}
public class AdNetworkInfo {
private DTBAdNetwork adNetwork;
public AdNetworkInfo(DTBAdNetwork dtbAdNetwork) {
adNetwork = dtbAdNetwork;
}
public String getAdNetworkName() {
return adNetwork.ToString();
}
internal DTBAdNetwork getAdNetwork() {
return adNetwork;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86929efe844004ce4a245fed201d6f9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,59 @@
using UnityEngine;
namespace AmazonAds {
public class AdRequest {
internal IAdRequest client;
public Amazon.OnFailureDelegate onFailed;
public Amazon.OnFailureWithErrorDelegate onFailedWithError;
public Amazon.OnSuccessDelegate onSuccess;
public AdRequest () {
#if UNITY_ANDROID
client = new Android.DTBAdRequest ();
#elif UNITY_IOS
client = new IOS.DTBAdRequest ();
#else
//Other platforms not supported
#endif
}
public AdRequest (IAdRequest adRequest) {
client = adRequest;
}
public void PutCustomTarget (string key, string value) {
client.PutCustomTarget (key, value);
}
public void SetRefreshFlag (bool flag) {
client.SetRefreshFlag(flag);
}
public void SetAutoRefresh() {
client.SetAutoRefresh();
}
public void SetAutoRefresh(int secs) {
client.SetAutoRefresh(secs);
}
public void ResumeAutoRefresh() {
client.ResumeAutoRefresh();
}
public void StopAutoRefresh() {
client.StopAutoRefresh();
}
public void PauseAutoRefresh() {
client.PauseAutoRefresh();
}
public void LoadAd () {
if (onSuccess != null && onFailed != null) {
client.LoadAd (onFailed, onSuccess);
} else if (onSuccess != null && onFailedWithError != null) {
client.LoadAd (onFailedWithError, onSuccess);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 470ce0a8c403f4531ac94b5ebe2ea5f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,4 @@
namespace AmazonAds {
public abstract class AdResponseObsolete {
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07d84938416874bbb97e941098b24279
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmazonAds {
public abstract class AdResponse {
public abstract String GetMoPubKeywords ();
public abstract IntPtr GetInstance();
public abstract Dictionary<String, String> GetRendering (bool isSmartBanner = false, string fetchLabel = null);
public abstract AdRequest GetAdLoader();
public abstract String GetBidInfo();
public abstract String GetPricePoint();
public abstract int GetWidth();
public abstract int GetHeight();
public abstract String GetMediationHints(bool isSmartBanner = false);
internal abstract void SetAdLoader(AdRequest adRequest);
public abstract IntPtr GetIosResponseObject();
public abstract AndroidJavaObject GetAndroidResponseObject();
#if UNITY_ANDROID
public abstract AndroidJavaObject GetResponse();
#else
public abstract IntPtr GetResponse();
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 80115d4cd111a4902804a0557a637367
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
using System;
namespace AmazonAds {
public class AdSize {
IAdSize client;
public AdSize (int width, int height, String slotUID) {
#if UNITY_ANDROID
client = new Android.DTBAdSize (width, height, slotUID);
#elif UNITY_IOS
client = new IOS.DTBAdSize (width, height, slotUID);
#endif
}
public IAdSize GetInstance () {
return client;
}
public class InterstitialAdSize {
IInterstitialAdSize client;
public InterstitialAdSize (String slotUID) {
#if UNITY_ANDROID
client = new Android.DTBAdSize.DTBInterstitialAdSize (slotUID);
#elif UNITY_IOS
client = new IOS.DTBAdSize.DTBInterstitialAdSize (slotUID);
#endif
}
public IInterstitialAdSize GetInstance () {
return client;
}
}
public class Video {
IVideo client;
public Video (int playerWidth, int playerHeight, String slotUUID) {
#if UNITY_ANDROID
client = new Android.DTBAdSize.DTBVideo (playerWidth, playerHeight, slotUUID);
#elif UNITY_IOS
client = new IOS.DTBAdSize.DTBVideo (playerWidth, playerHeight, slotUUID);
#endif
}
public IVideo GetInstance () {
return client;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6669e9284e4b5497fb351ae7bcb28436
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace AmazonAds {
public class AdView {
internal IAdView adView;
public AdView (AdSize adSize, APSAdDelegate delegates) {
#if UNITY_ANDROID
adView = new Android.AndroidAdView(delegates);
#elif UNITY_IOS
adView = new IOS.IOSAdView(adSize, delegates);
#else
//Other platforms not supported
#endif
}
public void fetchAd (AdResponse adResponse) {
adView.FetchAd(adResponse);
}
}
}

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