Native Ads


Display a native ad in your app

Displaying a native ad is a two-step process. First you should create and load your MFNativeAd unit, then when you’re ready, get the native assets and views to add to build your content.

  • Create an native ad unit
  • Get the native assets and views to display

Create a native ad unit

The MFNativeAd class provided by the MobileFuse SDK will handle the loading of the native ad assets and views.



To provide a good user experience, you should create and pre-load your native ad units before you intend to display the native ad. Once a native ad unit is created and pre-loaded, you can retrieve the content instantly with the get content methods. Having the ad preloaded will ensure that you’re ready to display the ad as soon as the opportunity occurs. However, please note that ads expire after 5 minutes (at which time you’ll need to request a new one), so plan accordingly.

First, create a new MFNativeAd unit and keep a reference to it within the Activity that you want to use it:

MFNativeAd *nativeAd;

-(void)createNativeAd() {
    nativeAd = [[MFNativeAd alloc] initWithPlacementId:@"000000"];



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.

[nativeAd registerAdCallbackReceiver: self];
-(void) onAdLoaded: (MFAd *)ad {
    // Ad has loaded - you are able to call get content methods after this callback is triggered

-(void) onAdNotFilled: (MFAd *)ad {
    // No ad is currently available to display to this user

-(void) onAdRendered: (MFAd *)ad {
    // Triggered when the ad content is added to the view hierarchy

-(void) onAdClicked: (MFAd *)ad {
    // Triggered when the ad is clicked by the user

-(void) onAdExpired: (MFAd *)ad {
    // Triggered when a loaded ad has expired - you should manually try to load a new ad here

-(void) onAdError: (MFAd *)ad withMessage: (NSString *)message {
    // An error occurred with the ad, examine the `error` argument to determine what went wrong

Finally, request that the ad is preloaded using the loadAd method:

[nativeAd loadAd];

Display the ad

Once the native ad has triggered the onAdLoaded delegate, you can then call the get content methods to add the content to your view.

You can call the "has" methods to see if the loaded ad has certain content available:

[nativeAd hasTitle];
[nativeAd hasSponsoredText];
[nativeAd hasDescriptionText];
[nativeAd hasDisplayUrl];
[nativeAd hasCtaButtonText];
[nativeAd hasIcon];
[nativeAd hasMainImage];
[nativeAd hasMainVideo];

The get content methods are split into two groups:

  • String values
  • Views
// String values
[nativeAd getTitle];
[nativeAd getSponsoredText];
[nativeAd getDescriptionText];
[nativeAd getDisplayUrl];
[nativeAd getCtaButtonText];

// Views
[nativeAd getIconImage]; // View
[nativeAd getMainImageView]; // View
[nativeAd getMainVideoView]; // View
[nativeAd getMainContentView]; // returns a View of either Main Image or Video (whichever is available)

Register for interaction

For the user to interact with the ad you are required to register the main content and clickable views:

[nativeAd registerViewForInteraction:containerView withClickableViews:@[ ... ]];