3.0.0 • Published 5 years ago

cordova-plugin-adcolony v3.0.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
5 years ago

AdColony

Allows you to integrate AdColony monetization platform with your Apache Cordova app.

Requirements

AdColony framework versions:

iOS SDK version is 4.1.0

Android SDK version is 4.1.0

Please make sure that you read the AdColony Project setup guides for both Android and iOS if you're building on both platforms.

All the documentation is available from here:

AdColony Android SDK

AdColony iOS SDK

This update integrates AdColony using a podspec in the plugin definition

Install plugin

$ cordova plugin add cordova-plugin-adcolony

See the AdColonyDemoApp code for how to configure and provide an APP_ID and a ZONE_ID within your JavaScript

Android

You will need to manually merge the contents of the file platforms/android/proguard-adcolony.txt to your existing project proguard-project.txt file (I need to figure out how to do this via a script still)

iOS

Please note that you must follow steps 2 onwards in the AdColony Project Setup notes (https://github.com/AdColony/AdColony-iOS-SDK/wiki/Project-Setup)

Methods

AdColony.configureWithAppID(appID, zoneIDs, options)

Initial method wich connects to AdColony.

AdColony.setAppOptions(options)

Set App Options.

ArgumentTypeDescription
optionsObjectJSON Array typically with ONE element a JSON object with the app options

AdColony.configureWithAppID(appID, zoneIDs, options)

Initial method wich connects to AdColony.

ArgumentTypeDescription
appIDstringthe appID of your app in AdColony Dashboard
zoneIDsstringsarray of your ad zones ids
optionsObjectarapp options defined here

AdColony.setAppOptions(options)

Set App Options.

ArgumentTypeDescription
optionsObjectJSON Array typically with ONE element a JSON object with the options. Options defined here

Note that I use the following strings from the Android SDK for cross-platform compatability

orientation
app_orientation
origin_store
disable_logging
user_id
gdpr_required
consent_string
test_mode
multi_window_enabled
mediation_network
mediation_network_version
plugin
plugin_version
keep_screen_on

AdColony.setAdOptions(options)

Set Ad options. options - JSON Array typically with ONE element a JSON object with the options. Options defined here

AdColony.setUserMetaData(metadata)

Set User meta-data for ad retrieval. Calling this sets the user metadata for all future ad requests metadata - JSON Array typically with ONE element a JSON object with the user meta-data. User meta-data defined here

ArgumentTypeDescription
metadataObjectJSON Array typically with ONE element a JSON object with the user meta-data

AdColony.requestInterstitialInZone(zoneID)

Request ad with given zoneID

ArgumentTypeDescription
zoneIdStringYour ad zone id

AdColony.requestInterstitial()

Request ad with current zoneID

AdColony.registerRewardReceiver(rewardHandler)

Register the given Javascript method to handle rewards (Demo uses 'AdColony.onRewardReceived'

ArgumentTypeDescription
rewardHandlerFunctionReward handler

AdColony.showWithPresentingViewController()

After ad is loaded you can show it by calling this method.

Events

document.addEventListener('ConfigureSuccess', () => {  
  console.log('AdColonyPlugin: Configuration successfully completed.');
});

document.addEventListener('AdColonyRequestSubmitted', () => {
 console.log('AdColonyPlugin: Interstitial ad requested.');
});

document.addEventListener('AdColonyRequestFilled', () => {
 console.log('AdColonyPlugin: Interstitial ad loaded.');
});

document.addEventListener('AdColonyRequestNotFilled', (error) => {
  console.log('AdColonyPlugin: Request interstitial failed with error: ' + error);
});

document.addEventListener('AdColonyRequestOpened', () => {
  console.log('AdColonyPlugin: Interstitial ad opened.');
});

document.addEventListener('AdColonyRequestClosed', () => {
  console.log('AdColonyPlugin: Interstitial ad closed.');
});

document.addEventListener('AdColonyRequestExpiring', () => {
  console.log('AdColonyPlugin: Interstitial ad expiring.');
});

Example

let appID = 'AdColonyAppID';
let zoneIDs = ['myZoneID1', 'myZoneID2'];
let options = null;

AdColony.configureWithAppID(appID, zoneIDs, options);

document.addEventListener('ConfigureSuccess', () => {  
   AdColony.requestInterstitialInZone(zoneIDs[0]);
});

document.addEventListener('AdColonyRequestFilled', () => {
 AdColony.showWithPresentingViewController();
});

document.addEventListener('AdColonyRequestClosed', () => {
  console.log('AdColonyPlugin: Interstitial ad closed.');
});

document.addEventListener('AdColonyRequestNotFilled', (error) => {
  console.log('AdColonyPlugin: Request interstitial failed with error: ' + error);
});

Also, Ferdil created great full working demo.

Thanks

Ferdil for the big PR #1

If you have saved some time using our work, do consider donating us something :) All donations I'll devide between all contributors.

paypal