npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adivery-cordova

v4.5.11

Published

Ultimate Cordova Plugin for Adivery to monetize hybrid apps. Show mobile Ad with single line of JavaScript. Compatible with Cordova CLI, PhoneGap Build, Ionic, etc.

Downloads

9

Readme

Adivery Plugin

Cordova / PhoneGap Plugin for Adivery.

Contents

  1. Description
  2. Features
  3. Demo
  4. Quick Start
  5. Installation
  6. Usage
  7. API
  8. License
  9. Credits

Description

This Cordova / PhoneGap plugin enables displaying mobile Ads with single line of javascript code. Designed for the use in HTML5-based cross-platform hybrid games and other applications.

Features

Platforms supported:

  • [ ] Amazon-FireOS, via Android SDK (part of Google Play service)
  • [x] Android, via Android SDK (part of Google Play service)
  • [ ] iOS
  • [ ] Windows Phone

Ad Types:

  • [x] Banner
  • [x] Interstitial
  • [x] Reward Video
  • [x] Native Ads
  • [x] Native Ads Advanced
  • [x] AppOpen Ads

Quick Demo

To quickly test this plugin and see ads on your devices use commands bellow.

    # install cordova CLI
    [sudo] npm install cordova -g

    # install a small utility to run all the commands for you
    [sudo] npm install plugin-verify -g

    # Demo: run adivery demo with sample index.html
    plugin-verify adivery-cordova-plugin

Quick start

	# create a demo project
    cordova create test1 com.adivery.example Test1
    cd test1
    cordova platform add android

    # now add the plugin, cordova CLI will handle dependency automatically
    cordova plugin add adivery-cordova-plugin

    # now remove the default www content, copy the demo html file to www
    rm -r www/*;
    cp plugins/adivery-cordova-plugin/test/* www/;

	# now build and run the demo in your device or emulator
    cordova prepare; 
    cordova run android;
    # or import into eclipse

Installation

  • If use with Cordova CLI:
cordova plugin add adivery-cordova-plugin
  • If use with PhoneGap Build:
<plugin name="adivery-cordova" source="npm"></plugin>

Notice:

  • If build locally using adivery-cordova, to avoid build error, you need install some extras in Android SDK manager (type android sdk to launch it): android extra

Usage

Show Mobile Ad with single line of javascript code.

Initialization

Create new application, in Adivery portal, then write it in your javascript code and replace AppID with the ID generated for your application in Adivery panel.

Adivery.initialize('AppID');

Banner ads

To create banner ads in your application use code bellow.

// it will display small banner at top center, using the default options
Adivery.createBanner(zoneId, Adivery.AD_POSITION.TOP_CENTER, Adivery.AD_SIZE.BANNER_SMALL);

Interstitial

To prepare Interstitial ads on your application run code bellow.

// prepare and load interstitial ad resource in background, e.g. at begining of game level
Adivery.prepareInterstitialAd(zoneId);
  • :alert: Adivery will automatically request next ad when current ad is displayed and there is no need to call prepareInterstitialAd again.

To get events related to Interstitial ads use code bellow.

document.addEventListener('onInterstitialAdLoaded', function(event) {
	if (typeof event.originalEvent !== 'undefined') event = event.originalEvent;
    var data = eevent.detail || event.data || event;

	console.log("Adivery InterstitialAd Loaded", data.placementId);
});

Rewarded

To prepare Rewarded ads on your application use code bellow.

// prepare and load Rewarded ad resource in background, e.g. at begining of game level
Adivery.prepareRewardedAd(zoneId);
  • :alert: Adivery will automatically request next ad when current ad is displayed and there is no need to call prepareRewardedAd again.

To get events related to rewarded ads use code bellow.

document.addEventListener('onRewardedAdClosed', function(event) {
	if (typeof event.originalEvent !== 'undefined') event = event.originalEvent;
    var data = eevent.detail || event.data || event;

	console.log("Adivery RewardedAd closed, isRewared:", data.isRewarded);
});

AppOpen

To prepare AppOpen ads on your application run code bellow.

// prepare and load interstitial ad resource in background, e.g. at begining of game level
Adivery.prepareAppOpenAd(zoneId);
  • :alert: Adivery will automatically request next ad when current ad is displayed and there is no need to call prepareInterstitialAd again.

To get events related to Interstitial ads use code bellow.

document.addEventListener('onAppOpenAdLoaded', function(event) {
	if (typeof event.originalEvent !== 'undefined') event = event.originalEvent;
    var data = eevent.detail || event.data || event;

	console.log("Adivery AppOpen Loaded", data.placementId);
});

Displaying Ads

To display ads just call showAd or showAppOpenAd depending on if you want to display interstitial, rewareded ads or AppOpen ads.

Adivery.showAd('ZoneId');

Adivery.showAppOpenAd('ZoneId');

Native Ads

To get a Native ad use requestNativeAd function to load a native ad.

Adivery.requestNativeAd('ZoneId`);

To get loaded ad and begin displaying it, use this code.

document.addEventListener('nativeAdLoaded', function(event) {
	if (typeof event.originalEvent !== 'undefined') event = event.originalEvent;
    var data = eevent.detail || event.data || event;

	console.log(data['headline']);
	console.log(data['description']);
	console.log(data['advertiser']);
	console.log(data['callToAction']);
	console.log(data['icon']);
	console.log(data['image']);
});

Handling impression and click of Native ads

To record Impression of native ad in your application use this code.

Please have in mind to call this code only and only if Ad is displayed to the user.

Adivery.recordNativeAdImpression();

Finally to record click of native ads, use this code.

Please have in mine, calling this function will navigate user to market or web browser depending on what ad is dispaying, so call it when user actually clicks on CTA button.

Adivery.recordNativeAdClick();

API

Methods:

// initialize plugin
initialize(AppID);
setLoggingEnabled(logEnabled);

// use banner
createBanner(zoneId, position, size);
createBannerAtXY(zoneId, x, y, size);
removeBanner();
showBanner();
hideBanner();

// use native
requestNativeAd(zoneId);
recordNativeAdImpression();
recordNativeAdClick();

// use interstitial/rewarded
prepareInterstitialAd(zoneId);
prepareRewardedAd(zoneId);
showAd(zoneId);

// use app open ads
prepareAppOpenAd(zondId);
showAppOpenAd(zoneId);

Events:

// onAdLoaded
// onAdRewarded
// onShowFailed
document.addEventListener('onBannerAdClicked', function(e){
    // handle the event
	// no data will be passed to this event
});
document.addEventListener('onBannerAdLoaded', function(e){
    // handle the event
	// no data will be passed to this event
});
document.addEventListener('onBannerAdShown', function(e){
    // handle the event
	// no data will be passed to this event
});
document.addEventListener('nativeAdClicked', function(e){
    // handle the event
	// no data will be passed to this event
});
document.addEventListener('nativeAdLoadFailed', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.message);
});
document.addEventListener('nativeAdLoaded', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
    console.log("native ad loaded", data['headline']);
    console.log("native ad loaded", data['advertiser']);
    console.log("native ad loaded", data['description']);
    console.log("native ad loaded", data['callToAction']);
    console.log("native ad loaded", data['icon']);
    console.log("native ad loaded", data['image']);
});
document.addEventListener('nativeAdShown', function(e){
    // handle the event
	// no data will be passed to this event
});
document.addEventListener('onAppOpenAdClicked', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onAppOpenAdClosed', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onAppOpenAdLoaded', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onAppOpenAdShown', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onInterstitialAdClicked', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onInterstitialAdClosed', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onInterstitialAdLoaded', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onInterstitialAdShown', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onRewardedAdClicked', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onRewardedAdClosed', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
    consoleLog("onAdClosed, reward: " + data.isRewarded);
});
document.addEventListener('onRewardedAdLoaded', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onRewardedAdShown', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
});
document.addEventListener('onError', function(e){
    // handle the event
	if (typeof e.originalEvent !== 'undefined') e = e.originalEvent;
	var data = e.detail || e.data || e;
	consoleLog("onAdLoaded. Type: " + data.placement);
	consoleLog("onAdLoaded. Type: " + data.message);
});

License

You can use the plugin for free.

Credits

This project is created and maintained by Milad Mohammadi and then updated to latest fearures by Adivery Team.

More Cordova/PhoneGap plugins by Milad Mohammadi, find them in plugin registry, or find them in npm.

More about Adivery