iOS Ad Settings

All adviews have an adSettings the property, which is an instance of SOMAAdSettings. This offers various configuration options in the Ad Settings. However, all the configuration options listed can also be set globally by updating the [iSoma defaultAdSettings] property.

Ad Settings includes the following topics below:

  • Publisher ID
  • Adspace ID
  • Custom location
  • Keywords and search queries
  • HTTPs-0nly settings

Default Publisher and Adspace ID

Once set, all ads use these values for Publisher ID and Adspace ID.

To set this, write the following code in the applicationDidFinishLaunching method of the AppDelegate:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary* )launchOptions{
[iSoma setDefaultPublisherId:YOUR_PUB_ID adSpaceId:YOUR_ADSPACE_ID];
}

Custom Location

If location services are not available or if you want to use offline location values, please use the following settings:

adSettings.longitude = -10.0000000;// some longitude value
adSettings.latitude = 53.5500000;// some latitude value

Keywords and Search Queries

Keywords are words or phrases that advertisers use to match to the context query entered by app users. These terms are what advertisers bid on to have their ads displayed with precise targeting in order to reach customers interested in the product.

Search queries are the words or a combination of words that are entered by the app user.

Setting Up Keywords and Search Queries

Setting keywords and search queries may result in contextual ads. These can be set up by using the following options:

adSettings.keywords = @”Your,key,words”;
adSettings.searchQuery = @”some,search,query”;

HTTPS Only

By setting the property “httpsOnly” to YES, the SDK will request only secure content via https.

adView.adSettings.httpsOnly = YES;

Setting Up Ad Views

You can add an ad view in the UI of your XCode project or do it manually (i.e., code-based):

Inside the UI

  • Drag a UIView and position it at a suitable place on your screen — typically at the top or bottom.
  • Set the height and width to 50px and 320px respectively.
  • Open the Identity Inspector (CMD+Option+3) and replace the class name with SOMAAdView.
  • Under User Defined Runtime Attributes, set your publisher and Adspace ID values as intended.

Code-Based

Import iSoma framework header into your view controller file:

#import <iSoma/iSoma.h>

In the viewDidLoad method, add the following lines:


SOMAAdView* adview = [SOMAAdView new];
adview.frame = CGRectMake(0, 70, 320, 50);
[self.view addSubview:adview];
adview.adSettings.publisherId = 0;
adview.adSettings.adSpaceId = 0;
[adview load];

Delegates

If you would like to be notified about various ad events, implement the SOMAAdViewDelegate in your view controller and override the methods.

You can use the Xcode Interface Builder to connect the delegate outlet or you can set it manually by:

adView.delegate = self;

Delegate methods are:

– (UIViewController*)somaRootViewController{
return self;
}

– (void)somaAdViewWillLoadAd:(SOMAAdView *)adview{
// Here, make sure that the adview or its parent is currently positioned inside the viewable area. If the ad is covered, it will not show.
}

– (void)somaAdViewDidLoadAd:(SOMAAdView *)adview{
// Called when the ad is ready to be shown. Banners are automatically shown but you have to explicitly show the interstitial ads.
}

– (void)somaAdView:(SOMAAdView *)adview didFailToReceiveAdWithError:(NSError *)error{
// If failed to load ad or if ad is covered or partially obstruted or load is called too frequently or there is already loaded but not yet shown.
}

– (void)somaAdViewWillEnterFullscreen:(SOMAAdView *)adview{
// It is called before going into expanded state.
}

– (void)somaAdViewDidExitFullscreen:(SOMAAdView *)adview{
// Called when expanded fullscreen ad is closed.
}

– (void)somaAdViewWillHide:(SOMAAdView *)adview{
// Called when the ad is hidden by SDK for some reason.
}

– (void)somaAdViewApplicationWillGoBackground:(SOMAAdView *)adview;
// Is called when some redirect in the app leads over to another app (i.e. minimizes the current app)

- (void)somaAdViewWillLeaveApplicationFromAd:(SOMAAdView *)adView {
// This delegate will be called when your application is opening other application due to a tap on ads.
}

The most reliable way to monitor the life cycle of your app’s events (e.g., to detect delegate issues such as the above) is overriding the application delegate method, or observing related notifications provided by iOS itself (e.g., *UIApplicationWillResignActiveNotification*).

Now, if there is an error due to too-frequent load calls or if the adview is covered, the following callback will be called with the appropriate information:

(void)somaAdView:(SOMAAdView *)adview didFailToReceiveAdWithError:(NSError *)error;

A new callback is added to the delegate when an ad tries to auto-redirect without any user interaction:

(void)somaAdViewAutoRedrectionDetected:(SOMAAdView *)adview;

Modified: June 19, 2019 at 12:36 pm