Mobpub cordova plugin


I installed mopub-cordova plugin and declared MoPub on home.ts put i’m getting error is showing MoPub function not defined.


declare let MoPub: any;
selector: ‘page-home’,
templateUrl: ‘home.html’
export class HomePage {

ad_units = {



constructor(public navCtrl: NavController, public platform: Platform) {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.

  if (MoPub) {
    MoPub( this.ad_units.banner );



ERROR Error: "Uncaught (in promise): ReferenceError: MoPub is not defined

Cordova plugin on the project

cordova-plugin-device 2.0.2 “Device”
cordova-plugin-extension 1.5.4 “Cordova Plugin Extension”
cordova-plugin-ionic-keyboard 2.0.5 “cordova-plugin-ionic-keyboard”
cordova-plugin-ionic-webview 1.1.19 “cordova-plugin-ionic-webview”
cordova-plugin-mopub 2.4.1 “MoPub”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-whitelist 1.3.3 “Whitelist”

Need help, please. Thanks,

Did you add it to the providers in the app.module.ts file?

1 Like

No i didn’t, and what exactly do i need to add to the providers?!
It is none native ionic plug-in, and don’t know what should i add in the provider?!

Here is the plug in:

Add Plugins to Your App’s Module
After installing a plugin’s package, add it to your app’s NgModule.

import { Camera } from ‘@ionic-native/camera’;


providers: [



export class AppModule { }

It is shwoing can’t find the module when import MoPub.

import {MoPub} from '../plugin/cordova-plugin-mopub/www/MoPub.js'

Realized that it does not have an Ionic Native Wrapper, sorry about that

Are you testing in the simulator or on device. Since it is a cordova plugin, you can not test it locally in a browser

Well, when i try to run it on the device it is showing error

at ChildProcess.whenDone (…/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

I would contact the plugin author for more assistance.

I would validate that the app compiles withOUT the plugin referenced at all, then try again.

I try many plugins, same issue couldn’t find function and can’t deploy on the android device.
then i saw article on the stackOver forum and i follow the instruction there but have same error,

i think problem for how to call function on the plugin.

I think problem with cordova last version , i downgrade cordova to 6.5 and implement heyzap cordova sdk,
I finally nailed it.