-
Notifications
You must be signed in to change notification settings - Fork 46
iOS CustomEvent
AdTiming edited this page Apr 3, 2020
·
1 revision
OpenMediation SDK支持自定义接入AdNetwork,通过实现AdNetwork的CustomEvent,使其能被SDK聚合。
AdTiming;
AdMob;
Facebook;
Unity;
Vungle;
AdColony;
AppLovin;
Tapjoy;
Chartboost;
TikTok;
Mintegral;
为了实现对CustomEvent的支持,请按照以下步骤的指导完成对接
在您项目中创建OMxxxAdapter类实现OMMediationAdapter协议,xxx为AdNetwork的name
@interface OMxxxAdapter : NSObject<OMMediationAdapter>
@end
重写+ (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler;configuration包含appkey以及为该App配置的所有广告位。 使用此信息初始化您的广告网络SDK。 初始化广告网络SDK后,请调用OMMediationAdapterInitCompletionBlock参数。 通过使用nil或NSError对象调用完成处理程序,此block使您可以向OpenMediation SDK报告初始化成功或失败的情况
+ (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler;
- 在您项目中创建OMxxxRewardedVideo类实现OMRewardedVideoCustomEvent协议,xxx为AdNetwork的name
@interface OMxxxRewardedVideo : NSObject<OMRewardedVideoCustomEvent>
@end
- 重写
- (instancetype)initWithParameter:(NSDictionary*)adParameter方法实现广告初始化
- (instancetype)initWithParameter:(NSDictionary*)adParameter;
- 重写
- (void)loadAd方法实现请求广告
- (void)loadAd;
- 重写
- (BOOL)isReady方法实现检查可用广告
- (BOOL)isReady;
- 重写
- (void)show:(UIViewController*)vc方法实现展示广告
- (void)show:(UIViewController*)vc;
- 监听AdNetWork的广告生命周期事件,通过delegate通知OpenMediation该事件
@protocol RewardedVideoCustomEventDelegate<OMCustomEventDelegate>
///tell the delegate when your ad ad loads successfully
- (void)customEvent:(id)adapter didLoadAd:(nullable id)adObject;
///tell the delegate when your ad fails to load
- (void)customEvent:(id)adapter didFailToLoadWithError:(NSError*)error;
///tell the delegate when your ad will be displayed
- (void)rewardedVideoCustomEventDidOpen:(id<OMRewardedVideoCustomEvent>)adapter;
///Notifies OpenMediation that ad show failed
- (void)rewardedVideoCustomEventDidFailToShow:(id<OMRewardedVideoCustomEvent>)adapter withError:(NSError*)error;
///Notifies OpenMediation that a rewarded ad started playing
- (void)rewardedVideoCustomEventVideoStart:(id<OMRewardedVideoCustomEvent>)adapter;
///tell the delegate when your rewarded ad finished playing
- (void)rewardedVideoCustomEventVideoEnd:(id<OMRewardedVideoCustomEvent>)adapter;
///tell the delegate when your ad has been clicked
- (void)rewardedVideoCustomEventDidClick:(id<OMRewardedVideoCustomEvent>)adapter;
///tell the delegate when your user has earned a reward
- (void)rewardedVideoCustomEventDidReceiveReward:(id<OMRewardedVideoCustomEvent>)adapter;
///tell the delegate when your ad has been dismissed
- (void)rewardedVideoCustomEventDidClose:(id<OMRewardedVideoCustomEvent>)adapter;
@end
- 在您项目中创建OMxxxInterstitial类实现OMInterstitialCustomEvent协议,xxx为AdNetwork的name
@interface OMxxxInterstitial : NSObject<OMInterstitialCustomEvent>
@end
- 重写
- (instancetype)initWithParameter:(NSDictionary*)adParameter方法实现广告初始化
- (instancetype)initWithParameter:(NSDictionary*)adParameter;
- 重写
- (void)loadAd方法实现请求广告
- (void)loadAd;
- 重写
- (BOOL)isReady方法实现检查可用广告
- (BOOL)isReady;
- 重写
- (void)show:(UIViewController*)vc方法实现展示广告
- (void)show:(UIViewController*)vc;
- 监听AdNetWork的广告生命周期事件,通过delegate通知OpenMediation该事件
@protocol interstitialCustomEventDelegate<OMCustomEventDelegate>
///tell the delegate when your ad ad loads successfully
- (void)customEvent:(id)adapter didLoadAd:(nullable id)adObject;
///tell the delegate when your ad fails to load
- (void)customEvent:(id)adapter didFailToLoadWithError:(NSError*)error;
///tell the delegate when your ad will be Opened
- (void)interstitialCustomEventDidOpen:(id<OMInterstitialCustomEvent>)adapter;
///tell the delegate when your ad will be displayed
- (void)interstitialCustomEventDidShow:(id<OMInterstitialCustomEvent>)adapter;
///Notifies OpenMediation that ad show failed
- (void)interstitialCustomEventDidFailToShow:(id<OMInterstitialCustomEvent>)adapter error:(NSError*)error;
///tell the delegate when your ad has been clicked
- (void)interstitialCustomEventDidClick:(id<OMInterstitialCustomEvent>)adapter;
///tell the delegate when your ad has been dismissed
- (void)interstitialCustomEventDidClose:(id<OMInterstitialCustomEvent>)adapter;
@end
- 在您项目中创建OMxxxNative类实现OMNativeCustomEvent协议,xxx为AdNetwork的name
@interface OMxxxNative : NSObject<OMNativeCustomEvent>
@end
- 重写
- (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewController*)rootViewController方法实现广告初始化
- (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewController*)rootViewController;
- 重写
- (void)loadAd方法实现请求广告
- (void)loadAd;
-
广告成功加载后,创建一个符合OMMediatedNativeAd协议的对象,并通过
- (void)customEvent:(id)adapter didLoadAd:(nullable id)adObject方法通知OpenMediation该事件 -
监听AdNetWork的广告生命周期事件,通过delegate通知OpenMediation该事件 广告返回时,您需要使用adObject对象创建一个符合OMMediatedNativeAd协议的相应对象
@protocol nativeCustomEventDelegate<OMCustomEventDelegate>
///tell the delegate when your ad ad loads successfully
- (void)customEvent:(id)adapter didLoadAd:(nullable id)adObject;
///tell the delegate when your ad fails to load
- (void)customEvent:(id)adapter didFailToLoadWithError:(NSError*)error;
///tell the delegate when your ad will be displayed
- (void)nativeCustomEventWillShow:(id<OMNativeCustomEvent>)adapter;;
///tell the delegate when your ad has been clicked
- (void)nativeCustomEventDidClick:(id<OMNativeCustomEvent>)adapter;
@end
- 在您项目中创建OMxxxNativeView类实现OMNativeViewCustomEvent协议,xxx为AdNetwork的name
- (instancetype)initWithFrame:(CGRect)frame;
- (void)setNativeAd:(id<OMMediatedNativeAd>)nativeAd;
- (void)setMediaViewWithFrame:(CGRect)frame;
- (UIView*)mediaView;
- 在您项目中创建OMxxxBanner类实现OMBannerCustomEvent协议,xxx为AdNetwork的name
@interface OMxxxBanner : NSObject<OMBannerCustomEvent>
@end
- 重写
- (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController方法实现广告初始化
- (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController;
- 重写
- (void)loadAd方法实现请求广告
- (void)loadAd;
- 监听AdNetWork的广告生命周期事件,通过delegate通知OpenMediation该事件
@protocol bannerCustomEventDelegate<OMCustomEventDelegate>
///tell the delegate when your ad ad loads successfully
- (void)customEvent:(id)adapter didLoadAd:(nullable id)adObject;
///tell the delegate when your ad fails to load
- (void)customEvent:(id)adapter didFailToLoadWithError:(NSError*)error;
///tell the delegate when your ad has been clicked
- (void)bannerCustomEventDidClick:(id<OMBannerCustomEvent>)adapter;
///tell the delegate that a full-screen view will be presente
- (void)bannerCustomEventWillPresentScreen:(id<OMBannerCustomEvent>)adapter;
///tell the delegate that the full-screen view will be dismissed.
- (void)bannerCustomEventDismissScreen:(id<OMBannerCustomEvent>)adapter;
///tell the delegate that a user click will open another app
- (void)bannerCustomEventWillLeaveApplication:(id<OMBannerCustomEvent>)adapter;
@end