Native Ads
Appnext iOS SDK - Native Ads ad unit
Ad Unit Integration
Native ads SDK allows you to build customized units in the same look and feel as your app. When creating your unique ads, you can choose any combination of ad properties such as app name, description, app URL, image URL, app category, package and more.
Dream the ad units your apps deserve and implement them with quick and easy SDK integration.
Make sure to complete the Getting Started with the iOS SDK steps before you begin
Step 1: Add import statement
Add the following import statement in your pre-compiled header or in your .m/.h file where you intend to instantiate and use the Appnext SDK. If your application is written in swift add it to your bridging-header.
#import <AppnextNativeAdsSDK/AppnextNativeAdsSDK.h>
Step 2: Define a New Native Ads Component
AppnextNativeAdsSDKApi *api = [[AppnextNativeAdsSDKApi alloc] initWithPlacementID:@"REPLACE_WITH_IOS_PLACEMENT_ID"];
Step 3: Requesting Ads
The SDK allow you to change the parameters for the request.
You can set different parameters such as: the number of ads to receive, preferred ad categories and custom postback data.
AppnextNativeAdsRequest *request = [[AppnextNativeAdsRequest alloc] init];
request.count = REPLACE_WITH_AD_COUNT; // default is 1 ad
request.postback = @"REPLACE_WITH_POSTBACK"; // optional
request.categories = @"REPLACE_WITH_APP_CATEGORIES"; // optional: “cat1,cat2…”
request.creativeType= ANCreativeTypeManaged; // optional. Default is ANCreativeTypeManaged
request.clickInApp = YES;
[api loadAds:request withRequestDelegate:self];
The different options for the request creativeType are:
- ANCreativeTypeManaged - both video and static available.
- ANCreativeTypeVideo - video available.
- ANCreativeTypeStatic - wide image available.
The different options for Click in app are:
YES
- The App Store will open "in-app" within the running appNO
- The App Store will open outside the running app
The delegate need to conform with AppnextNativeAdsRequestDelegate
:
@protocol AppnextNativeAdsRequestDelegate
@optional
- (void) onAdsLoaded:(NSArray *)ads forRequest:(AppnextNativeAdsRequest *)request; //use the received data (ads) to assemble your banner ad
- (void) onError:(NSString *)error forRequest:(AppnextNativeAdsRequest *)request;
@end
// Possible errors returned to client in AppnextNativeAdsRequestDelegate method adError:forRequest:
static NSString * const kAdErrorNoInternetConnection = @"No internet connection";
static NSString * const kAdErrorNoPlacementID = @"Placement ID cannot be empty";
static NSString * const kAdErrorDownloadingResources = @"Error Downloading Resources";
static NSString * const kAdErrorAdNotReady = @"Ad not ready";
static NSString * const kAdErrorPreparingViews = @"Error Preparing Views";
static NSString * const kAdErrorLoadingAd = @"Error Loading Ad";
static NSString * const kAdErrorBadParameters = @"Bad parameters";
static NSString * const kAdErrorEmptyResponse = @"Empty response";
static NSString * const kAdErrorNoAds = @"No ads";
static NSString * const kAdErrorFailedLoadingAds = @"Failed loading ads";
static NSString * const kAdErrorNoSuitableAd = @"No suitable ad";
static NSString * const kNativeAdsErrorRequestNotValid = @"Request cannot be null";
Available properties in AppnextAdData
Extract the following ad metadata, returned in the response, and use its properties to build your customized native UI:
@interface AppnextAdData : NSObject <NSCoding, NSCopying>
@property (nonatomic, strong, readonly) NSString *title;
@property (nonatomic, strong, readonly) NSString *desc;
@property (nonatomic, strong, readonly) NSString *urlImg;
@property (nonatomic, strong, readonly) NSString *urlImgWide;
@property (nonatomic, strong, readonly) NSString *categories;
@property (nonatomic, strong, readonly) NSString *idx;
@property (nonatomic, strong, readonly) NSString *iosPackage;
@property (nonatomic, strong, readonly) NSString *supportedDevices;
@property (nonatomic, strong, readonly) NSString *urlVideo;
@property (nonatomic, strong, readonly) NSString *urlVideoHigh;
@property (nonatomic, strong, readonly) NSString *urlVideo30Sec;
@property (nonatomic, strong, readonly) NSString *urlVideo30SecHigh;
@property (nonatomic, strong, readonly) NSString *bannerId; // The Identifier
@property (nonatomic, strong, readonly) NSString *campaignId;
@property (nonatomic, strong, readonly) NSString *supportedVersion;
@property (nonatomic, strong, readonly) NSString *storeRating;
@property (nonatomic, strong, readonly) NSString *appSize;
@end>
Step 4: Report Impressions
Report impressions for each displayed ad by calling the following function
[api adImpression:adData];
Step 5: Opening the store for one of the ads
[api adClicked:adData withAdOpenedDelegate:self];
Launching the store should only be done by calling the adClicked method.
The delegate need to conform with AppnextNativeAdOpenedDelegate:
@protocol AppnextNativeAdOpenedDelegate
@optional
- (void) storeOpened:(AppnextAdData *)adData;
- (void) onError:(NSString *)error forAdData:(AppnextAdData *)adData;
@end
// Possible errors returned to client in AppnextNativeAdOpenedDelegate method adError:forAdData:
static NSString * const kNativeAdsErrorAdDataNotValid = @"Ad Data cannot be null";
static NSString * const kNativeAdsErrorCantOpenStore = @"Cant open store on the device";
Step 6: Report "Video Started"
It is mandatory to call the following function, whenever a video is displayed and started playing:
[api videoStarted:adData];
Step 7: Report "Video Ended"
It is mandatory to call the following function, whenever a video ended:
[api videoEnded:adData];
Step 8: Add Privacy Policy Icon
It is mandatory to add Appnext Privacy Policy icon to the ad unit. For your convenience, you can use the following PSD/PNG assets from here. Once placed, clicking the icon should trigger the privacyClicked function.
[api privacyClicked:self.adData withPrivacyClickedDelegate:self];
Example Project
Please find example projects or how to implement the native ads SDK inside the zip file here.
App Categories
1. Action 2. Adventure 3. Arcade 4. Board 5. Books 6. Business 7. Card 8. Casino 9. Catalogs 10. Dice 11. Education 12. Educational 13. Entertainment 14. Family 15. Finance 16. Food & Drink 17. Graphics & Design 18. Health & Fitness 19. Kids | 20. Lifestyle 21. Medical 22. Music 23. Navigation 24. News 25. Photo & Video 26. Productivity 27. Puzzle 28. Racing 29. Reference 30. Role Playing 31. Simulation 32. Social Networking 33. Sports 34. Strategy 35. Travel 36. Trivia 37. Utilities 38. Weather |
Make sure to encode (%20) categories with more than 1 word, example: Travel%20%26%20Local
Integration Support
Should you have any problems integrating the product, log a ticket with us by emailing [email protected].
Updated 8 months ago