Before You Start
Before integrating ads unit in your app, you must:
- In the OpenMediation UI, create an app and create an ad placement. You can follow guides here.
- Follow our steps to iOS SDK Integration by integrating the OpenMediation SDK into your project.
- If you use mediation, go to Add Mediation Networks and make sure you have added the ad networks' SDKs and the corresponding adapters you wish to work with in your app.
Splash
Step 1. Initialize Splash Ad
The OpenMediation SDK fires several events to inform you of Splash Ad activity. To display Splash Ads, one needs to create a brand new OMSplash object, set up its Delegate and load the ads.
Create OMSplash Object
The following snippet demonstrates how to use the OMSplash class to create Splash objects and implement the OMSplashDelegate interface to receive Splash Ad events. The SDK will notify the Delegate of all possible events listed below:
@property (nonatomic, strong) OMSplash *splash;
- (void)viewDidLoad {
self.splash = [[OMSplash alloc] initWithPlacementId:@"YOUR_PLACEMENT_ID" adSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height)];
self.splash.delegate = self;
}
private lazy var splash: OMSplash = {
let splash = OMSplash(placementID: "YOUR_PLACEMENT_ID" adSize: self.view.frame.size)
splash.delegate = self
return splash
}()
Splash Delegate (OMSplashDelegate)
Implement the following callback functions in your code to process ad logic when receiving the status of your ad. For example invoke Show function to serve Ad to your users when the Splash Ad is ready.
The methods declared by the OMSplashDelegate protocol allow the adopting delegate to respond to messages from the OMSplash class and thus respond to operations such as whether the ad has been loaded, or the user has clicked the ad.
/// Invoked when the splash ad is available.
- (void)omSplashDidLoad:(OMSplash *)splash {
NSLog(@"SplashAd Did Load");
}
/// Invoked when the call to load a splash has failed.
/// Parameter error contains the reason for the failure.
- (void)omSplashFailToLoad:(OMSplash *)splash withError:(NSError *)error {
NSLog(@"SplashAd Did Load Fail");
}
/// Invoked when the splash ad is showing.
- (void)omSplashDidShow:(OMSplash *)splash {
NSLog(@"SplashAd Did Show");
}
/// Invoked when the user clicks on the splash ad.
- (void)omSplashDidClick:(OMSplash *)splash {
NSLog(@"SplashAd Did Click");
}
/// Invoked when the splash ad has been closed.
- (void)omSplashDidClose:(OMSplash *)splash {
NSLog(@"SplashAd Did Close");
}
/// Invoked when the splash ad show failed.
- (void)omSplashDidFailToShow:(OMSplash *)splash withError:(NSError *)error {
NSLog(@"SplashAd Did Show fail");
}
/// Invoked when the splash ad is available.
func omSplashDidLoad:(_ splash: OMSplash) {
print("SplashAd Did Load")
}
/// Invoked when the call to load a splash has failed.
/// Parameter error contains the reason for the failure.
func omSplashDidFail:(toLoad splash: OMSplash, withError error: Error) {
print("SplashAd Did Fail")
}
/// Invoked when the splash ad is shown.
func omSplashDidShow:(_ splash: OMSplash) {
print(@"SplashAd Did Show")
}
/// Invoked when the splash ad is shown fail.
func omSplashDidFail:(toShow splash: OMSplash, withError error: Error) {
print(@"SplashAd Did Show fail")
}
/// Invoked when the user clicks on the splash ad.
func omSplashDidClick(_ splash: OMSplash) {
print("SplashAd Did Click")
}
/// Invoked when the splash ad has been closed.
func omSplashDidClose(_ splash: OMSplash) {
print(@"SplashAd Did Close")
}
Step 2. Load a Splash Ad
Invoke the following method to request a splash ad to your users:
Invoke the following method to serve a splash ad to your users:
[self.splash showWithWindow:[UIApplication sharedApplication].keyWindow customView:nil];
self.splash.show(with:"WINDOW" customView:"CUSTOM_VIEW")
Comments
Article is closed for comments.