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
答案 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
});
}