Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

adivery

Simple plugin to display adivery ads in react-native android applications.

Installation

npm install adivery

Usage

import { Adivery, AdiveryBanner, Banner, LargeBanner, MediumRectangle } from "adivery";

// declare your placementIds

// these are test placements , replace with your own
const appOpenPlacement = "9e9dd375-a1fe-4c2b-8432-b5bf8a5095f6"
const rewardedPlacement = "3f97dc4d-3e09-4024-acaf-931862c03ba8"
const interstitialPlacement = "0045a4aa-1498-4790-9eed-6e33ac870e5f"
const adiveryAppId = "7e27fb38-5aff-473a-998f-437b89426f66"
const bannerPlacementId = "2f71ec44-f30a-4043-9cc1-f32347a07f8b"
const nativePlacementId = "25928bf1-d4f7-432c-aaf7-1780602796c3"

// initialize Adivery
Adivery.configure(adiveryAppId)

Display rewarded Ad

To display a rewarded ad first you need to prepare rewarded ad. this makes SDK to prepare rewarded ad and handle reloading it later.

Adivery.prepareRewardedAd(rewardedPlacement)

To show rewarded ad to user use the following code.

Adivery.isLoaded(rewardedPlacement).then((isLoaded) => {
      if ( isLoaded ){
        console.log("calling show")
        Adivery.showAd(rewardedPlacement)
      }
    })

Display interstitial Ad

To display a interstitial ad first you need to prepare rewarded ad. this makes SDK to prepare interstitial ad and handle reloading it later.

Adivery.prepareInterstitialAd(interstitialPlacement)

To show rewarded ad to user use the following code.

Adivery.isLoaded(interstitialPlacement).then((isLoaded) => {
      if ( isLoaded ){
        console.log("calling show")
        Adivery.showAd(interstitialPlacement)
      }
    })

Display app-open Ad

To display a app-open ad first you need to prepare rewarded ad. this makes SDK to prepare app-open ad and handle reloading it later.

Adivery.prepareAppOpenAd(appOpenPlacement)

To show rewarded ad to user use the following code.

Adivery.isLoaded(appOpenPlacement).then((isLoaded) => {
      if ( isLoaded ){
        console.log("calling show")
        Adivery.showAd(appOpenPlacement)
      }
    })

Display OfferWall Ad

OfferWall needs Adivery SDK 4.10.0-alpha.1 or later (this plugin version pins it).

To display an offer wall ad, first prepare it:

Adivery.prepareOfferWallAd(offerWallPlacement)

Once onOfferWallAdLoaded fires (see the callbacks below), show it:

Adivery.showAd(offerWallPlacement)

Unlike interstitial and rewarded ads, the SDK doesn't prepare another offer wall after one closes. Call prepareOfferWallAd again before each show. The example app prepares on tap and shows from onOfferWallAdLoaded:

Adivery.addGlobalListener({
  onOfferWallAdLoaded: (placementId) => {
    Adivery.showAd(placementId)
  },
})

// on tap:
Adivery.prepareOfferWallAd(offerWallPlacement)

Add Callback for fullscreen Ads.

If you want to get notified when a ad is loaded or user clicked on add you can use the following code

Adivery.addGlobalListener(
      {
        onRewardedAdLoaded: (placementId) => {
          console.log("rewarded loaded")
        },
        onRewardedAdShown: (placementId) => {
          console.log("rewarded shown")
        },
        onRewardedAdClicked: (placementId) => {
          console.log("rewarded clicked")
        },
        onRewardedAdClosed: (plcementId, isRewarded) => {
          console.log("rewarded closed: " + isRewarded)
        },
        onInterstitialAdLoaded: (placementId) => {
          console.log("interstitial loaded")
        },
        onInterstitialAdShown: (placementId) => {
          console.log("insterstitial shown")
        },
        onInterstitialAdClicked: (placementId) => {
          console.log("interstitial clicked")
        },
        onInterstitialAdClosed: (placementId) => {
          console.log("interstitial closed")
        },
        onAppOpenAdLoaded: (placementId) => {
          console.log("appOpen loaded")
        },
        onAppOpenAdShown: (placenentId) => {
          console.log("appOpen shown")
        },
        onAppOpenAdClicked: (placementId) => {
          console.log("appOpen clicked")
        },
        onAppOpenAdClosed: (placementId) => {
          console.log("appOpen closed")
        },
        onOfferWallAdLoaded: (placementId) => {
          console.log("offerWall loaded")
        },
        onOfferWallAdShown: (placementId) => {
          console.log("offerWall shown")
        },
        onOfferWallAdClicked: (placementId) => {
          console.log("offerWall clicked")
        },
        onOfferWallAdClosed: (placementId) => {
          console.log("offerWall closed")
        },
        onOfferWallMissionRewarded: (placementId, currency, rewardAmount) => {
          console.log("offerWall rewarded: " + rewardAmount + " " + currency)
        },
        onError: (placementId, message) => {
          console.log("onError: " + message)
        }
      }
    )

Display banner Ad.

To display a banner ad just simply add this code to your render function.

<AdiveryBanner 
    style={{width:this.state.w, height:this.state.h}} 
    placementId={bannerPlacementId} 
    bannerSize={this.state.bannerSize} 
    onAdLoaded={this.bannerLoaded} 
    onAdClicked={this.bannerClicked} 
    onError={this.bannerError} />

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages