admob-free interstitial close event ionic3

时间:2017-08-04 12:22:09

标签: angular ionic2 ionic3

Working with Admob-free plugin.

How to fire interstitial close event,

//this is the code found for javscript
document.addEventListener('admob.interstitial.events.CLOSE', function (event) {
    console.log(event)
    admob.interstitial.prepare()
})
//i want this code  in ionic3 

can someone help how to do this in typescript/ ionic3

document.addEventListener is showing error in typescript

2 个答案:

答案 0 :(得分:2)

import {Component, Renderer} from '@angular/core';    
constructor(renderer: Renderer) {

            renderer.listenGlobal('document', 'admob.interstitial.events.CLOSE', (event) => {
                console.log(event);
            });

        }

你可以这样做

答案 1 :(得分:1)

最简单的方法如下所示,但不要忘记在构造函数中注册 AdmobFree

constructor(
    private admobFree: AdMobFree,
    public platform: Platform
) {

    // Handle interstitial's close event
    this.admobFree.on('admob.interstitial.events.CLOSE').subscribe(() => {
       // handle interstitial close
    });
}