ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
499 stars 214 forks source link

How fix TypeError #392

Open fujifujifuji opened 4 years ago

fujifujifuji commented 4 years ago

I using this pluginto show reward ads to users in my ionic app. I got an error when I clicked the button.

top.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { AdMobFree, AdMobFreeRewardVideoConfig, AdMobFreeRewardVideo } from '@ionic-native/admob-free/ngx';

@IonicPage()
@Component({
  selector: 'page-top',
  templateUrl: 'top.html',
})
export class TopPage {

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private admobFree: AdMobFree,
    private platform: Platform) {
  }

  ionViewDidLoad() {
    console.log('TopPage');
  }

  showRewardAd() {
    const rewardConfig: AdMobFreeRewardVideoConfig = {
      id: 'ca-app-pub-XXXXXXXXXXXXXXXXXXX',
      isTesting: true,
      autoShow: true
    };
    this.admobFree.rewardVideo.config(rewardConfig);

    this.admobFree.rewardVideo.prepare()
      .then(() => {
        console.log("Details screen : Reward video ad prepare successfull");
          this.admobFree.rewardVideo.show();
      })
      .catch(e => console.log(e));
  }
}

top.html

<ion-content class="top">
    <button ion-button (click)="showRewardAd();" class="user-info-btn">Show Ad</button>
</ion-content>

error

TopPage.html:33 ERROR TypeError: Object(...) is not a function
    at AdMobFreeRewardVideo.config (index.js:124)
    at TopPage.webpackJsonp.682.TopPage.showRewardAd (top.ts:37)
    at Object.eval [as handleEvent] (TopPage.html:33)
    at handleEvent (core.js:13589)
    at callWithDebugContext (core.js:15098)
    at Object.debugHandleEvent [as handleEvent] (core.js:14685)
    at dispatchEvent (core.js:10004)
    at core.js:10629
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
    at t.invokeTask (polyfills.js:3)
View_TopPage_0 @ TopPage.html:33

Where is wrong.I did not know. ( I apologize for my poor English. )

masterbd commented 4 years ago

I have the same issue