Refresh

This website github-wiki-see.page/m/tapdaq/cordova-plugin/wiki/Quickstart is currently offline. Cloudflare's Always Online™ shows a snapshot of this web page from the Internet Archive's Wayback Machine. To check for the live version, click Refresh.

Quickstart - tapdaq/cordova-plugin GitHub Wiki

Installation of the Cordova SDK

Contents

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

  • Cordova CLI: 10.0.0
  • Cordova iOS: 6.0.0
  • Cordova Android: 9.0.0

For iOS to integrate the latest Tapdaq SDK, the Deployment target must be 8.0 or higher and be built with Xcode 11.0 or newer. If using an older version of Xcode then 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 12.0 Deployment Target: 9.0
AdMob 16 Xcode 11.0 Deployment Target: 9.0
AppLovin 16 Xcode 8.0 Deployment Target: 9.0
Chartboost 21 Xcode 8.0 Deployment Target: 10.0
Facebook AN 14 Xcode 8.0 Deployment Target: 9.0
InMobi 15 Xcode 11.0 Deployment Target: 9.0
Maio 16 Xcode 11.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 12.0 Deployment Target: 8.0
YouAppi 16 Xcode 10.2 Deployment Target: 9.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

false Select Adapters To integrate an ad network adapter into your project, use the following commands 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-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 > The **cordova build** command may need to be run after adding plugins

C. Enable AndroidX

Tapdaq Android requires AndroidX, enable it in one of the following ways:

Cordova-Android 9.0.0 and above

In the config.xml add the following preference:

<widget>
    <preference name="AndroidXEnabled" value="true" />
</widget>

Cordova-Android pre 9.0.0

Add this plugin (or alternative) to enable AndroidX

cordova plugin add cordova-plugin-androidx

D. Enable Multidex

For large Android projects which include over 65k references, multidex may be necessary. To enable it, simply add this plugin (or alternative).

Note: This is not necessary for iOS only projects

cordova plugin add cordova-plugin-enable-multidex

E. Add SKAdNetworkIds

iOS 14 Apple documentation recommends adding SKAdNetworkIds for each network which has been integrated, these ID's may change so please check the documentation for the latest ID's.

SKAdNetworkItems key should be added to the app's Info.plist with type array. For each network ID a dictionary item should be added. Each dictionary should containt a single key-value pair with the key SKAdNetworkIdentifier and value being the ID string. This can be done via the Config.xml like so:

<widget>
    <platform name="ios">
        <config-file target="*-Info.plist" parent="SKAdNetworkItems">
            <array>
                <dict>
                    <key>SKAdNetworkIdentifier</key>
                    <string>zzzzz.skadnetwork</string>
                </dict>
                <dict>
                    <key>SKAdNetworkIdentifier</key>
                    <string>xxxxx.skadnetwork</string>
                </dict>
            </array>
        </config-file>
    </platform>
</widget>

All of the ID's are maintained in this document and can also be found on each networks documentation

Network ID Link
AdColony Multiple Docs
AdMob cstr6suwn9.skadnetwork Docs
AppLovin Multiple Docs
Chartboost Multiple Docs
Facebook AN Multiple Docs
InMobi Multiple Docs
IronSource su67r6k2v3.skadnetwork Docs
Maio v4nxqhlyqp.skadnetwork Docs
Pangle Multiple Docs
Tapjoy Multiple Docs
UnityAds Multiple Docs
Vungle Multiple Docs
YouAppi N/A Docs

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.

⚠️ **GitHub.com Fallback** ⚠️