ConsoliAds Mediation Integration

You are here:
Estimated reading time: 6 min

Create App on Portal

Login to your ConsoliAds portal and go to Apps-> New App to create your native app.

Make sure that you have already created a brand to associate your app with. Import your app directly from the app store or create manually by providing all the required information and save, ConsoliAds will create your app with the following default placeholders:
•   Activity 1
•   Activity 2
•   Activity 3
•   Activity 4
•   Options A
•   Options B
•   About
•   Settings

Integrate ConsoliAds iOS Mediation

  1. Login to your ConsoliAds portal and download ConsoliAds-mediation for native iOS
  2. Place all of the files in your project root (all files are mandatory)
  3. Add all files in project except “libConfigureServer.out”
  4. Requirements and settings to work with ConsoliAds mediation:

   XCode version should be 8 or higher.

   Deployment Target should be equal to greater than 9.

   ConsoliAds-mediation requires a device to run (would not build on simulator)

   Disable “Bitcode” option in build settings

   Add “–ObjC” flag in “Other linker flags” in build settings

          •   in Target > link Binary with libraries add

1. libc++.1.tbd.
2. lbsqlite3.0.tbd

5. In project target‘s info, add “App Transport Security Settings” as follows:

6. To add your desired Ad Network to ConsoliAds mediation, please visit ‘Add/Remove Ad Network‘ section.

Initialize ConsoliAds iOS Mediation

  1. Import “ConsoliAdsMediation.h” and set up app’s name and bundle ID as follows:
[ConsoliAdsMediation sharedInstance][email protected]"Mediation iOS";
[ConsoliAdsMediation sharedInstance][email protected]"com.onsonliAds.nativeMediation";

      2. Delegates

To receive the event when ConsoliAds Mediation get initialize, you need to register the ‘ConsoliAdsMediationDelegate’ delegate before initializing mediation:

[[ConsoliAdsMediation sharedInstance] setDelegate:yourMediationInitDelegate];

ConsoliAds SDK fire following event on initialization success.

-(void) onConsoliAdsInitializationSucces:(BOOL)status;

       3. Initialize ConsoliAds-Mediation as follows:

[[ConsoliAdsMediation sharedInstance] initializeWithUserConsent:true viewController:self];
  • User Consent
    TRUE means user has provided the consent and will be shown personalized ads, whereas FALSE means user is not willing to see personalized ads. It is developer’s responsibility to get user consent and pass it above initialization call.
  • ViewController
    The prevailing view controller upon initialization.

Interstitial Ad

   Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
   Add Interstitial and Video Ad slot as shown in the below figure:

Check the availability of Interstitial Ad using the following code:

- (BOOL)isInterstitialAvailable:(NSInteger)sceneIndex;

Show Interstitial Ads
Once initialized, ConsoliAds mediation is ready to show ads. Make sure you have added Ad Network IDs in the portal for the corresponding app. Now show interstitial ad simply by the following code:
NOTE: Interstitial ads are not required to be requested and loaded separately.

[[ConsoliAdsMediation sharedInstance] showInterstitial:sceneIndex viewController:self];

This call requires the following mandatory parameters:

  • Scene Index
    Integer value for the index of the scene for which you want to show the Interstitial ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
  • ViewController
    The prevailing ViewController showing the interstitial ad.
  • Delegates

To receive events for Interstitial Ads please register ‘ConsoliAdsMediationInterstitialAdDelegate’ delegate.

[[ConsoliAdsMediation sharedInstance] setInterstitialAdDelegate: yourInterstitialDelegate];

ConsoliAds SDK fire the following events so that you can track activities for Interstitial Ads.

-( void) onInterstitialAdShown;
-( void) onInterstitialAdClicked;
-( void) onInterstitialAdClosed;
-( void) onInterstitialAdFailedToShow;

Rewarded Video Ad

   Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
   Add Rewarded Video Ad slot as shown in the below figure:

Check the availability of Rewarded Video Ad using the following code:

- (BOOL)isRewardedVideoAvailable:(NSInteger)sceneIndex;

Load Rewarded Video
Rewarded video ads in ConsoliAds are loaded and shown separately. Load rewarded video ad as follows:

[[ConsoliAdsMediation sharedInstance] loadRewarded:sceneIndex];

NOTE: It is highly recommended that you call LoadRewarded(sceneIndex) as early as possible to allow videos to be preloaded.
This call requires the following mandatory parameters:

  • Scene Index
    Integer value for the index of the Scene for which you want to load the Rewarded video ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.

Show Rewarded Video
Show Rewarded ad simply by the following code:

[[ConsoliAdsMediation sharedInstance]showRewardedVideo:sceneIndex viewController:self];
  • Scene Index
    Integer value for the index of the scene for which you want to show the Rewarded Video ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
  • ViewController
    The prevailing ViewController when showing the rewarded video ad.
  • Delegates
    To receive events for Rewarded Video Ads please register ‘ConsoliAdsMediationRewardedAdDelegate’ delegate.
[[ConsoliAdsMediation sharedInstance] setRewardedAdDelegate: yourRewardedVideoDelegate];

ConsoliAds SDK fire the following events so that you can track activities for Rewarded Video Ads.

-( void) onRewardedVideoAdLoaded;
-( void) onRewardedVideoAdFailToLoad;
-( void) onRewardedVideoAdShown;
-( void) onRewardedVideoAdCompleted;
-( void) onRewardedVideoAdClicked;
-( void) onRewardedVideoAdFailToShow;
-( void) onRewardedVideoAdClosed;

Banner Ad

   Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
   Add Banner Ad slot as shown in the below figure:

Show Banner
Show banner ad by simply the following code:

[[ConsoliAdsMediation sharedInstance]showBanner:sceneIndex viewController:self view:bannerView];

This call requires the following mandatory parameters:

  • Scene Index
    Integer value for the index of the scene for which you want to show the banner ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
  • ViewController
    The view controller at which you want to display banner.

Banner View

The banner view is the UIView to show banner. Size of the view must be according to the following sizes provided by the ConsoliAds

Banner (320*50)

Medium rectangle (300*100)

IABBanner (468*60)

Leaderboard (728*90)

Large Banner (320* 100)

Smart Banner (screen Width)

NOTE: Leaderboard banner will not show if your screen size is smaller than banner size

Custom Show banner ad simply by the following code:

[[ConsoliAdsMediation sharedInstance]showBanner:sceneIndex viewController:self view:bannerView width:width height:height];

we will provide the custom banner according to the size provided and it will draw in the center of the container (bannerView).

NOTE: ConsoliAds mediation supports only one banner at a time.

Hide Banner

You can hide banner simply by using the following code:

[[ConsoliAdsMediation sharedInstance] hideBanner]

Delegates

To receive events for Banner Ads please register ‘ConsoliAdsMediationBannerAdDelegate’ delegate.

[[ConsoliAdsMediation sharedInstance] setBannerAdDelegate: yourBannerAdDelegate];

ConsoliAds SDK fire the following events so that you can track activities for Banner Ads.

-( void) onBannerAdShown;
-( void) onBannerAdFailToShow;
-( void) onBannerAdClosed;
-( void) onBannerAdClicked;

Native Ad

   Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
   Add Native Ad slot as shown in the below figure:

ConsoliAds Mediation provides the following Ad Networks’ Native Ad through its Mediation SDK:

  • ConsoliAds
  • Admob
  • Facebook
  • Applovin

Request an Ad

You need to create a custom view class of type UIView and implement the ‘CANativeAdRenderingDelegate’ protocol. you need to create multiple UI elements inside this calls to present Native Ad contents. The mandatory UI elements are:

  • Title Label: To contain the Native Ad title string
  • Body Label: To contain the Native Ad body string
  • Advertiser Text Label: To contain the Native Ad Advertiser string
  • NativeAdVideoView: To contain the Native Ad content View
  • NativeIconImageView: To contain the Native Ad icon Image
  • NativeCallToActionButton: To contain the Native Ad Action Button
  • NativePrivacyInformationIconImageView: To contain the Native Ad privacy policy view

You need to implement all the following method provided by CANativeAdRenderingDelegate protocol and provide exactly the same UI element to load Native Ads content.

-(UILabel *) nativeTitleTextLabel;
-(UILabel *) nativeBodyTextLabel;
-(UILabel *) nativeAdvertiserTextLabel;
-( UIImageView *) nativeIconImageView;
-( UIView *) nativeVideoView;
-( UIButton *) nativeCallToActionButton;
-( UIView *) nativePrivacyInformationIconImageView;
-( NSLayoutConstraint *) iconAdWidthConstraint;

So your custom view class’s implementation for native ad mediation would look like this.

@implementation MyMediatedNativeAdView
-( UILabel *) nativeBodyTextLabel
{
                   return self. yourNativeAdBodyLabel;
}
…
…

@end

Delegates

To request a Native Ad you can call the following method:

[[ConsoliAdsMediation sharedInstance] loadNativeAdInViewController:yourViewController sceneIndex:sceneIndex delegate:yourNativeAdDelegate];

Parameters:

  • ViewController:
    You need to provide the ViewController reference for which you need to show Native Ad.
  • Scene Index: 
    Integer value for the index of the Scene for which you want to show the Native ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
  • NativeAd Delegate:
    you need to register Native Ad delegate to get notified against Native Ad’s life-cycle events.

You need to register ‘CANativeAdRequestDelegate’ delegate to get yourself notified for the events fired against each activity for the Native Ads, such as when nativeAd gets loaded or when native ads get fail to load an ad.

ConsoliAds SDK fire the following events so that you can track activities against each Native Ad request.

-( void) onNativeAdLoaded:(CAMediatedNativeAd*)nativeAd;
-( void) onNativeAdLoadFailed;
-( void) onNativeAdClicked;
-( void) onNativeAdShown;
-( void) onNativeAdFailToShow;
-( void) onNativeAdClosed

Register

When Native Ad is loaded you have to implement this method to populate the view with Native Ad contents.

-( void)onNativeAdLoaded:(CAMediatedNativeAd *)nativeAd ){
                   [nativeAd registerViewForInteractionWithNativeAdView:self.nativeAdView];
}

Icon Ad

   Icon ad comes in different sizes (Small, Medium, Large)
   Login to your ConsoliAds portal and go to Apps->Mediation->(Your APP)->Placeholders & Ads
   Import IconAdBase.h and IconAdView.h
   Add icon ad slot

 

Steps to show Icon Ad

Get Icon Ad:

IconAdBase *iconBase = (IconAdBase*)[[ConsoliAdsMediation sharedInstance] getIconAd:sceneIndex];

Show Icon Ad:

If( iconAdBase != nil ) { IconAdView *view = [[IconAdView alloc]initWithAd:iconBase]; [self.iconView addSubview:view]; }

iconView: This is the view at which you want to display Icon Ad.

Delegates

To receive events for Icon Ads please register ‘ConsoliAdsMediationIconAdDelegate’ delegate.

[[ConsoliAdsMediation sharedInstance] setIconAdDelegate: yourIconAdDelegate];

ConsoliAds SDK fire the following events so that you can track activities for Icon ads:

-( void) onIconAdShown;
-( void) onIconAdFailedToShow;
-( void) onIconAdClosed;
-( void) onIconAdClicked;

Implementing Call Back Events

ConsoliAds provides the following callbacks for different events:

- (void)onConsoliAdsInitializationSuccess:(BOOL)status;
- (void)onInterstitialAdShown;
- (void)onInterstitialAdClicked;
- (void)onVideoAdShown;
- (void)onVideoAdClicked;
- (void)onRewardedVideoAdShown;
- (void)onIconAdShown;
- (void)onRewardedVideoAdCompleted;
- (void)onRewardedVideoAdClick;

Configure Server

Steps to Configure Server:

   Find “libConfigureServer.out” in ConsoliAds-mediation package and place it in the root directory of the project.
   Open terminal, change the directory path to the project root directory and run the following command.

./libConfigureServer.out userSignature packageName store Apple

Example:

./libConfigureServer.out 5d4b02b39dc419548ea8183e8d3ea170 com.seasonapps.myfitnessguide Apple

User Signature: A user identification code which is present in the personal info tab of your account.

   Once you have successfully configured server, make sure to remove the libConfigureServer.out from root directory of the project

ConsoliAds GitHub Forum

If you are having any technical issues with ConsoliAds you can visit https://github.com/teamconsoliads/sampleapp-IOS to view known issues, share problems and suggestions.

Was this article helpful?
Dislike 1
Views: 380