Native Ads integration
Native ads let you easily monetize your app in a way that's consistent with its existing design. The Instal SDK execute the download and all the tracking automatically, you can just populate your layout with the information managed by the sdk.
Prerequisites:
Before integrating interstitial ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project.
Download and display a native ad
@property (nonatomic, strong) INNativeAd *nativeAd;
Create an MPNativeAdRequest object using the +requestWithAdUnitIdentifier:
method.
- (void)viewDidLoad {
[super viewDidLoad];
INNativeAdRequest *adRequest = [INNativeAdRequest requestWithAdUnitIdentifier:@"YOUR_AD_UNIT_ID"];
}
Start the request via -startWithCompletionHandler:
, providing a completion block to handle the results of the request. If the request is successful, the completion block's MPNativeAd parameter will represent an object that contains the ad's assets. The following sections of this guide provide more information on how to access ad assets.
INNativeAdRequest *adRequest = [INNativeAdRequest requestWithAdUnitIdentifier:@"506"];
[adRequest startWithCompletionHandler:^(INNativeAdRequest *request, INNativeAd *response, NSError *error) {
if (error) {
// Handle error.
NSLog(@"%@", error);
} else {
// Use the 'response' object to render a native ad.
self.nativeAd = response;
self.nativeAd.delegate = self;
[self displayAd];
}
}];
Layout ad view
You can use the following informations to populate ad layout:
- title
- promo text
- call to action text
- long text
- icon url
- list of screenshots (optional)
- (void)displayAd
{
[self.nativeAd loadTitleIntoLabel:self.titleLable];
[self.nativeAd loadIconIntoImageView:self.iconImageView];
[self.nativeAd loadCallToActionTextIntoButton:self.ctaButton];
[self.nativeAd trackImpression];
}
Trigger the ad's default action
When you detect that the user has tapped on an ad (e.g. via gesture recognizer or a button action), trigger the ad's default action by calling the -displayContentForURL:rootViewController:completionBlock:
method on the corresponding INNativeAd
.
- (IBAction)onCtaButton:(id)sender {
[self.nativeAd displayContentWithCompletion:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"Completed display of ad's default action URL");
} else {
NSLog(@"%@", error);
}
}];
}
A complete ViewController is available in sample app.