Skip to end of metadata
Go to start of metadata

Version History


 Click Here to Expand Version History!
VERSIONDATEAUTHORCHANGES
3.12012-03-26MORewrite of larger portions of the code. Improved API for easier integration. Full support for MRAID rich media ads (see here). Transmission of ODIN mobile device identifier.
3.1.12012-06-27MOAddressed issues occurring on older Android Devices.
3.1.22012-09-14MOMinor internal changes and improvements.
3.1.32012-09-19MOImproved compatibility with other advertising SDKs. Added information about unique identifiers.
3.1.42012-10-02MOAddresses issue where negative GPS coordinates weren’t accepted.
3.1.52012-10-23MOAddresses an issue that can cause crashes on Gingerbread devices that run version 1.9.11 of the Facebook application. Updated privacy language.
3.1.62012-11-05MOImproved compatibility with other advertising SDKs. Minor improvements.
3.1.72012-11-09MOAdded description how to add in XML layout. Minor improvements.
3.1.82012-12-11MOImproved compatibility with other advertising SDKs. Minor improvements.
3.1.92013-01-15MOAdded Javascript compatibility for Android 4.2
3.2.02013-02-06MOAdded compatibility for Android StrictMode
3.2.12013-03-28MOImproved user experience
3.2.22013-05-06MOStatus bar bug fix. Banner scaling configurable
4.0.02013-06-06NCFull Support for MRAID 2.0, introduced new banner format
4.0.12013-06-13NCReverse Geocoding
4.0.22013-06-21NCBugfixes
4.0.32013-07-12NCEncoding Strings in ad Request
4.0.42013-07-24NCFix for reverse geocoding and google play links
4.0.52013-08-30NCNew COPPA (Children’s Online Privacy Protection Act) parameter introduced.
4.0.62013-09-25NCFix for banner auto reload.
Introduction of language parameter.
4.0.72013-10-04NCImproved Rich Media Support
4.0.82014-03-18NCIntroduced Banner Twister
4.0.92014-05-12NCFix for lat/long
4.1.12014-06-10NCImproved interstitial support
4.22014-06-10NCBlocking auto expanding ads
4.32014-06-26NCRemoved android id
4.3.12014-08-07NCImproved Google advertising id integration
Removed IMEI
Bug fixes
Android 4.3.22014-09-15NCInterstitial landscape orientation
New Demo App
Bug fixes
Android 4.3.32014-10-22NC

Support for AppLinks
Updated mediation adapters
Phonegap Integration guide included

Android 4.4.02015-03-19NC

VAST Support

Native Ads Support

Android 4.4.12015-03-20NCFix for auto reload
Android 4.4.22015-04-08NCImproved Rich Media support for Interstitial ad units
Android 4.5.02015-08-25NC

Introducing SDK Browser
VAST Support Improvements
Interstitial now supports location with Unity3D 

Android 4.5.12015-09-02NC

Enhanced Exception handling

Bug fixes

Android 5.02015-10-29NC
  • Client side mediation
  • Supported networks: AdMob, MoPub, Millennial Media, iAd and Custom Network
  • App Deep linking enhancements
  • Multiple debug levels support
  • Bug fixes
Android 5.0.12015-12-07NC
  • Enhanced VAST video support
  • Faster Rich Media ad rendering

Android 5.0.2

2016-01-19BR
  • Introduced Native Ads Templates for iAB Native Ads Layouts

  • Added Destroy Method to Banner View

Android 5.0.42016-06-27BR
  • JSON Responses (except for VAST)
  • Support for both ActivityContext and ApplicationContext Methods
Android 5.0.72016-07-26BR
  • Updated Mopub Custom Adapter Documentation
  • Added Native Ads Support for Mopub Custom Adapter
Android 5.0.92016-09-20BR
  • Nougat support/Split-screen support added
  • Facebook CSM information added
Android 5.0.102016-10-28BR
  • Android 4.4-related Bug Fixes
Android 5.1.02016-12-13BR
  • Rewarded Video
  • Video Auto-Close
  • Video Skippability
Android 5.1.12017-01-13BR
  • Native Ad Impression Beacon handling updated
Android 5.1.22017-03-09EN
  • Device Rotation support for Video Interstitials and Rewarded Ads
Android 6.0.02017-04-04EN
  • Memory Optimisation and updated support for MoPub Adapters Custom Events

Latest Version

Getting Started

Download the Smaato Android SDK

To download the latest version of our Android SDK, you can either log in to your SPX account and get it from the integration section, or download it from our website at https://www.smaato.com/resources/sdks/.

For more information on versions and requirements, check out the Version History above.

Also, by using our SDK you agree to our Terms and Conditions.

Add the Smaato SDK to your project

Download and unzip the Smaato SDK

You'll find a .JAR file. Drag & drop (or import) it into your project.

Notice for Android Studio Users:

If you don't have the following line in your build.gradle file already, add the following line and rebuild the project:

compile fileTree(dir: 'libs', include: ['*.jar’])
Also, please add the following line into your module level build.gradle file as a dependency. Save the build.gradle file and sync Gradle (go to Tools --> Android --> Sync Project with Gradle Files). For further reference, please check our SmaatoDemoApp.

 

compile 'com.google.android.gms:play-services-ads:7.8.+’

Configuring your AndroidManifest.xml

Permissions

In order to let the SDK run correctly, some permissions need to be granted:

  • INTERNET (mandatory)
  • READ_PHONE_STATE (strongly recommended)
  • ACCESS_NETWORK_STATE (strongly recommended)
  • ACCESS_COARSE_LOCATION (recommended)
  • ACCESS_FINE_LOCATION (optional)
  • WRITE_EXTERNAL_STORAGE (optional)

Open your AndroidManifest.xml and add the following lines:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

 

If you are using Google Play Services SDK, please add the following metadata to your AndroidManifest.xml

<meta-data android:name=”com.google.android.gms.version” android:value=”@integer/google_play_services_version”/>

Soma Activity Declaration

From version 4.5.0 onward, we've introduced the enhanced SDK browser, which requires its activity to be declared:

<activity android:name="com.smaato.soma.ExpandedBannerActivity" android:configChanges="keyboardHidden|orientation|screenSize" ></activity>

Since we've introduced the Interstitial ad format, that activity also needs to be declared in your manifest.xml as well; please add the following lines to your manifest configuration:

<activity android:name=”com.smaato.soma.interstitial.InterstitialActivity” android:configChanges="keyboardHidden|orientation|screenSize" ></activity> 

 

From version 5.1.2 onward, we've introduced the enhanced SDK functionality which allows you to display ads in either only Portrait mode or only Landscape mode

For Landscape Mode, you could use the following block of code:

<!-- Smaato Activities. --> 
 
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity"
 android:resizeableActivity="false"  android:screenOrientation="landscape" >
 </activity>
 <activity android:name="com.smaato.soma.video.VASTAdActivity"
 android:resizeableActivity="false"  android:screenOrientation="landscape" >
</activity>
 <activity android:name="com.smaato.soma.ExpandedBannerActivity"
 android:resizeableActivity="false"  android:screenOrientation="landscape" >
 </activity>

For Portrait Mode, you could use the following block of code:

<!-- Smaato Activities. --> 
 
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity"
 android:resizeableActivity="false" android:screenOrientation="portrait" >
 </activity>
 <activity android:name="com.smaato.soma.video.VASTAdActivity"
 android:resizeableActivity="false" android:screenOrientation="portrait" >
</activity>
 <activity android:name="com.smaato.soma.ExpandedBannerActivity"
 android:resizeableActivity="false" android:screenOrientation="portrait" >
 </activity>
 

Split-Screen Mode (Android Nougat)

Since Android Nougat, publishers can now also use the new split-screen/multi-window mode in their apps.

If you intend to use that, you'll need to add the statement android:resizeableActivity="false" for Smaato activities in your AndroidManifest.xml file. 

Example:

<!-- Smaato Activities. --> <activity android:name="com.smaato.soma.interstitial.InterstitialActivity"
 android:resizeableActivity="false" android:configChanges="keyboardHidden|orientation|screenSize">
 </activity>
 <activity android:name="com.smaato.soma.video.VASTAdActivity"
 android:resizeableActivity="false" android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
 <activity android:name="com.smaato.soma.ExpandedBannerActivity"
 android:resizeableActivity="false"android:configChanges="keyboardHidden|orientation|screenSize">
 </activity>

 

Adding Third Party Ad Networks

Smaato as primary (Client Side Mediation)

Client side mediation (aka SDK mediation) enables you to mediate owned 3rd party network accounts (such as AdMob, MoPub, iAd, Millennial Media, or any other network via a custom SDK connector) via SDK. Just integrate our SDK as per the above, integrate the respective 3rd party SDK as described below and configure your network mediation in your SPX account.

For more details, please visit the Android 6.0.0 page.

Google AdMob 

Add the following lines to your AndroidManifest.xml file:

<!--GOOGLE ADMob Include the AdActivity -->
<activity android:name="com.google.android.gms.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
 android:theme="@android:style/Theme.Translucent" />

Add the following lines to your project level build.gradle file. Avoid any duplicate additions.

compile 'com.google.android.gms:play-services-ads:7.8.0'

If you're using Proguard in your project, consider adding the following lines to your Proguard config file as per your requirements:

-assumenosideeffects class android.util.Log {
    public static *** d(...);
	public static *** v(...);
	public static *** i(...);
}

MoPub 

Add the following lines to your AndroidManifest.xml file:

<!--Mopub Activity -->
<activity android:name="com.mopub.mobileads.MoPubActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser"
    android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"/>

Add the following lines to your project level build.gradle file. Avoid any duplicate additions:

// MoPub  aar dependency inclusion for Mediation
compile('com.mopub:mopub-sdk:3.13.0@aar') {
    transitive = true
}

If you're using Proguard in your project, add the following lines to your Proguard config file:

-dontwarn com.mopub.**
 
-keep public class * extends one.mopub.**
-keep class com.mopub.** { *; }

Millennial Media 

Add the following lines to your AndroidManifest.xml file:

<activity android:name="com.millennialmedia.internal.MMActivity" />
<activity android:name="com.millennialmedia.internal.MMIntentWrapperActivity" />

Copy the latest .aar file from Millennial Media Android SDK (Reference http://docs.millennialmedia.com/android-ad-sdk/index.html)

Add the following lines to your project level build.gradle file. Avoid any duplicate additions.

compile project(':mm-ad-sdk')

If you're using Proguard in your project, add the following lines to your Proguard config file.

keep classmembers class com.millennialmedia** {
public *;
}

­keep class com.millennialmedia**

Facebook

Please Note: Facebook requires Android SDK version 5.0.8 or higher.

Add the following lines to your project-level build.gradle file. Make sure to avoid any duplicate additions.

// Facebook Android SDK
compile 'com.facebook.android:facebook-android-sdk:4.10.1'
// Audience Network SDK. Only versions 4.6.0 and above are available
compile 'com.facebook.android:audience-network-sdk:4.10.1' 

Next, add the following lines to your AndroidManifest.xml file:

 

<!--Facebook Audience Network Interstitial -->
<activity android:name="com.facebook.ads.InterstitialAdActivity"
    android:configChanges="keyboardHidden|orientation|screenSize" />
<!-- Apps targeting api v13 and higher should add '|screenSize' to the InterstitialAdActivity configChanges to support video rotation -->
<!--Facebook Audience Network NativeAd-->
<activity android:name="com.facebook.ads.NativeAdVideoActivity"
    android:configChanges="keyboardHidden|orientation|screenSize" />

Also, if you're using Proguard in your Project, consider adding the following lines to your Proguard config file as per your requirements:

 

-keep class com.facebook.ads.** { *; }
-keep class com.facebook.** { *; }

 

CustomMediationNetwork Adapter Ad 

  • Write your custom mediation Adapter by extending MediationEventBanner class.
  • Add your custom method to get invoked through SPX portal and the signature of the method is fixed as shown in the Sample Adapter files.
  • Configure the Class name along with the package name com.smaato.soma.mediation.CustomMediationBannerAdapterSample,
    Method name and parameters in SPX portal,

Smaato as secondary 

AdMob/DFP

Import the SDK

1. First of all we need to import Soma SDK to the project.

  • Copy soma sdk into your project.
  • Right click on your project then properties.
  • Navigate to JavaBuildPath -> Libraries.
  • Click on add JARs then choose soma sdk jar.

PS: You also need to import the AdMob SDK.

2. The second thing to do is to copy and past AdMobMediationAdapter into your project (In this tutorial we will put it inside “com.smaato.soma.MediationAdapter” package, the adapter is included in the sdk zip file).

3. For Admob - head over to your Admob account:

  • Go to “Sites & Apps” -> Ad Network Mediation or just go to AdMob Mediation.
  • Click on Add Network Mediation Placement.
  • Fill in the form with a name, platform (Android), Ad Size and an Automatic Refresh then click on Save & Continue again Continue.
  • Now you created you Add network mediation placement, now you should create a custom event by clicking on “Add Custom Event”
  • Choose a Label , in Class Name field enter this class name “com.smaato.soma.MediationAdapter.AdMobMediationAdapter” and use the parameter to transfer your Smaato publisher and AdSpace Ids, the parameters should have this form “publisher=yourPublisherID&adspace=yourAdSpaceID”.
  • Now you are done, to get Smaato ad now you have just to use the Mediation ID in your app and this while creating a new adView (activity, adSize, “mediationId”).

4. For DFP - head over to your DFP account:

  • Create a new order and new line item, targeting the desired ad unit with this line item
  • Under that order and line item, add a new creative by clicking "Add Creatives"
  • Select "SDK mediation" to configure the SDK
  • Choose a "name" for the creative
  • Toggle the "Location data" to "Active"
  • For "Select network", choose "Custom Event"
  • Use the "Parameter" field to transfer your Smaato publisher and adspace IDs, in the form “publisher=yourPublisherID&adspace=yourAdSpaceID”
  • Choose a name in the "Label" field
  • In the "Class Name" field, enter this class name “com.smaato.soma.MediationAdapter.AdMobMediationAdapter”
  • Click "Save" to save the creative
  • The Smaato SDK will now be called as specified for the targeted ad units

Mopub

MoPub Adapter Compatibility Matrix

Smaato SDK

Version

Mopub SDK

version 4.7.0

Mopub SDK

version 4.12.0

Mopub SDK

version 4.13.0

Formats

Banner

Adapter 

Interstitial

Adapter 

Native

Adapter 

Banner

Adapter 

Interstitial

Adapter 

Native

Adapter 

Banner

Adapter 

Interstitial

Adapter 

Native

Adapter 

v 6.0.0

supported

supportednot supportedsupportedsupportedsupportedsupportedsupportedsupported
v 5.1.2supportedsupportedsupportednot supportednot supportednot supportednot supportednot supportednot supported
v 5.1.1supportedsupportedsupportednot supportednot supportednot supportednot supportednot supportednot supported

 

MoPub ID configuration

First, we'll walk you through creating a MoPub ID and configuring it to work with the Smaato SDK.

  1. Login in to https://app.mopub.com, after that click on the Inventory Tab. Then click on the Add a New App button.
  2. Fill in the fields with your App info (e.g. platform, App Name, Package name, Category, etc.)
  3. When you're done filling in the information, click the Save and View Code Integration button.

  4. You'll be redirected to the Integration page, where your new Ad Unit ID will be generated.

  5. Copy your new Ad Unit ID and click on the All Done! button. 

 

Next, we'll go over through creating the custom event:

  1. Click on the Networks tab at the top of the page.
  2. Click the drop-down Add a Network menu and select Custom Native Network
  3. Enter the name of your Custom Native Network (e.g. Smaato SDK).
  4. Then select the App Targeting area and add the class name by clicking on Set App Class.
  5. You'll need to fill in the form with your class package:
    1. Enter the following in the Custom Event Class field: com.smaato.soma.mopubcustomevent.SomaMopubAdapter
    2. Also, put your Smaato Publisher ID and Adspace ID for the respective adspace in the Custom Event Class Data field, using JSON formatting - i.e. {"publisherId""0","adspaceId""0"(replace 0 with your IDs)
    3. Click on Save Section, and you're good on the Mopub side of things for now.

 

Implementation

In this section, we'll explain how to implement the “CustomEventAdapter”, which will allow you to request a banner ad-unit from Smaato. 

Requirements:

  • latest Smaato SDK

  • latest MoPub SDK

  • From version 6.0.0 onwards Smaato adapter implemented support for onBannerClicked() MoPub custom event in addition to onBannerLoaded(View) & onBannerFailed(MoPubErrorCode)
  1. Add the following permissions to your AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  2. Also, declare the following MoPub and Smaato activities:

    <!--Mopub --><activity android:name="com.mopub.mobileads.MoPubActivity"
     android:configChanges="keyboardHidden|orientation|screenSize"/>
    <activity android:name="com.mopub.mobileads.MraidActivity"
     android:configChanges="keyboardHidden|orientation|screenSize"/>
    <activity android:name="com.mopub.common.MoPubBrowser"
     android:configChanges="keyboardHidden|orientation|screenSize"/>
    <activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
     android:configChanges="keyboardHidden|orientation|screenSize"/>
    
    <!--Smaato-->
    <activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:configChanges="keyboardHidden|orientation|screenSize">
    </activity>
    <activity android:name="com.smaato.soma.ExpandedBannerActivity" android:configChanges="keyboardHidden|orientation|screenSize">
    </activity>
  3. In your Activity, add the following lines of code to your onCreate method:

    mAdView = (MoPubView) findViewById(R.id.adview);// Enter your Ad Unit ID from www.mopub.com
    mAdView.setAdUnitId("your_mo_pub_ad_unit_id");
    mAdView.loadAd();
  4. Also, make sure you've declared a Mopub view using

    private MoPubView mAdView;
  5. Declare your view in your layout.xml:

    <com.mopub.mobileads.MoPubView
    android:id="@+id/adview"
    android:layout_width="fill_parent"
    android:layout_height="50dp" />
  6. Finally, create a class called SomaMopubAdapter that extends CustomEventBanner.
  7. Declare a BannerView instance using

    private static BannerView mBanner;
  8. Add the SomaMopubAdapter.java class to the com.smaato.soma.mopubcustomevent package (e.g. by copying and pasting); the class is included in the SDK download.

MoPub Custom Events supported by Smaato's Banner Adapter:

  • onBannerLoaded(View)

  • onBannerFailed(MoPubErrorCode)

  • onBannerClicked()
Native Ads

Mopub native ads can now be mediated to show Smaato ads by using Mopub's custom event settings on their dashboard along with Smaato Adapters.

MoPub Custom Events supported by Smaato's Native Adapter: 

  • notifyAdClicked
  • notifyAdImpressed
  • preCacheImages

 

Mopub Dashboard Setup
  1. Set up a Mopub native ad unit.
  2. Create a Custom Native Network on MoPub dashboard (or use your existing one from the previous steps).
  3. Enter com.smaato.soma.mopubcustomevent.SmaatoMopubNativeCustomEvent in the field CUSTOM EVENT CLASS.
  4. Enter {"publisherId": "0","adspaceId": "3075"} in the CUSTOM EVENT CLASS DATA field. This will show a demo native ad from Smaato. So, please update it according to your publisher id and adspace id.

Android App Setup
  1. Add the Mopub SDK and display a native ad unit (according to Mopub's setup instructions).
  2. Add the Smaato Android SDK into the project.
  3. Add the SmaatoMopubNativeCustomEvent.java file and place it inside the package com.smaato.soma.mopubcustomevent in your App.
  4. Edit the SmaatoMopubNativeCustomEvent.java class if you need any customization. 
Interstitial Ads

 

MoPub Custom Events supported by Smaato's Interstitial Adapter:

  • showInterstitial()
  • onInterstitialLoaded()
  • onInterstitialFailed(MoPubErrorCode)
  • onInterstitialShown()
  • onInterstitialDismissed()
  • onInterstitialClicked()

 

For interstitial ads, the process is mostly similar to the aforementioned banner and native ads:

  1. Create a Custom Native Network on MoPub dashboard (or use your existing one from the previous steps).
  2. Enter com.smaato.soma.mopubcustomevent.SomaMopubAdapterInterstitial in the field "CUSTOM EVENT CLASS"
  3. Enter {"publisherId": "0","adspaceId": "0"} in the "CUSTOM EVENT CLASS DATA" field. This will show a demo Interstitial ad from Smaato. So, please update it according to your publisher id and adspace id.  

Android App Setup

  1. Add the Mopub SDK and display a Interstitial ad unit (according to Mopub's setup instructions).
  2. Add the Smaato Android SDK into the project.
  3. Add the SomaMopubAdapterInterstitial.java file and place inside the package com.smaato.soma.mopubcustomevent in your App.
  4. Edit SomaMopubAdapterInterstitial.java class if you need any customization.

If you need any customization to decide on when to show the Ad, update the listener methods as needed. For example, if you would like to show SmaatoAd, only when calling mMoPubInterstitial.show(), update the onReadyToShow() method as per the following:

@Overridepublic void onReadyToShow() {
 
   new CrashReportTemplate<Void>() {
      @Override
      public Void process() throws Exception {
 
         mHandler.post(new Runnable() {
            @Override
            public void run() {
               customEventInterstitialListener.onInterstitialLoaded();
            }
         });
 
         return null;
      }
   }.execute();
 
}
Integrating Unity

First of all, you need to create a folder called “Plugins” under your “assets” folder in your project.

Under the “Plugins” folder, please create another folder called “Android”. The hierarchy should look like this:

The next step is to paste the plugin files:

Start with “SomaEventListener”, “SomaEventManager” and “SomaUnityPlugin” that need to go into the “Plugins” folder.

"Soma SDK", "AndroidManifest.xml", "classes.jar" belong in the “Android” folder.

In order to create a banner view in your OnGUI() method, use the following method:

SomaUnityPlugin.initBannerView(yourPublisherId,yourAdSpaceId,adDimension, position); 

 

You can choose from the following ad dimensions:

  • 0 for MMA–320x50

  • 1 for Medium Rectangle – 300x250

  • 2 for Leaderboard – 728x90

  • 3 for Sky scraper – 120x600

 

Also, you're able to choose between two available positions:

 

  • 0 to place the ad on On Top of the screen

  • 1 to place the ad on Bottom of the screen 

Now, the banner view should be created.

To request a banner, please use:

 

SomaUnityPlugin.asyncLoadNewBanner();

To enable GPS location update, use:

SomaUnityPlugin.setLocationUpdateEnabled(Boolean value); // true to enable, false otherwise. 

 

To set the user age, please use:

SomaUnityPlugin.setAge(int age);

 

For city targeting, please use:

SomaUnityPlugin.setCity(String city); 

 

To use a keyword list, you can use the following method:

SomaUnityPlugin.setKeywordList(String keywordList); 

 

To use a search query, please use:

SomaUnityPlugin.setSearchQuery(String searQuery);

 

To set the user gender, please use:

SomaUnityPlugin.setUserGender(int gender); 

0 for Male
1 for Female
other for unset. 

To set the targeted region, please use:

SomaUnityPlugin.setRegion(String region);

 

In order to enable or disable the COPPA check, please use:

SomaUnityPlugin.setCOPPA(bool value);

true to enable; false to disable.

 

To enable the Banner auto reload, please use:

SomaUnityPlugin.setAutoReloadEnabled(bool value);

 

The default reload frequency is 60 seconds; if you want to change it, please use:

SomaUnityPlugin.setAutoReloadFrequency(int frequency);

 

By default, the banner view will be shown, if you need to hide it for some reason, please use the following method:

SomaUnityPlugin.hideView();

 

And to show it again, please use the following method:

SomaUnityPlugin.showView();

Integrating Unity with AdMob Mediation Adapter

Prerequisite :
  • AdMob SDK integrated in your Unity project.

  • Smaato Android SDK. Steps:

    This is very simple and just needs a few steps to be done. All what you need to do here, is following :

  1. Create a library project in your IDE (e.g.Eclipse or AndroidStudio)

  2. Copy paste the AdMob mediation Adapter to the package that you want to use

  3. Make all the modification needed in the mediation adapter (e.g.choose the ad dimension)

  4. Copy/Paste the generated .jar file from the /bin folder to

    /Assest/Plugins/Android in your unity project

  5. Run the unity project.

That’s it. 

Showing Interstitials

In order to request interstitial, first of all you need to declare Smaato Interstitial activity, inside your androidmanifest.xml please add the following line:

<activity>android:name="com.smaato.soma.interstitial.InterstitialActivity" android:configChanges="keyboardHidden|orientation|screenSize"> </activity>

 

The second thing that you should do is to initialise the interstitial ad using the following code :

SomaUnityPlugin.initInterstitialAd(yourPulisherId, yourAdSpaceId);

 

To enable automatic GPS location update use

SomaUnityPlugin.setInterstitialLocationUpdateEnabled(Boolean value); // true to enable, false otherwise.
 

To set the user location manually use

SomaUnityPlugin.setInterstitialLocation(37.331689,-122.030731);

 

To request interstitial ad use.

SomaUnityPlugin.asyncLoadNewInterstitial()

 

That’s it - you should now be able to get interstitial ads. 

Using Proguard

If you are using Proguard obfuscation, please add the following to your configuration:

-keep public class com.smaato.soma.internal.connector.OrmmaBridge {
public *;
}
-keepattributes *Annotation*

Setting Up Ad Views

Banners

Adding a BannerView to your activity

Inside your activity, in your onCreate(), create your BannerView.

BannerView mBanner = new BannerView (context);

The SDK supports both ActivityContext and ApplicationContext.

Note: ApplicationContext is not supported in AlertBanner and Full Screen Banner

Now the banner is created, but it won't be printed to the screen yet, so you need to attach it.

First, you need to get an instance from your layout using:

RelativeLayout myRelativeLayout = (RelativeLayout) findViewById(R.id.myRelativeLayoutId);

 

To then attach the banner view to your layout, you can use:

myRelativeLayout.addView(mBanner, new LayoutParams(LayoutParams.MATCH_PARENT, 70));

And you’re done - now the banner is attached to your layout; the next step is to set your IDs and start requesting banners.

Requesting Banners

In order to fetch live ads inside the activity, add your PublisherID and AdspaceID in the onCreate method. For example:

mBanner.getAdSettings().setPublisherId(publisherId);
mBanner.getAdSettings().setAdspaceId(adspaceId);

Please make sure you are using the correct Publisher ID and Adspace ID from your SPX Account.

We highly recommend using publisherId 0 and adSpaceId 0 during your tests.

 

The basic configuration is now ready, you still need to trigger a banner request using

mBanner.asyncLoadNewBanner();

Caching Ads

If you’re planning on loading the banner view in the background and only attaching it to the screen when an ad is available, please use the following line:

mBannerView.setScalingEnabled(false);

Activate GPS location

Enriching traffic with location data more or less guarantees higher eCPMs, with the tradeoff being that getting GPS info usually drains battery life.

To activate the location parameter, you've got two options.

1) You can use the automatic location tracking by calling

mBanner.setLocationUpdateEnabled(true);

This will allow the SOMA lib to update the user's location automatically.

2) If your application gathers location information by nature, you can also use that already present information.

mBanner.getUserSettings().setLatitude(37.331689);
mBanner.getUserSettings().setLongitude(-122.030731);

Please Note: Option 2 is disabled if automatic location update (Option 1) is enabled.

Using Targeting Data

The BannerView allows developers to set the following metadata:

  • KeywordSearch: Tags set by the app developer that describe the type of content (e.g. cars, news, restaurants, new york…)
  • QuerySearch: A search term or keywords entered by the user (e.g. restaurant new york). For example, if there is a search bar in your app, when end users search for restaurant, you can pass the query string to search terms.
  • Age, gender: The age and gender of the user (e.g. gathered through user registration).

Setting a keyword list:

mBanner.getUserSettings().setKeywordList(“Android,California”); //connect different terms with “,”

Setting a search term:

 mBanner.getUserSettings().setSearchQuery(“red car,mini”); //connect different terms with “,”

Setting the user’s age:

 mBanner.getUserSettings().setAge(35); //available parameters are integers.

Setting the user’s gender:

 mBanner. getUserSettings().setUserGender(UserSettings.Gender.MALE); //available parameters are MALE and FEMALE.

Enabling and Disabling COPPA

You are able to activate and deactivate COPPA (Children’s Online Privacy Protection Act) by using the following:

 mBanner.getUserSettings().setCOPPA(value); // true to enable, false otherwise.
Available Listener

BannerView allows you to use some listener in order to get notified when banner status changes

There is tow kind of listener, the first one is the ad listener which will get notified as soon as a banner download was completed (Success or Error).

	mBanner.addAdListener(new AdListenerInterface() {
   @Override
	public void onReceiveAd(AdDownloaderInterface arg0, ReceivedBannerInterface banner) {
		if(banner.getStatus() == BannerStatus.ERROR){
			Log.w(“”+banner.getErrorCode(), “”+banner.getErrorMessage());
		} else {
			// Banner download succeeded
	}}});

 

The second listener is the banner state listener, which will get notified when a banner will open the landing page or on closing landing page

mBanner.setBannerStateListener(new BannerStateListener() {
	@Override
	public void onWillOpenLandingPage(BannerView arg0) {
		// TODO Auto-generated method stub
	}
	@Override
	public void onWillCloseLandingPage(BannerView arg0) {
		// TODO Auto-generated method stub
	}
}); 

Destroying the Banner View

After you finish using the Banner View, it is highly recommended to clean up the memory, please call the destroy() method as per the following:

@Override
public void onDestroy(){
   // Need to be included while using Mediation
   if(mBannerView!=null)
   mBannerView.destroy();
   super.onDestroy();
}

Banner Auto Reload

The BannerView is the only banner type which implement an auto reload system. The auto refresh timer is automatically deactivated as soon as the banner is off screen. The auto reload frequency is by default set to 60 seconds, you can modify this frequency using the following method

mBanner.setAutoReloadFrequency(autoReloadFrequency);

where auto reload frequency is an integer which represent the refresh frequency in seconds that can have a minimal value 10 and maximal value 240.
If you wish to disable the auto reload frequency, please use the following method

mBanner.setAutoReloadEnabled(autoReloadEnabled);// true to enable, false otherwise

Ad Dimensions

You can specify a desired ad dimension using

mBanner.getAdSettings().setAdDimension(AdDimension.MEDIUMRECTANGLE);

Available values are:

  • DEFAULT (320 x 50)
  • LEADERBOARD (728 x 90)
  • MEDIUMRECTANGLE (300 x 250)
  • SKYSCRAPER (120 x 600)

Change Background color

By default the banner view have a white background, you still can use your preferred color for example

mBanner.setBackgroundColor(Color.BLACK);

Adding a Banner View to your Application

Create a Banner in your XML layout

In your xml layout you can directly declare a banner view, for example:

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
	xmlns:tools=”http://schemas.android.com/tools”
	xmlns:BannerView=”http://schemas.android.com/apk/lib/com.smaato.soma”
	android:layout_width=”fill_parent”android:layout_height=”fill_parent” >
	<com.smaato.soma.BannerView
		android:id=”@+id/bannerView”
		android:layout_width=”fill_parent”
		android:layout_height=”50dp”
		android:layout_alignParentLeft=”true”
		android:layout_alignParentTop=”true”
		BannerView:adSpaceId=”yourAdSpaceId”
		BannerView:publisherId=”yourPublisherId”
		BannerView:loadNewBanner=”true” />
</RelativeLayout>

BannerView:loadNewBanner=”true” need to be always the last line, otherwise the banner view will trigger a banner request ignoring all other followings attributes.

Available Parameters

Additional Parameters that can be setValue RangeDescription
BannerView:age=”30″IntegerThe user’s age
BannerView:autoReloadFrequency=”60″IntegerSet the auto refresh. Minimum = 10sec. Maximum = 600sec.
BannerView:backgroundColor=”FF0101″ Set the background color.
BannerView:gender=”M”m, fThe user’s gender.
BannerView:keywordList=”Car, Racing, Game” Keywords, describing the content. Comma separated.
BannerView:latitude=”37.787827″ Latitude of user’s location.
BannerView:longitude=” -122.406728″ Longitude of user’s location.
BannerView:locationUpdateEnabled=”true”true, falseEnable transmission of location data.
BannerView:zip=”94108″ User’s zip code.

Using Toaster Style Banners

We are also offering a banner view which use a Toaster Style (Translate in screen when a banner is ready and off screen when the banner is clicked or the user dismiss it using a close button ), you can integrate the Toaster banner using

 ToasterBanner mToaster = new ToasterBanner(context, myRootRelativeLayout);
Where myRootRelativeLayout is the root relative layout in your activity. ToasterBanner implements also the same methods as BannerView. When you successfully load a new banner, as described in the BannerView section, the banner will automatically appear inside the screen.
 

disappearAndDestroy() Method (new) 

disappearAndDestroy() method is to hide and destroy the ToasterBanner. This method internally calls disappear method and handles removing all childViews.

Example usage, invoke this method from onDestroy()

Using an Alert Banner

Alert banner is using the AlertDialog from Android, which will appear as an alert and containing an Ad. With the AlertBanner you can also use the same methods described for the BannerView. There is to types of alert view, the first one is the FullScreenBanner

FullScreenBanner mAlertBanner = new FullScreenBanner(context); 
The second type is the AlertBanner, which will only request text ads, and will not contain a banner view, but a text ad, and an open and close button. Open button will open the default device browser and close button will simply dismiss the alert. In order to use this banner type, you need first to instantiate an object from AlertBanner. In your activity type the following line
AlertBanner mAlertBanner = new AlertBanner(context); 
Please use the same methods described for BannerView in order to set your IDs, targeting options etc…

To fetch a new banner use

mAlertBanner.asyncLoadNewBanner(); 
You are also able to modify the alert title using
mAlertBanner.setTitle(“your title”); 

Listener available

As the BannerView offers, with the AlertBanner you can also implement your AdListenerInterface (Please see description in BannerView)

In order to have more information about the alert banner states you can implement your AlertBannerStateListener using

mAlertBanner.setAlertBannerStateListener(new AlertBannerStateListener() {
 public void onWillShowBanner() {
   // Banner was loaded and will show
 }
 public void onWillLeaveActivity() {
   // User clicked on the banner.
 }
 public void onWillCancelAlert() {
   // User dismissed the alert.
 }
});

Interstitials

Starting from version 4.0, our SDK is supporting the Interstitial Banner format as well. In order to use this banner format, please integrate as described below:

First of all, declare an Interstitial variable using:

Interstitial interstitial;

In your onCreate or in your onResume, please ad the following lines

interstitial = new Interstitial(this); //this, supposed to be your activity
interstitial.setInterstitialAdListener(this); // your activity need to implements InterstitialAdListener interface
interstitial.getAdSettings().setPublisherId(your_publisher_id);
interstitial.getAdSettings().setAdspaceId(your_adspace_d);

 

in order to load a new banner, please use

interstitial.asyncLoadNewBanner();

 

as soon as a banner has been loaded, the method onReadyToShow() will be called, otherwise onFailedToLoadAd() will be called.

When a banner was successfully loaded, you need to call show() method using

interstitial.show();

Destroy the Interstitial Ad

When you finish using the interstitial ad unit and want to clean up memory usage, please call the destroy() method as per the following:

@Override
public void onDestroy() {
   interstitial.destroy();
   super.onDestroy();
}

Debug Mode

Our SDK is offering different debug mode which are described below

  • Level_0 : No log Output.
  • Level_1 : Normal Log output (Used by default).
  • Level_2 : Advanced Log Output (Level_1 + Errors/Exceptions)
  • Level_3 : Expert level (Level_1 + Level_2 + Method tracing)

you can change the debug level using (Please set the desired debug before instantiating any type of BannerViews)

Debugger.setDebugMode(Debugger.Level_1);

PS : You can find an Integration Sample for every single Banner Format in our Demo App, please import the project in your workspace and have a quick look to the integration code, you can see how it works.

Video Ads

Similar to interstitial ad units, video ads are shown in full screen mode and can be placed before, in between or after the app content. The video ad will be loaded in background, and will be waiting for a signal to show up.

First of all, the Video Player requires activity declaration in your AndroidManifest.xml as well:

<activity android:name="com.smaato.soma.video.VASTAdActivity" android:configChanges="keyboardHidden|orientation|screenSize">
</activity>

Next, you will need to instantiate a Video object in the activity where you want to show video ads and to implement the VASTAdListener interface to have more control on the Video ads. Your IDE will ask you to implement following methods:

import com.smaato.soma.video.VASTAdListener;
public class MyActivity implements VASTAdListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.myLayout);
		Video videoAd = new Video(MyActivity.this);
	}
	// Called when the banner has been loaded.
	public void onReadyToShow() {
		// TODO
		// Call this when you want to show the video ad.
		videoAd.show();
	}

	// Called when the ad will show.
	public void onWillShow() {
		// TODO
	}

	// Called when the banner has been clicked.
	public void onWillOpenLandingPage() {
		// TODO
	}

	// Called when Interstitial ad will be close.
	public void onWillClose() {
		// TODO
	}

	// called when banner failed to load.
	public void onFailedToLoadAd() {
		// TODO
	}
}

Of course, you will need to provide the SDK with your Smaato Publisher and AdSpace IDs, please use the following code for that:

videoAd.getAdSettings().setPublisherId(REPLACE_WITH_YOUR_PUBLISHER_ID);
videoAd.getAdSettings().setAdspaceId(REPLACE_WITH_YOUR_ADSPACE_ID);

Finally, to load a new video ad, use following method :

videoAd.asyncLoadNewBanner();

Auto-Close Feature:

From Android SDK 5.1.0 version on, you can configure an auto-close duration in seconds, to auto-close after a given number of seconds upon Interstitial Video Ad completion.

By default, auto-close is enabled. After the video completion, the ad will automatically close after the default duration of 3 seconds.

videoAd.setAutoCloseDuration(5);   // default value is 3 seconds

 

You can also completely disable the auto-close feature on VAST Ad completion. 

 videoAd.disableAutoClose(true);   // default value is false.

Configurable Skip button:

From Android SDK 5.1.0 version on, you can also configure a Skip button appearance after a duration in seconds. By default, videos are skippable after 15 seconds. 

videoAd.setVideoSkipInterval(5);   // default value is 15 seconds

Rewarded Video Ads

Similar to interstitial ad units, rewarded video ads are shown in full screen mode and can be placed before, in between or after the app content.

The video ad will be loaded in the background and will be waiting for a signal to show up.

First of all, the Rewarded Video Player requires the following activity declaration in your AndroidManifest.xml: 

 

<activity android:name="com.smaato.soma.video.VASTAdActivity" android:configChanges="keyboardHidden|orientation|screenSize">
</activity>

 

Next, you will need to instantiate a Rewarded Video object in the activity where you want to show Rewarded Video ads and to implement the RewardedVideoListener interface to have more control on the Rewarded Video ads. 

import com.smaato.soma.video.RewardedVideo;
import com.smaato.soma.video.RewardedVideoListener;

public class MyActivity extends Activity implements RewardedVideoListener {

    RewardedVideo rewardedVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rewardedvideo_sample);
        rewardedVideo = new RewardedVideo(MyActivity.this);
    }

    // Called when the banner has been loaded.
    @Override
    public void onReadyToShow() {
        rewardedVideo.show();   // call this when to show the RewardedVideo ad.
    }

        // Called when the ad will be displayed.
        @Override
        public void onWillShow() { }

		// Called when the RewardedVideo or the EndCard is clicked after video completion
        @Override
        public void onWillOpenLandingPage () { }

        // Called when the ad is closed.
        @Override
        public void onWillClose () { }

        // Called when there is No ad or Ad failed to Load
        @Override
        public void onFailedToLoadAd () { }

        @Override
        public void onRewardedVideoStarted () { }

        @Override
        public void onFirstQuartileCompleted () { }

        @Override
        public void onSecondQuartileCompleted () { }

        @Override
        public void onThirdQuartileCompleted () { }

        // Called when the Video ad display completed.
        @Override
        public void onRewardedVideoCompleted () { } // TODO

    } 

You can configure an auto-close duration in seconds, to auto-close after completion of the Rewarded Video ad.

rewardedVideo.setAutoCloseDuration(5);   // default value is 3 seconds

You can also completely disable the auto close feature.

rewardedVideo.disableAutoClose(true);   // default value is false

Of course, you will need to provide the SDK with your Smaato Publisher and AdSpace IDs, please use the following code for that:

 

rewardedVideo.getAdSettings().setPublisherId(REPLACE_WITH_YOUR_PUBLISHER_ID);
rewardedVideo.getAdSettings().setAdspaceId(REPLACE_WITH_YOUR_ADSPACE_ID);

Finally, to load a new video ad, use the following method :

rewardedVideo.asyncLoadNewBanner();

Native Ads

Native ads are designed in a way that respond exactly to your needs. With native ads, you're able to show ads in your apps that look completely the same as your app content. That means, more control for you, better design for your users, better user experience and of course more revenue for you!

Smaato Native Ads Serving Template (SNAST) gives you the flexibility to choose which elements you need for your ad space. Currently, we've got the following items available :

  • Ad Title
  • Ad Text
  • Icon Image (80x80 pixels)
  • Main Image (1200x627 pixels)
  • Click to install text (e.g. Install, Read More etc...)
  • Star rating (only for app ads)

In order to start using native ads, you will need to go through following steps : 

  • Create all needed views (icon view, main image view, text views, rating bar etc...)
  • Put your views together so that they look similar to your app content
  • Pass the views to our SDK
  • and start requesting

After you created all the views, please proceed by passing the views to our SDK by using the following code:

NativeAd nativeAd = new NativeAd(this);
nativeAd.setClickToActionButton(ctaButton).setIconImageView(iconImage)
				.setMainImageView(mainImage).setTextView(nativeText)
				.setTitleView(nativeTitle).setMainLayout(nativeRelativeLayout).setRatingBar(ratingBar);

Next, you can start requesting ads by using the following method:

nativeAd.asyncLoadNewBanner();

After receiving the rendered Native Ad, you need to attach the native ad components and making them visible:

 

iconImage.setVisibility(View.VISIBLE);
mainImage.setVisibility(View.VISIBLE);
nativeText.setVisibility(View.VISIBLE);
ctaButton.setVisibility(View.VISIBLE);
nativeTitle.setVisibility(View.VISIBLE);
nativeRelativeLayout.setVisibility(View.VISIBLE);
ratingBar.setVisibility(View.VISIBLE);
 
// IMPORTANT step to be invoked after attaching the NativeAd. (SDK checks the native ad component visibility before firing Impression).
// IMPORTANT FOR IMPRESSIONS COUNTS & REVENUE.
nativeAd.registerImpression();

 

You can also get notified and know if we delivered an ad or not. To activate that, please let your activity implement our AdListenerInterface. Below is a sample code:

public class MyActivity implements AdListenerInterface

And of course, do not forget to register the listener by using following code :

nativeAd.setAdListener(MyActivity);

Native Ad Templates (new)

To start using Native Ad Templates, you will need to go through following steps : 

  • Create a RelativeLayout and set it as MainLayout.
  • Set the params (width & height without density, text size) to look similar to your App
  • Pass the NativeType to Smaato SDK and load new Ad
  • On successful Ad response, the generated NativeLayout (RelativeLayout) will be available with its elements based on the NativeType ( TitleView, RatingStar, Click to Action Button, Icon).
// Step 1:Declare properties
NativeAd nativeAd;
RelativeLayout nativeRelativeLayout;
 
// Step 2: Instantiate & Configure mandatory parameters
nativeAd = new NativeAd(this);
nativeRelativeLayout = (RelativeLayout) findViewById(R.id.nativeAdLayout);
nativeAd.setMainLayout(nativeRelativeLayout);
nativeAd.getAdSettings().setPublisherId(0);  // replace with your PublisherId
nativeAd.getAdSettings().setAdspaceId(3075); // replace with your AdSpaceId
 
// Following are non mandatory formatting as per your app (look and feel) requirements.
nativeAd.setTitleTextSize(15);
nativeAd.setWidthWithoutDensity(80);  // density calculation happens inside SDK for icons width
nativeAd.setHeightWithoutDensity(80); // default value is 70*density
 
// Step 3: Initiate new ad request by sending required NativeType and attach the Ad response using nativeAd.bindAdResponse(nativeView); 
 nativeAd.asyncLoadNativeType(NativeAd.NativeType.APP_WALL, new NativeAd.NativeAdTypeListener() {
   @Override
   public void onError(ErrorCode errorCode, String errorMessage) {      
      Log.e("OnErrorResponse", errorMessage); // No Ad Response is fine. Check for errorCode & errorMessage.
   }

    @Override
   public void onAdResponse(ViewGroup createdNativeLayout) {
         // if required, configure & format individual element of the generated Layout element before binding.
         //nativeAd.getIconImageView().setBackgroundColor(Color.BLUE); 
		 nativeAd.getTitleView().setTextColor(Color.BLUE);
         // IMPORTANT FOR IMPRESSION COUNT & BEACONS. Invoke bindAdResponse only after attaching mainLayout with visibility (VISIBLE).
         nativeAd.bindAdResponse(createdNativeLayout);
      }
});

 

Integrating other Templates (i.e. NativeLayout Types):

This implementation steps are similar for all other NativeLayout Types as well. Please bear in mind: NativeCarousel supports an ArrayList of ImageViews and accessible through nativeAd.getCarouselImages(). 

Send the required NativeType to the method nativeAd.asyncLoadNativeType.

The SmaatoDemoApp has sample implementations of all the NativeLayouts.

Using the Demo App

Within the SDK ZIP file, there's a demo app which shows an example of how to integrate our SDK, how to use it and how to implement desired options.

The demo app allows you to:

  • Use your Publisher and AdSpace IDs.
  • Request multiple Ad units (Text, Image, Rich Media, Medium Rectangle, Video).
  • Configure refresh time.
  • See how a banner can be used across multiple screen.
  • Use a classical BannerView
  • Use a full screen banner
  • Use interstitial banner
  • Use toaster banner
  • and how to instantiate banners directly from your xml layout.

Crash Reporting

Anonymous crash reporting helps us improve our services, and we don't collect any user- or app-specific information.

Crash reporting is enabled by default, and can be disabled using this method: Debugger.enableCrashReporting(false);

 

 

  • No labels