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

capacitor-mopub

v0.1.0

Published

This is Ionic Capacitor native MoPub plugin for IOS & Android

Downloads

3

Readme

Capacitor MoPub 💸

Capacitor MoPub is a native Twitter MoPub implementation for IOS & Android. Now you can use this package as a Ionic Capacitor Plugin in your App.

Release Note 0.1.0:

NOTE: This is the Initial release of this plugins. You may find some issue in this version. Please feel free to create an Issue.

Supported Platform

  • [x] Android
  • [] iOS
  • [] Electron

Other Plugins:

| Plugins | Android | iOS | Electron | PWA | | :------------- | :------------- | :------------- | :------------- | :------------- | | AdMob | ✅ | ❌ | ❌ | ❌ |

MoPub Demo App

Screenshot

| Basic Banner | TabBar Banner | Interstitial | RewardVideo | | ------------- | ------------- | --------------------- | --------------------- | Basic MoPub Banner | Basic AdMob Banner | Basic AdMob Banner | Basic AdMob Banner |

Download

Download Demo App from Here

cd demo

npm install

ionic build

npx cap copy

npx cap sync 

npx cap update

npx cap open android

============== Or just use this command ===========

npm install & ionic build & npx cap copy & npx cap sync & npx cap update & npx cap open android

Installation

Use MoPub plugins in your app.

 npm install --save capacitor-mopub

📌 Register MoPub to Capacitor

Open your Ionic Capacitor App in Android Studio, Now open MainActivity.java of your app and Register MoPub to Capacitor Plugins.

// Other imports...
import app.xplatform.capacitor.MoPub;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      
      add(MoPub.class);  // Add MoPub as a Capacitor Plugin

    }});
  }
}

📌 BANNER

prepareBanner(options: AdOptions): Promise<{ value: boolean }>

import { Plugins } from '@capacitor/core';
import { AdOptions, AdSize } from 'capacitor-mopub';

const { MoPub } = Plugins;

@Component({
  selector: 'app-home',
  templateUrl: 'home.component.html',
  styleUrls: ['home.component.scss']
})
export class HomeComponent implements OnInit {


    constructor() {}

    ngOnInit() {
      // Show Banner Ad
      const options: AdOptions = {
        adId: 'b195f8dd8ded45fe847ad89ed1d016da',
        adSize: AdSize.MATCH_VIEW,
        autoShow: true,
        autoRefresh: true
      }


      // Register to an Event Listener
      MoPub.prepareBanner(options)
        .then(
          (value) => { console.log(value); }, // true
          (error) => { console.error(error); } // show error
        );
    }
}

hideBanner(): Promise<{ value: boolean }>

// Hide the banner, remove it from screen, but can show it later

MoPub.hideBanner()
  .then(
    (value) => { console.log(value); }, // true
    (error) => { console.error(error); } // show error
  );

resumeBanner(): Promise<{ value: boolean }>

// Resume the banner, show it after hide

MoPub.resumeBanner().then(
    (value) => { console.log(value); }, // true
    (error) => { console.error(error); } // show error
);

removeBanner(): Promise<{ value: boolean }>

// Destroy the banner, remove it from screen.

MoPub.removeBanner()
  .then(
    (value) => { console.log(value); }, // true
    (error) => { console.error(error); } // show error
  );

Event Listener

This following Event Listener can be called in Banner AD.

addListener(eventName: 'onAdLoaded', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onBannerFailed', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onBannerClicked', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onBannerExpanded', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onBannerCollapsed', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onBannerPrepared', listenerFunc: (info: any) => void): PluginListenerHandle;

📌 INTERSTITIAL

prepareInterstitial(options: AdOptions): Promise<{ value: boolean }>

import { Plugins } from '@capacitor/core';
import { AdOptions, AdSize } from 'capacitor-mopub';

const { MoPub } = Plugins;

@Component({
  selector: 'app-home',
  templateUrl: 'home.component.html',
  styleUrls: ['home.component.scss']
})
export class HomeComponent implements OnInit {


    constructor() {}

    ngOnInit() {
      // Interstitial Ad Optios
      const options: AdOptions = {
        adId: '24534e1901884e398f1253216226017e',
        autoShow: true,
        isTesting: true
      }

      // Prepare Interstial Ad
      MoPub.prepareInterstitial(options)
        .then(
          (value) => { console.log(value); }, // true
          (error) => { console.error(error); } // show error
        );
    }


    // Show Interstitial Ads
    showInterstitial() {
      
      MoPub.showInterstitial()
        .then(
          (value) => { console.log(value); }, // true
          (error) => { console.error(error); } // show error
        );
    }   
}

showInterstitial(): Promise<{ value: boolean }>

// Show interstitial ad when it’s ready

MoPub.showInterstitial()
  .then(
    (value) => { console.log(value); }, // true
    (error) => { console.error(error); } // show error 
  );

Event Listener

This following Event Listener can be called in Interstitial AD

addListener(eventName: 'onInterstitialLoaded', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onInterstitialFailed', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onInterstitialShown', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onInterstitialClicked', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onInterstitialDismissed', listenerFunc: (info: any) => void): PluginListenerHandle;

📌 RewardVideo

prepareRewardVideo(options: AdOptions): Promise<{ value: boolean }>

import { Plugins } from '@capacitor/core';
import { AdOptions, AdSize } from 'capacitor-mopub';

const { MoPub } = Plugins;

@Component({
  selector: 'app-home',
  templateUrl: 'home.component.html',
  styleUrls: ['home.component.scss']
})
export class HomeComponent implements OnInit {


    constructor() {}

    ngOnInit() {
      // RewardVideo Ad Optios
      const options: AdOptions = {
        adId: '920b6145fb1546cf8b5cf2ac34638bb7',
        autoShow: true,
        isTesting: true
      }

      // Prepare RewardVideo Ad
      MoPub.prepareRewardVideo(options)
        .then(
          (value) => { console.log(value); },
          (error) => { console.log(error); }
        );
    }


    // Show RewardVideo Ads
    showRewardVideo() {
      MoPub.showRewardVideo()
        .then(
          (value) => { console.log(value); }, // true
          (error) => { console.error(error); } // show error
        );
  }  
}

showRewardVideoAd(): Promise<{ value: boolean }>

// Show a RewardVideo AD

MoPub.showRewardVideo()
    .then(
      (value) => { console.log(value); }, // true
      (error) => { console.error(error); } // show error
    );

Event Listener

This following Event Listener can be called in RewardedVideo

addListener(eventName: 'onRewardedVideoLoadSuccess', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoLoadFailure', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoStarted', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoPlaybackError', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoClicked', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoClosed', listenerFunc: (info: any) => void): PluginListenerHandle;

addListener(eventName: 'onRewardedVideoCompleted', listenerFunc: (info: any) => void): PluginListenerHandle;

API

📌 AdOptions

interface AdOptions {
  adId: string;       // Banner ad ID (required)
  adSize?: AdSize;
  hasTabBar?: boolean;
  tabBarHeight?: number; // Height in Pixal
  isTesting?: boolean;
  autoShow?: boolean;
  autoRefresh?: boolean;
  userId?: string;
}

📌 AdSize

enum AdSize {

  MATCH_VIEW = 'MATCH_VIEW',

  HEIGHT_50 = 'HEIGHT_50',

  HEIGHT_90 = 'HEIGHT_90',

  HEIGHT_250 = 'HEIGHT_250',

  HEIGHT_280 = 'HEIGHT_280'
}

Contributing

  • 🌟 Star this repository
  • 📋 Open issue for feature requests

Roadmap

License

Capacitor AdMob is MIT licensed.