iOS: Vdopia SDK w/ Monkey
Monkey Forums/Monkey Code/iOS: Vdopia SDK w/ Monkey
| ||
Native iOS Code: NOTE: The Vdopia SDK can serve banner ads, but this code is for fullscreen in-app video & interstitial ads only NOTE: There is no harm calling '*_Init' during resumes and/or "*_UnInit" during suspends /* ** Network_Vdopia.cpp */ #import "VDOAds.h" @class _VdopiaDelegate; static bool _vdopia_isFullscreen; static _VdopiaDelegate* _vdopia_adDelegate; @interface _VdopiaDelegate : NSObject <VDOAdsDelegate> { VDOAds *vdoAds; } - (bool) inAppAvailable; - (void) playInApp; @end @implementation _VdopiaDelegate - (id) initWithAPIKey:(String)APIKey { if( (self = [super init]) ) { vdoAds = [VDOAds alloc]; vdoAds.delegate = self; [vdoAds openWithAppKey:APIKey.ToNSString() useLocation:false withFrame:CGRectNull startWithBanners:false]; } return self; } - (void) dealloc { [vdoAds close]; vdoAds.delegate = nil; [vdoAds release]; [super dealloc]; } - (bool) inAppAvailable { return [vdoAds isInAppAvailable]; } - (void) playInApp { _vdopia_isFullscreen = true; [vdoAds playInApp]; } - (void) playedVDOAd { printf( "%s\n", __func__ ); _vdopia_isFullscreen = false; } - (void) noVDOAd { printf( "%s\n", __func__ ); } - (void) playedInApp { printf( "%s\n", __func__ ); _vdopia_isFullscreen = false; } - (void) noInApp { printf( "%s\n", __func__ ); } @end void Vdopia_Init( String APIKey ) { printf( "%s\n", __func__ ); if( !_vdopia_adDelegate ) { _vdopia_adDelegate = [[_VdopiaDelegate alloc] initWithAPIKey:APIKey]; } } void Vdopia_UnInit() { printf( "%s\n", __func__ ); if( _vdopia_adDelegate ) { [_vdopia_adDelegate release]; _vdopia_adDelegate = nil; } } bool Vdopia_RequestAd() { printf( "%s -> ", __func__ ); if( _vdopia_adDelegate ) { if( [_vdopia_adDelegate inAppAvailable] ) { [_vdopia_adDelegate playInApp]; printf( "Ok.\n" ); return true; } } printf( "Not Available.\n" ); return false; } bool Vdopia_IsFullscreen() { return _vdopia_isFullscreen; } Monkey Interface: 'vdopia.monkey Private Import "vdopia.cpp" Extern Function Vdopia_Init:Void( APIKey$ ) Function Vdopia_UnInit:Void() Function Vdopia_RequestAd?() Function Vdopia_IsFullscreen?() Usage: 'main.monkey Import vdopia Function Main() Vdopia_Init( "app-key-here" ) Vdopia_RequestAd '<-- will very likely return false (no-ad-ready) because the SDK has not had time to buffer ad End Enjoy! |