I would like to know if it is possible to call a function within a given event using addEventListener ().
I have this function, which adds a reward to the database:
//Função que adiciona uma recompensa ao banco de dados
addReward(){
if(!this.isEditing){
this.addDocument(this.caminho, this.recompensa).then(()=>{
//this.loadData();//refresh view
});
}else{
this.updateDocument(this.caminho, this.recompensa.key,
this.recompensa).then(()=>{
this.loadData();//refresh view
});
}
this.isEditing = false;
//clear form
this.recompensa.valor;
this.recompensa.data;
}
Here is the function that displays a certain ad to the user, I need to have the above function done when I close the video, sending the value of its reward to the database, but it always returns an error: p>
videosInmobi() {
let carregar = this.loading.create({content : "Carregando..."});
carregar.present();
let rewardConfig: AdMobFreeRewardVideoConfig = {
isTesting: true,
autoShow: true,
id: 'ca-app-pub-8000726989219599/6974786599' //id videos InMobi
};
this.admob.rewardVideo.config(rewardConfig);
this.admob.rewardVideo.prepare().then((result) => {
carregar.dismissAll();
this.recompensa.data = moment().format('L');
this.recompensa.valor = 0.03;
//tento fazer assim atualmente, porém ele sempre retorna um erro quando fecho o vídeo
document.addEventListener('admob.rewardvideo.events.CLOSE', function(event) {
console.log(event)
this.addReward(this.recompensa);
})
}), carregar.dismissAll();
}
The error that returns me is the image below: