将cordova mopub与ionic 2集成

时间:2018-07-09 09:54:59

标签: ionic-framework ionic2 cordova-plugins mopub

我为cordova插件安装了mopub,并在home.ts上声明了MoPub。我得到的错误是未定义MoPub函数。

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

Cordova插件

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"

需要帮助。 谢谢,

0 个答案:

没有答案