2.9.0 beta Unity SDK Integration Guide

Get started

1. Get the app key

Add your app to Appodeal and get the app key for your application, as it is used during SDK integration.

2. Link your Admob account to Appodeal

Appodeal yields optimal results in cooperation with Admob. Use our application to link them. The application will allow Appodeal to access your Admob reports over API, and will create new ad units on Admob and submit them to Appodeal. Please, see this page for more information.

If you don't have Admob account, please sign up on  admob.com .


General Data Protection Regulation (GDPR) compliance

Publishers need to update their apps to collect the user consent prior to initializing our SDK (Read our guide on collecting consent  here ).

Publishers need to pass the boolean consent flag(with 'false' meaning that the user declined to give the consent) to the Appodeal.initialize() method of our SDK.

Appodeal.initialize(YOUR_APPODEAL_APP_KEY, adTypes, consentValue);

Integrate SDK 

You can use our demo app as a reference project.

Minimum OS requirements:

  • Unity 2017.4 or 2018.3+
  • Android API level 14 (Android OS 4.0). You can include Appodeal SDK in apps with lower minSdkVersion.
  • iOS 8.0 or higher. You still can integrate the Appodeal SDK into a project with a lower value of minimum iOS version. On the devices that don’t support iOS 8.0+ our SDK will just be disabled.

Mediation A/B testing

If you want to compare Appodeal's performance to another mediation, please follow this Mediation A/B testing guide .

1. Download SDK

Download Appodeal SDK 2.9.0 that includes the newest Android and iOS Appodeal SDK with major improvements, asynchronous ads loading support.

Use this plugin, If you are using MultiDex over custom gradle template, export to Android Studio or Eclipse with Andmore Plugin. Follow this guide to add Multidex.

 

You can also download this version from the Unity Asset Store.

2. Android configuration

1. Import the Appodeal Unity plugin

Open your project in the Unity Editor. Go to Assets → Import Package → Custom package and select the downloaded *.unityPackage file. Select all the files and press Import.  

2. Play Services Resolver

Appodeal plugin includes Play Services Resolver package.  You need to complete these following steps to resolve Appodeal's dependencies:

1. After the import Appodeal Unity Plugin, in the Unity editor select File → Build Settings → Android.

2. Then run Assets → Play Services Resolver → Android Resolver and press Resolve or Force Resolve.

3. As a result, the modules, that are required for the Appodeal SDK support, will be imported to your project. You can edit them or add other modules in the Assets → Appodeal → Editor → AppodealDependencies.xml file.

If you're using AndroidX in your app, make sure to use NoDex SDK version with enabled Jetifier

3. Configure AndroidManifest.xml

Add required permissions to your AndroidManifest.xml file under manifest tag:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Add optional permissions to your AndroidManifest.xml file under manifest tag to improve ad targeting:
<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.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
Add the following permissions necessary for the Mintegral network to work correctly to your AndroidManifest.xml under manifest tag:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/> <!--optional-->

If your app is targeting API level 28 (Android 9.0) or above, make sure to specify the requirement for Apache HTTP Legacy library. Include the following declaration within the <application> element of AndroidManifest.xml:

<uses-library
    android:name="org.apache.http.legacy"
    android:required="false" />

All the required AndroidManifest.xml tags are already added to the Appodeal Unity Plugin. If you don't want to use optional permissions, go to Plugins → Android → Appodeal, open AndroidManifest.xml and remove them from there.


4. Admob configuration

If you use Play Services version 17 and up, add the <meta-data> tag to AndroidManifest file. 

<manifest>
	<application>
		<meta-data
			android:name="com.google.android.gms.ads.APPLICATION_ID"
			android:value="[ADMOB_APP_ID]"/>
	</application>
</manifest>

Make sure to add Privacy Policy to your app on Google Play that links to Appodeal's Privacy Policy to avoid violating Google Play Developer Distribution Agreement.

3. iOS configuration

1. Play Services Resolver

Appodeal plugin includes Play Services Resolver package.  You need to complete these following steps to resolve Appodeal's dependencies:

1. After the import Appodeal Unity Plugin, in the Unity editor select File → Build Settings → iOS.

2. During build a project the modules, that are required for the Appodeal SDK support, will be imported to your project. You can edit them or add other modules in the Assets → Appodeal → Editor → AppodealDependencies.xml file.

2. Adding keys to info.plist:

Set up the following keys in info.plist of your app:

In order to serve ads, the SDK requires you to allow arbitrary loads.

1. Go to your info.plist file, then press Add+ anywhere in the first column of the key list.

2. Add App Transport Security Settingskey and set its type to Dictionary in the second column.

3. Press Add+ at the end of the name App Transport Security Settingskey and choose Allow Arbitrary loads. Set its type to Boolean and its value to Yes.

You can also add the key to your info.plist directly, using this code:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
4. You need to add a valid GADApplicationIdentifier: Add GADApplicationIdentifier into info.plist with type string as key and your app identifier as value.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

4. Known issues

AdColony presentation issue

AdColony always checks, if the key window’s rootViewController matches the passed rootViewController. Otherwise, Adcolony fails to present the ad. If your app has multiple independent windows, you can get a message with this or similar text:

AdColony [*** ERROR ***] : AdColony has ads, but could not display them. AdColony was unable to find the currently visible UIViewController for your app. Please ensure that your key UIWindow has a rootViewController.

It means, that the rootViewController that was used in showAd, doesn't belong to the first window in the array. 

GoogleMobileAds background playback issue

GoogleMobileAds will play music during ad downloading, if someone wants to change UserAgent on their custom UserAgent. The issue was detected in v. 7.33.1. This problem has not appeared in newer versions of the Google SDK (starting with v. 7.35.0), but then ads almost stop filling. 

GoogleMobileAds UIWebView crash iOS 13

Rendering of some of Google Mobile Ads creatives may be cause of crash. Workaround: You can force GoogleMobileAds to use WKWebView by adding following key value pair into your info.plist fail:

<key>gad_preferred_webview</key>
<string>wkwebview</string>

5. Initialize SDK

Before starting to load ads, you need to initialize the Appodeal SDK, as follows:

1. Import the namespaces:

using AppodealAds.Unity.Api;
using AppodealAds.Unity.Common;
2. Add the following code within the Start() method of your main scene’s MonoBehavior: 
Appodeal.initialize("YOUR_APPODEAL_APP_KEY", adTypes, consentValue);
consentValue is boolean, with 'false' meaning that the user declines to give the consent. Read our guide on collecting consent here.

Make sure to replace "YOUR_APPODEAL_APP_KEY" with the actual app key.

Use the type codes below to set the preferred ad format:

  • Appodeal.INTERSTITIAL for interstitial.
  • Appodeal.REWARDED_VIDEO for rewarded videos.
  • Appodeal.NON_SKIPPABLE_VIDEO for non-skippable videos.
  • Appodeal.BANNER for banners.
  • Appodeal.MREC for 300*250 banners.


Please note:

Ad types can be combined using "|" operator. For example, Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO.

Non-skippable and rewarded videos cannot be used simultaneously. If you are not sure, which ad formats would suit you the best, check out our FAQ.


Publish your app

iOS publication

1. Update Your IDFA Settings

When you submit your application to the AppStore, you need to update its "Advertising Identifier (IDFA)" settings in order to comply with Apple advertising policy.

1. Go to the Advertising Identifier section.

2. Set Yes on the right panel.

3. Tick Serve advertisements within the app and Attribute this app installation to a previously served advertisement. 

If your app gets rejected by the App Store because of some missing usage descriptions, add those of them you need to your info.plist file:

<key>NSLocationWhenInUseUsageDescription</key>
<string><App Name> needs your location for analytics and advertising purposes.</string>
<key>NSCalendarsUsageDescription</key>
<string><App Name> needs your location for analytics and advertising purposes.</string>

It's done!

You are ready to use Appodeal and implement ad types. If you have any questions, check out our FAQ or contact the support team. 

Third-party SDKs versions

NetworkAndroid SDK versioniOS SDK version
Adcolony4.1.04.1.1
Admob15.0.0-17.2.07.52.0
Amazon Ads5.9.02.2.17.1
Applovin9.9.26.9.3
Chartboost7.5.08.0.1
Facebook Audience Network5.5.05.6.0
Inmobi7.3.09.0.0
IronSource6.9.16.8.6.0
Mintegral9.13.55.8.1
myTarget5.4.75.3.5
Ogury4.1.3-
StartApp4.0.24.2.1
Smaato21.1.321.1.2
Tapjoy12.3.312.3.3
Unity Ads3.2.03.3.0
Vungle6.4.116.4.5
Yandex Metrica3.8.0-
Yandex Mobile Ads2.1102.13.3