Omni Unit Ads
Omni ads are a brand new ad unit type that gives our SDK publishers an entirely incremental revenue stream. Omni ads are unobtrusive videos and rich media creatives that float on top of your app content. You can customize where and when the omni ad is displayed to ensure that it doesn’t negatively impact user experience or cover important UI controls.
Prerequisites
- Follow the initial integration guide for iOS
- Ensure that you have an Omni Ad Placement ID to use
Display an Omni ad in your app
Displaying an omni ad is a two-step process. First you should create and load your MFOmniAd
unit, then when you’re ready, call the showAd
method to display the ad.
- Create an Omni ad unit
- Display the ad
Create an Omni ad unit
The MFOmniAd
class provided by the MobileFuse SDK will handle the loading, display and interactivity of the omni ad. It is similar in implementation to MobileFuse interstitial ads.
First, create a new MFOmniAd
unit and keep a reference to it. We’ll also add it to our current view.
MFOmniAd *omniAd;
- (void)createOmniAd {
// UI on main thread
dispatch_async(dispatch_get_main_queue(), ^ {
omniAd = [[MFOmniAd alloc] initWithPlacementId:@"000000"];
// Optionally register ourselves as a callback receiver (if we've implemented
// IMFAdCallbackReceiver)
[omniAd registerAdCallbackReceiver:self];
[omniAd loadAd];
});
}
Note
Ensure that the SDK has fully initialized before creating your ad units. You can use the
onInitSuccess
callback as a good place to set up your ad units.
Next, add a listener - the listener will allow you to receive events from the ad unit. The omni ad has some additional callbacks for omni ad specific events.
[omniAd registerAdCallbackReceiver: self];
-(void) onAdLoaded: (MFAd *)ad {
// The ad has loaded - you are able to show the ad once this callback has triggered
}
-(void) onAdStateChanged: (MFAd *)ad withState: (MobileFuseOmniAdRenderState)state {
if (state == MOBILEFUSE_OMNI_AD_STATE_FULL_SCREEN) {
// The omni ad is now rendering in full-screen mode, you should
// mute any audio/pause your app
} else if (state == MOBILEFUSE_OMNI_AD_STATE_THUMBNAIL) {
// The omni ad is now rendering as a floating omni thumbnail, your
// app should not be paused
}
}
-(void) onAdNotFilled: (MFAd *)ad {
// There is no ad currently available to show to this user
}
-(void) onAdClosed: (MFAd *)ad {
// The ad has been displayed and then closed
}
-(void) onAdRendered: (MFAd *)ad {
// Triggered when the ad is first shown to the user - you could
// use this to ensure that the corner of the screen does not contain
// content that may be hidden by the omni ad
}
-(void) onAdClicked: (MFAd *)ad {
// The user has clicked the ad
}
-(void) onAdExpired: (MFAd *)ad {
// The ad has expired before being displayed - you should manually try to
// load a new ad here
}
-(void) onAdError: (MFAd *)ad withMessage: (NSString *)message {
// An error occured - the message argument will contain details of what went wrong
}
// You can also listen for mute/unmute events - these happen when the user
// manually un-mutes the ad and you should ensure that your app is not
// playing music at the same time:
-(void) onAdMutedChanged: (MFAd *)ad withMuteState: (BOOL)muted {
if (muted) {
// The ad is muted, your app can play audio as normal
} else {
// The ad is playing sound - mute any music that your app is playing
}
}
Finally, request that the ad is preloaded using the loadAd method:
[omniAd loadAd];
Display the ad
Once the omni ad has triggered the onAdLoaded
callback, you can then call showAd
to start displaying the initial thumbnail state of the ad:
[omniAd showAd];
Optionally, you can specify the corner for the ad to be displayed in - this will default to bottom-right and should be set before calling showAd
:
// Choose where to display the ad!
[omniAd setStartingPosition: MOBILEFUSE_OMNI_AD_POSITION_BOTTOM_LEFT];
[omniAd setStartingPosition: MOBILEFUSE_OMNI_AD_POSITION_BOTTOM_RIGHT];
[omniAd setStartingPosition: MOBILEFUSE_OMNI_AD_POSITION_TOP_LEFT];
[omniAd setStartingPosition: MOBILEFUSE_OMNI_AD_POSITION_TOP_RIGHT];
You can also use isLoaded
to check whether the ad is ready to be displayed.
if ([omniAd isLoaded]) {
// The ad is ready to be displayed!
[omniAd showAd];
}
Updated about 1 year ago