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

nativescript-audience-network

v1.0.3

Published

Your awesome NativeScript plugin.

Downloads

10

Readme

nativescript-audience-network

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-audience-network

iOS currently not supported

Android

BANNER

Here are the supported functions:

createBanner

TypeScript

import * as AudienceNetwork from 'nativescript-audience-network';
import { isIOS } from "tns-core-modules/platform";

export class HomeComponent implements OnInit {


  ngOnInit(): void {
    
    // Init audienceNetwork SDK here.
    AudienceNetwork.initAds();
  }

  testing = true;
  createBanner() {
    let option: CreateBannerOptions = {
      // global test banner id
      androidBannerId: "<Your audience network banner id>",
      margins: {
        bottom: 10,
        // top:10
      },
      testing: true,
      size: AD_SIZE.STANDARD_BANNER,
    };
    AudienceNetwork.createBanner(option).then(
      () => (this.message = "Banner created"),
      (error) => (this.message = "Error creating banner: " + error)
    );
  }
}

INTERSTITIAL

To show a fullscreen ad, you can use this function. Note that Interstitial banners need to be loaded before they can be shown, and there are two ways to do that:

preloadInterstitial

Use this for instance while loading your view, so it's ready for the moment you want to actually show it (by calling showInterstitial).

preloadInterstitial(){
    let option: CreateInterstitialOptions = {
            "androidInterstitialId": "<Your audience network Interstitial id>",
            "testing": true,
            "onAdClosed": this.onInterstitialClosed.bind(this),
            "onAdClicked": this.onInterstitialClicked.bind(this)
    }
    AudienceNetwork.preloadInterstitial(option).then(
     ()=> {
      console.log(
        "interstitial preloaded - you can now call 'showInterstitial' whenever you're ready to do so"
      );
    }, (error)=> {
      console.log("preloadInterstitial error: " + error);
    }
  );
  }
  onInterstitialClosed() {
      console.log("ad closed");
  };
  onInterstitialClicked() {
      console.log("ad clicked");
  }

showInterstitial

At any moment after preloadInterstitial successfully resolves, you can call showInterstitial.

Note that when you want to use showInterstitial again, you also have to use preloadInterstitial again because those ads can't be reused.

 showInterstitial(){
    AudienceNetwork.showInterstitial()
 }

preloadRewardedVideoAd

Use this for instance while loading your view, so it's ready for the moment you want to actually show it (by calling showRewardedVideoAd).

 preloadRewardedVideoAd(){
    let option = {
      androidAdPlacementId: "<Your audience network RewardedVideo id>"
    }
    AudienceNetwork.preloadRewardedVideoAd(option).then(()=> {
      console.log(
        "RewardedVideoAd preloaded - you can now call 'showRewardedVideoAd' whenever you're ready to do so"
      );
    },(error)=> {
      console.log("preloadRewardedVideoAd error: " + error);
    }
  );
 }

showRewardedVideoAd

At any moment after preloadRewardedVideoAd successfully resolves, you can call showRewardedVideoAd.

Note that when you want to use showRewardedVideoAd again, you also have to use preloadRewardedVideoAd again because those ads can't be reused.

onRewarded is probably the only callback you need to worry about.

 showRewardedVideoAd(){
   let option: ShowRewardedOptions = {
        "onRewardedVideoAdClosed":this.onRewardedVideoAdClosed.bind(this),
        "onRewardedVideoAdOpened":this.onRewardedVideoAdOpened.bind(this),
        "onRewardedVideoCompleted":this.onRewardedVideoCompleted.bind(this),

      }
    AudienceNetwork.showRewardedVideoAd(option)
 }
  onRewardedVideoAdClosed(){
    console.log("onRewardedVideoAdClosed")
  }

  onRewardedVideoAdOpened(){
    console.log("reward clicked")
  }
  onRewardedVideoCompleted(){
    console.log("reward complete")
  }