iOS SDK for in-app advertising with SmartyAds SSP
This is a free Software Development Kit for the iOS application developers and publishers to monetize digital mobile inventory faster than the blink of an eye. SmartyAds integrates with SmartyAds SSP, one single source of offerings tailored to publishers' needs.
Supported Ad formats
SmartyAdsSDK supports five Banner Sizes. Your should choose size to pass in initialization( your_banner_size_here) accordingly to selected placement type on SSP platform:
Banner and rich media ads:
Size, DPI | Type | SmartyAdsSDK Size Constant |
---|---|---|
320x50 | Standard Banner | kStandartSizeBanner |
320x100 | Large Banner | kLargeSizeBanner |
300x250 | IAB Medium Rectangle | kIABMediumRectangelSizeBanner |
468x60 | IAB Full-Size Banner | kIABFullSizeBanner |
728x90 | IAB Leaderboard | kIABLeaderboardSizeBanner |
Video ads:
Orientation: Landscape or Portrait
Native ads
Currently SDK supports native ads for UITableView
only. We are going to add some more options in future
Interstitial ads:
Size, DPI | Type |
---|---|
Custom size | Full screen |
Getting Started
Just a few steps to start (to understand how user works with inventory):
-
Register your account on SmartyAds Supply Side Platform
-
Confirm your registration by following the confirmation link sent via email
-
Create your first mobile inventory by clicking
Add Inventory
. SelectiOS Application
in pop up. -
Fill all required fields in
Add Inventory
form. Inventory should be reviewed and approved before presenting ads. ClickSave changes
for proceeding next -
After this, you will be granted access to create placements for your inventory,
+Banner
button should become clickable -
Click on
+Banner
, add the targeting options, floor price and size of your placement, then clickSave changes
-
Please, note the Placement ID(e.g., ID#12) below it's title. It will be used later in your code to initialize the ad container
Requirements
SmartyAdsSDK in-app advertising framework requires iOS 9 and up .
Manualy installation
ImportantSmartyAdsSDK.framework don't support iOS Simulator. Use real device for testing.
-
Download SmartyAdsSDK Cocoa Touch framework
-
Place SmartyAdsSDK.framework in project's folder
-
In Xcode, choose your App Target: General -> Embedded Binaries -> Add SmartyAdsSDK.framework from the folder where it was placed on the previous step
-
In Xcode, choose your App Target:Build Settings -> Architectures -> Build Active Architecture Only set YES
-
In Xcode, choose your App Target:Build Settings -> Build Options -> Enable Bitcode set NO
Setup App Permissions
-
Edit your Info.plist file to include the following properties: * Add ADBundleIsPaid property and its Boolean value: - YES - if your App is paid, or you have in-app purchases - NO - if your App is distributed free of any charges
-
To allow SmartyAdsSDK geo ad targeting: Add Privacy - Location When In Use Usage Description property with a String value:your_app_name would like to use your geoposition
<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> ... <key>NSLocationWhenInUseUsageDescription</key> <string>your_app_name would like to use your geoposition</string> ... </dict> </plist>
-
TURN ON App Transport Security - Allows Arbitrary Loads property - this option will allow ad content loading via HTTPprotocol. In order to turn turn on this property do the following:
<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> ... <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> ... </dict> </plist>
-
ALTERNATIVELY, you can use App Transport Security - Allows Arbitrary Loads In Web Content property - this option will allow web content loading via HTTP protocol. Also add ssp-nj.webtradehub.com to Exception Domains dictionary:
<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> ... <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>ssp-nj.webtradehub.com</key> <dict/> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> ... </dict> </plist>
Initializing SmartyAdsSDK
In AppDelegate.m, -application:didFinishLaunchingWithOptions:
method add following initializing code:
#import <SmartyAdsSDK/SmartyAdsSDK.h> ... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [MonetizationSDK start]; [MonetizationSDK GDPRconsentFlag:YES]; return YES; }
Setting GDPR (Requirement)
To make your iOS SDK GDPR compliant please set one of the following options:+ (void)GDPRconsentFlag:(BOOL)flag;
- set a new value for GDPR user consent. GDPR user consent is a boolean value, where YES = user consent given & NO = user consent denied or no information provided.+ (BOOL)getGDPRconsentFlag;
- get current GDPR value
Driving BannerAdViewDelegate
Required methods:
-
-bannerAdDidLoad
- fires when Banner AD is successfully loaded and ready for showing -
-bannerAdDidFailLoadingWithError:
- fires when Banner Ad failed to load from server -
-viewControllerForPresentingModalView
- theBannerAdView
will use the view controller returned by this method to present modals when tapped. Typically your controller can simply returnself
. -
-bannerAdCacheDidFailLoadingWithError:
- fires when Banner Ad failed to load from local cache
Optional methods:
-
-bannerAdViewClicked
- fires when user clicked on Banner Ad View -
-shouldRequestPreciseLocation
- asks if Ad View can request geo location, by using device location services, YES by default -
-autoRefreshInterval
- method for overriding time interval for auto refreshing
Add Interstitial Ad
In ViewController where you want to show Interstitial, add InterstitialAdViewController property:
#import <SmartyAdsSDK/SmartyAdsSDK.h> @interface ViewController ()<InterstitialAdDelegate> @property (nonatomic, strong) InterstitialAdViewController *interstitialad; @end
Use -init
, -viewDidLoad
as a place for interstitialAd initialization:
- (void)viewDidLoad { [super viewDidLoad]; self.interstitialAd = [[InterstitialAdViewController alloc] initWithPlacementId:**your_interstitial_id_here**]; self.interstitialAd.delegate = self; }
ImportantDon't use
-viewDidAppear:
,-viewWillAppear:
methods for initialization InterstitialAdViewController
Interstitial Ad Load and Presentation
In order to load Interstitial Ad, you should call -loadInterstitialAd
method.
- (void)someMethod { ...your code there... [self.interstitialAd loadInterstitialAd]; }
For shows Interstitial Ad View just call -showInterstitialAd
method.
- (void)interstitialAdDidLoad { [self.interstitialAd showinterstitial]; }
Driving InterstitialAdDelegate
Required methods:-
-interstitialAdDidLoad
- fires when Interstitial Ad is successfully loaded -
-interstitialAdDidFailLoadingWithError:
- fires when Interstitial Ad failed to load from server -
-interstitialAdCacheDidFailLoadingWithError:
- fires when Interstitial Ad failed to load from local cache
-
-interstitialAdViewWillAppear
- fires when Interstitial Ad View will appear on View Controller -
-interstitialAdViewDidAppear
- fires when Interstitial Ad View did appear on View Controller -
-interstitialAdViewWIllDisappear
- fires when Interstitial Ad View will disappear from View Controller -
-interstitialAdViewDidDisappear
- fires when Interstitial Ad View did disappear from View Controller -
-userClickedOnInterstitialAdView
- fires when user click on Interstitial Ad View
Add Video Ad
In ViewController where you want to show Video, add VideoAdController property.
#import <SmartyAdsSDK/SmartyAdsSDK.h> @interface ViewController () <VideoAdDelegate> @property (nonatomic, strong) VideoAdController *videoAd; @end
Use -viewDidLoad
, -init
as a place for adVideo initialization:
- (void)viewDidLoad { [super viewDidLoad]; self.videoAd = [[VideoAdController alloc] initWithPlacementId:**your_video_id_here**]; self.videoAd.delegate = self; }
ImportantDon't use
-viewDidAppear:
,-viewWillAppear:
methods for initialization VideoAdController
Video Ad Load and Presentation
In order to load Video Ad, you should call -loadVideoAd
method.
- (void)somemethod { ...code there... [self.videoAd loadVideoAd]; }
For shows Video Ad View just call -showVideoAd
method.
- (void)videoAdDidLoad { [self.videoAd showVideoAd]; }
Driving VideoAdViewDelegate
Required methods:-
-videoAdDidLoad
- fires when Video Ad is successfully loaded -
-videoAdDidFailLoadingWithError:
- fires when Video Ad failed to load from server -
-videoAdCacheDidFailLoadingWithError:
- fires when Video Ad failed to load from local cache
-
-videoAdViewControllerDidAppear
- fires when Video Ad View appear on View Controller -
-videoAdViewControllerDidDisappear
- fires when Video Ad View disappear from View Controller -
-videoAdViewControllerDidFailToLoading
- fires when Video Ad View failed to load video file -
-userDidClickOnVideo
- fires when user click on Video Ad View -
-videoAdComplete
- fires when Video Ad fully watched -
-videoAdSkipped
- fires when Video Ad skipped
Additional params
-
-setRewardedMacros:
- override this method if you set reward params in your inventory -
-setAmountMacros:
- override this method if you set amount params in your inventory
To enable custom macros please follow the steps below:
1. Inventory is supposed to be created on UI.
2. Please toggle rewarded video when creating Video Placement in that inventory.
3. The fields to fill in URLs appear to distinguish video events.
Initializing Native Ad
Currently SDK supports native ads for UITableView
only. We are going to add some more options in future.
To use native ads in your app you should take some simple steps:
-
To define the layout of native advertisement
-
To implement the classes needed for native ads served in UITableView
-
To call the method for automatic loading and serving native ads.
How to define the layout of native advertisement
Every native ad requires UIVIew
subclass which realizes NativeAdRenderingProtocol
for NativeAdViewConfigurator
settings object. NativeAdRenderingProtocol
allows you to point out which UI elements of native ad you want to use. Typical assets for native ad according to IAB specification:
-
Title
-
Sponsored
-
Icon
-
Main image
-
Desription
-
Call-to-action button
Sample implementation for native ad
//NativeAdView.h @interface NativeAdView : UIView @end //NativeView.m @interface NativeAdView ()<NativeAdRenderingProtocol> @property (weak, nonatomic) IBOutlet UIImageView *iconImageView; @property (weak, nonatomic) IBOutlet UIImageView *mainImageView; @property (weak, nonatomic) IBOutlet UILabel *titleLabel; @property (weak, nonatomic) IBOutlet UILabel *sponsoredLabel; @property (weak, nonatomic) IBOutlet UIButton *ctaButton; @property (weak, nonatomic) IBOutlet UILabel *description2Label; @end @implementation NativeAdView - (void)awakeFromNib { [super awakeFromNib]; } + (UINib *)nibForAd { return [UINib nibWithNibName:@"NativeAdView" bundle:[NSBundle bundleForClass:[self class]]]; } - (void)layoutSubviews { [super layoutSubviews]; } - (UILabel *)nativeTitleTextLabel { return self.titleLabel; } - (UIImageView *)nativeIconImageView { return self.iconImageView; } - (UIImageView *)nativeMainImageView { return self.mainImageView; } - (UIButton *)nativeCallToActionButton { return self.ctaButton; } - (UILabel *)nativeBrandLabel { return self.sponsoredLabel; } - (UILabel *)nativeDescription2TextLabel { return self.description2Label; }
Sample UI design for native ads


