Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Support for Android in cordova-plugin-adcolony #1

Merged
merged 7 commits into from
Nov 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

/.eslintrc.json
.eslintrc.json
.idea/
.DS_Store
94 changes: 81 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,112 @@
# cordova-plugin-adcolony
AdColony ads for Apache Cordova
AdColony ads for Apache Cordova.

iOS SDK version is 3.0.4.1
Allows you to integrate with AdColony from within a Cordova app, supporting both Android and iOS. Requires the AdColony SDK

WARNING: This plugin available only for iOS.
iOS SDK version is 3.2.1.0 64bit production

Android SDK version is 3.2.1

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 3](https://github.com/AdColony/AdColony-Android-SDK-3)

[AdColony iOS SDK 3](https://github.com/AdColony/AdColony-iOS-SDK-3)

I recommend that you use cocoapods to install the AdColony Framework dependency

# 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

If you are testing the Android Plugin, use the following demo APP\_ID and ZONE_ID:

APP\_ID=app185a7e71e1714831a49ec7

ZONE_ID=vz1fd5a8b2bf6841a0a4b826

For the iOS Plugin, use the following demo APP\_ID and ZONE_ID in the configureWithAppID method

APP\_ID=appbdee68ae27024084bb334a

ZONE_ID=vzf8e4e97704c4445c87504e

# Methods

#### AdColony.configureWithAppID(appID, zoneIDs, options)
Initial method wich connects to AdColony.
(string) appID - the appID of your app in AdColony Dashboard
([strings]) zoneIDs - array of your ad zones ids
options - app options defined [here](https://adcolony-www-common.s3.amazonaws.com/Appledoc/3.1.0/Classes/AdColonyAppOptions.html) - I will implement this in next updates, now it should be null.
options - app options defined [here](https://adcolony-www-common.s3.amazonaws.com/Appledoc/3.1.0/Classes/AdColonyAppOptions.html)

#### AdColony.setAppOptions(options)
Set App Options.
options - JSON Array typically with ONE element a JSON object with the options. Options defined [here](https://adcolony-www-common.s3.amazonaws.com/Appledoc/3.1.0/Classes/AdColonyAppOptions.html)

#### AdColony.setAdOptions(options)
Set Ad options.
options - JSON Array typically with ONE element a JSON object with the options. Options defined [here](https://adcolony-www-common.s3.amazonaws.com/Appledoc/3.1.0/Classes/AdColonyAdOptions.html)

#### 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](https://adcolony-www-common.s3.amazonaws.com/Appledoc/3.1.0/Classes/AdColonyUserMetadata.html)


#### AdColony.requestInterstitialInZone(zoneID)
Request ad with given zoneID

#### AdColony.requestInterstitial()
Request ad with current zoneID

#### AdColony.registerRewardReceiver(rewardHandler)
Register the given Javascript method to handle rewards (Demo uses 'AdColony.onRewardReceived)

#### AdColony.showWithPresentingViewController()
After ad is loaded you can show it by calling this method.

# Events

```
document.addEventListener('Configuration successfully completed', (data) => {
document.addEventListener('ConfigureSuccess', () => {
console.log('AdColonyPlugin: Configuration successfully completed.');
});
```
```
document.addEventListener('Interstitial ad loaded', (data) => {
document.addEventListener('AdColonyRequestSubmitted', () => {
console.log('AdColonyPlugin: Interstitial ad requested.');
});
```
```
document.addEventListener('AdColonyRequestFilled', () => {
console.log('AdColonyPlugin: Interstitial ad loaded.');
});
```
```
document.addEventListener('Request interstitial failed with error', (error) => {
document.addEventListener('AdColonyRequestNotFilled', (error) => {
console.log('AdColonyPlugin: Request interstitial failed with error: ' + error);
});
```
```
document.addEventListener('Interstitial ad closed', (data) => {
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

Expand All @@ -57,22 +117,30 @@ let options = null;

AdColony.configureWithAppID(appID, zoneIDs, options);

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

document.addEventListener('Interstitial ad loaded', (data) => {
document.addEventListener('AdColonyRequestFilled', () => {
AdColony.showWithPresentingViewController();
});

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

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

```

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QVU9KQVD2VZML)
For a full working demo, I've created a Cordova App [AdColonyCordovaDemo on GitHub](https://github.com/ferdil/AdColonyCordovaDemo)


If you have saved some time using my work, do consider donating me something :-)

[Donations through PayPal gratefully accepted![paypal.me](https://www.paypalobjects.com/webstatic/paypalme/images/social/pplogo120_4_3.png)](https://www.paypal.me/LADEIRA137)

Original iOS only version Author:
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QVU9KQVD2VZML)
62 changes: 33 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
{
"name": "cordova-plugin-adcolony",
"version": "1.0.0",
"description": "AdColony ads for Apache Cordova",
"cordova": {
"id": "cordova-plugin-adcolony",
"platforms": [
"ios"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/notmedia/cordova-plugin-adcolony.git"
},
"keywords": [
"adcolony",
"ads",
"video",
"ad",
"plugin",
"ios",
"monetisation"
],
"author": "notmedia",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/notmedia/cordova-plugin-adcolony/issues"
},
"homepage": "https://github.com/notmedia/cordova-plugin-adcolony#readme"
}
"name": "cordova-plugin-adcolony",
"version": "1.1.0",
"description": "AdColony ads for Apache Cordova",
"cordova": {
"id": "cordova-plugin-adcolony",
"platforms": [
"ios",
"android"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/notmedia/cordova-plugin-adcolony.git"
},
"keywords": [
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"adcolony",
"ads",
"video",
"ad",
"plugin",
"ios",
"monetisation"
],
"author": "notmedia",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/notmedia/cordova-plugin-adcolony/issues"
},
"homepage": "https://github.com/notmedia/cordova-plugin-adcolony#readme"
}
68 changes: 53 additions & 15 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns=""
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-adcolony" version="1.0.0">
<name>AdColony Plugin</name>
<description>Cordova AdColony Plugin</description>
<description>Cordova AdColony Plugin by Ferdi Ladeira ferdi@smartmobiware.com</description>
<license>Apache-2.0</license>
<keywords>cordova,adcolony</keywords>
<author>Ferdi Ladeira</author>
<js-module src="www/AdColony.js" name="AdColony">
<clobbers target="window.AdColony" />
</js-module>

<engines>
<engine name="cordova-android"
version=">=3.5.0"/>
<engine name="cordova-ios"
version=">=4.0.0"/>
</engines>


<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="AdColonyPlugin">
<param name="ios-package" value="AdColonyPlugin"/>
</feature>
</config-file>
<header-file src="src/ios/AdColonyPlugin.h" />
<source-file src="src/ios/AdColonyPlugin.m" />
<framework src="src/ios/AdColony.framework" custom="true"/>
<header-file src="src/ios/AdColonyPlugin.h"/>
<source-file src="src/ios/AdColonyPlugin.m"/>
<framework src="AudioToolbox.framework"/>
<framework src="AdSupport.framework"/>
<framework src="AVFoundation.framework"/>
<framework src="CoreGraphics.framework" />
<framework src="CoreMedia.framework" />
<framework src="CoreTelephony.framework" />
<framework src="EventKit.framework" />
<framework src="CoreGraphics.framework"/>
<framework src="CoreMedia.framework"/>
<framework src="CoreTelephony.framework"/>
<framework src="EventKit.framework"/>
<framework src="EventKitUI.framework"/>
<framework src="libz.1.2.5.dylib" />
<framework src="MediaPlayer.framework" />
<framework src="MessageUI.framework" />
<framework src="QuartzCore.framework" />
<framework src="libz.1.2.5.dylib"/>
<framework src="MediaPlayer.framework"/>
<framework src="MessageUI.framework"/>
<framework src="QuartzCore.framework"/>
<framework src="Social.framework"/>
<framework src="StoreKit.framework"/>
<framework src="SystemConfiguration.framework" />
<framework src="WebKit.framework" />
<framework src="SystemConfiguration.framework"/>
<framework src="WebKit.framework"/>
</platform>
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.adcolony.sdk.AdColonyInterstitialActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"/>
<activity android:name="com.adcolony.sdk.AdColonyAdViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

</config-file>

<config-file target="res/xml/config.xml" parent="/*">
<feature name="AdColonyPlugin">
<param name="android-package" value="com.adcolony.plugin.AdColonyPlugin"/>
<param name="onload" value="true"/>
</feature>
</config-file>

<framework src="src/android/adcolony.gradle" custom="true" type="gradleReference"/>
<source-file src="src/android/com/adcolony/plugin/AdColonyPlugin.java" target-dir="src/com/adcolony/plugin"/>
<source-file src="src/android/proguard-project.txt" target-dir="./"/>
</platform>
</plugin>
12 changes: 12 additions & 0 deletions src/android/adcolony.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repositories {
jcenter()
maven {
url "https://adcolony.bintray.com/AdColony"
}
}

dependencies {
compile 'com.adcolony:sdk:3.2.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.support:support-annotations:25.0.1'
}
Loading