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.

ConsoliAds Mediation Integration

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 your Xcode project, select your target Build Settings and

○  Enable module option (c and objective-c)

○  Enable Objective-C Exceptions

          •   in Target > link Binary with libraries add

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

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].productName=@"Mediation iOS";
[ConsoliAdsMediation sharedInstance].bundleIdentifier=@"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:userConsent isCCpa: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.
  • CCPA
    California Consumer Privacy Act (CCPA) Flag
  • 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:

ConsoliAds Mediation Integration

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:

ConsoliAds Mediation Integration

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:

ConsoliAds Mediation Integration

Show Banner
Show banner ad by simply the following code:

[[ConsoliAdsMediation sharedInstance] showBannerWithIndex:sceneIndex  bannerView:bannerView 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 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 CAMediatedBannerView

 to show banner create the object of the CAMediatedBannerView with the size provided by the ConsoliAds. 

bannerView = [[CAMediatedBannerView alloc] initBannerWithSize:size];

Where size of the view must be according to the following sizes provided by the ConsoliAds

  •    CABannerSizeNone,                 // Size selected on ConsoliAds Portal
  •     CABannerSizeStandard ,             //320×50
  •     CABannerSizeMediumRectangle ,    //300×250
  •     CABannerSizeIABBanner ,          //468×60
  •     CABannerSizeLeaderboard ,        //728×90
  •     CABannerSizeSmartBanner ,        //screenwidth
  •     CABannerSizeLargeBanner 

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

Custom Banner

For Admob user can show custom banner by setting property of mediated view before show call;

bannerView = [[CAMediatedBannerView alloc] initBannerWithSize:size];

where size is a value of CGSize type.

Hide Banner

You can hide banner simply by using the following code:

[[ConsoliAdsMediation sharedInstance] destroyBannerView:bannerView];

Delegates

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

-(void)onBannerAdLoaded:(CAMediatedBannerView*)bannerView;
- (void)onBannerAdLoadFailed;
- (void)onBannerAdClicked;
-(void)onBannerAdRefreshEvent;

When banner is loaded add banner to view.

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 Integration

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

 

ConsoliAds Mediation Integration

Steps to show Icon Ad

Get Icon Ad:

IconAdBase *iconBase = (IconAdBase*)[[ConsoliAdsMediation sharedInstance] loadIconAd:sceneIndex viewController:self delegate:self];

Show Icon Ad:

Init the icon with the animation. ConsoliAds  provides the following animation 

  • KCAAdNoIconAnimation ,    // No Icon Animation
  • KCAAdRotationIconAnimation ,   // Rotation Animation
  • KCAAdScaleIconAnimation     // Scale ANimation
If( iconAdBase != nil ) {IconAdView *view = [[IconAdView alloc] initWithAd:iconBase animationType:KCAAdScaleIconAnimation]; [self.iconView addSubview:view]; }

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

Delegates

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

-(void)didCloseIconAd;
-(void)didClickIconAd;
-(void)didDisplayIconAd;
-(void)didRefreshIconAd;
-(void)didLoadIconAd;
-(void)didFailedToLoadIconAd;

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)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.

ConsoliAds Mediation Integration

   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: 518