Mobpub cordova plugin


#1

Hi,

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

home.ts

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

ad_units = {

  banner:"xxxxxxxxxx",
  interstitial:"xxxxxxx"

}

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 Error: "Uncaught (in promise): ReferenceError: MoPub is not defined
HomePage/<@http://localhost:8100/build/main.js:191:1

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,


#2

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


#3

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:

https://www.npmjs.com/package/cordova-plugin-mopub


#4

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’;

@NgModule({

providers: [

Camera

]

})
export class AppModule { }


#5

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

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


#6

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


#7

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

BUILD FAILED in 41s
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)


#8

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.


#9

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.


#10

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