Installation of the Cordova SDK

We recommend the latest Cordova, this plugin supports 9.0.0 and above.

  • Cordova CLI: 9.0.0
  • Cordova iOS: 5.0.1
  • Cordova Android: 8.0.0

For iOS to integrate the latest Tapdaq SDK please make sure Deployment Target is 8.0 and Xcode 11.0 or above is used. In order to build an app using older Xcode versions bitcode must be disabled.

For Android the minimum version support is API level 14.

The following networks have higher minimum requirements:

Network Android API Level Xcode iOS Deployment Target
AdColony 14 Xcode 11.0 Deployment Target: 8.0
AdMob 16 Xcode 10.0 Deployment Target: 8.0
AppLovin 16 Xcode 8.0 Deployment Target: 9.0
Chartboost 21 Xcode 8.0 Deployment Target: 8.0
Facebook AN 14 Xcode 8.0 Deployment Target: 9.0
InMobi 15 Xcode 11.0 Deployment Target: 9.0
Maio 16 Xcode 8.0 Deployment Target: 8.0
Pangle N/A Xcode 10.0 Deployment Target: 8.0
Tapjoy 14 Xcode 9.3 Deployment Target: 8.0
UnityAds 14 Xcode 8.0 Deployment Target: 9.0
Vungle 14 Xcode 11.0 Deployment Target: 8.0
YouAppi 16 Xcode 10.2 Deployment Target: 9.0
ZPlay 16 Xcode 8.0 Deployment Target: 8.0

1. Installation

A. Pre-requisites

Install or update Apache Cordova via npm:

npm install -g cordova

Add the platforms you wish to support:

cordova platform add android
cordova platform add ios

You will also need to install cocoapods for iOS, like so:

sudo gem install cocoapods

B. Add Tapdaq SDK


cordova plugin add @tapdaq/cordova-sdk


cordova plugin add @tapdaq/cordova-adcolony-adapter
cordova plugin add @tapdaq/cordova-admob-adapter
cordova plugin add @tapdaq/cordova-applovin-adapter
cordova plugin add @tapdaq/cordova-chartboost-adapter
cordova plugin add @tapdaq/cordova-fan-adapter
cordova plugin add @tapdaq/cordova-inmobi-adapter
cordova plugin add @tapdaq/cordova-ironsource-adapter
cordova plugin add @tapdaq/cordova-maio-adapter
cordova plugin add @tapdaq/cordova-mintegral-adapter
cordova plugin add @tapdaq/cordova-pangle-adapter
cordova plugin add @tapdaq/cordova-tapjoy-adapter
cordova plugin add @tapdaq/cordova-unityads-adapter
cordova plugin add @tapdaq/cordova-vungle-adapter
cordova plugin add @tapdaq/cordova-youappi-adapter
cordova plugin add @tapdaq/cordova-zplay-adapter


// add this if you want to support Android
cordova plugin add cordova-plugin-androidx
cordova plugin add cordova-plugin-enable-multidex
    

The cordova build command may need to be run after adding plugins

2. Initialise Tapdaq

To add in your iOS and Android App ID and Client Key, simply add the following inside your onDeviceReady() method.

var app: {
    ...
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
        
        const Tapdaq = cordova.require("cordova-plugin-tapdaq.Tapdaq");

        const config = {
            ios: {
                appId: "YOUR_IOS_APP_ID",
                clientKey: "YOUR_IOS_CLIENT_KEY"
            },
            android: {
                appId: "YOUR_ANDROID_APP_ID",
                clientKey: "YOUR_ANDROID_CLIENT_KEY"
            }
        };
        
        const opts = {
            didInitialise: function() {
                // Tapdaq has initialised
            },
            didFailToInitialise: function(error) {
                // Tapdaq failed to initialised
            }
        };

        Tapdaq.init(config, opts);
    }
};

You can find your App ID and Client Key by logging into the Tapdaq Dashboard, and then visiting Settings > General tab.

Note: If your app supports iOS and Android, you will need to create two separate apps on the Tapdaq dashboard.

Build and run your app to check the integration was successful.

cordova build ios 
cordova run ios

cordova build android
cordova run android

3. Update GDPR consent

Consent can be updated mid session as well as at initialisation, it can be set and unset.

Tapdaq.setUserSubjectToGDPR(Tapdaq.Status.TRUE);
Tapdaq.setConsent(Tapdaq.Status.TRUE);
Tapdaq.setAgeRestrictedUser(Tapdaq.Status.FALSE);

For Mintegral: for users outside the EU UserSubjectToGDPR must be set to FALSE to receive ads. For users inside the EU UserSubjectToGDPR must be TRUE with ConsentGiven also TRUE to receive ads.

4. Display an advert

To display an advert, please click on one of the following guides.

You can test that each ad network has been integrated correctly by visiting the Debugging page.

5. iOS specific steps

Please add the following entries in Target -> Info -> Custom iOS Target Properties. These steps are required when submitting your app to the App Store.

A. App Transport Security

App Transport Security (ATS), introduced in iOS 9, improves user security and privacy by requiring apps to use secure network connections over HTTPS. However, some ad network adapters still use insecure network connections in their ad serving. As such, please follow the steps below to ensure your app passes Apple’s review process:

App Transport Security Settings: Set the type to Dictionary and add the "Allow Arbitrary Loads" key as a 'Boolean' type and set the value to 'YES'

B. AdMob specific steps

You must also include you AdMob app ID in the app config.xml. This will then be automatically added to your info.plist when you build.

<widget>
    <platform name="ios">
        <config-file target="*-Info.plist" parent="GADApplicationIdentifier">
            <string>ca-app-pub-0000000000000000~0000000000</string>
        </config-file>
    </platform>
</widget>

C. AdColony specific steps

When including AdColony to your project, you must set the following three entries in order to submit your app to Apple:

NSCalendarsUsageDescription: Set the type to String and set the value to the following Some ad content may create a calendar event.

NSPhotoLibraryUsageDescription: Set the type to String and set the value to the following Some ad content may require access to the photo library.

NSCameraUsageDescription: Set the type to String and set the value to the following Some ad content may access camera to take picture.

NSMotionUsageDescription: Set the type to String and set the value to the following Some ad content may require access to accelerometer for interactive ad experience.

6. Android Specific Steps

A. AdMob Specific steps

You must also include you AdMob app ID in the app config.xml. This will then be automatically added to your AndroidManifest.xml when you build.

<widget>
<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-0000000000000000~0000000000"/>
    </config-file>
</platform>
</widget>

B. Facebook Audience Network

Videos ads on Facebook Audience Network require hardware acceleration to be enabled either on the application or activity level. See full details on the Facebook website

For Android P (9.0) devices, in order to load ads a config must be added to the AndroidManifest.xml, see full details on the Facebook website

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.