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
495 stars 211 forks source link

How to work to get a reward? #308

Open diegoestacho999 opened 6 years ago

diegoestacho999 commented 6 years ago

The video is displayed correctly, but I do not know how to proceed after the video is displayed. Is it necessary to manipulate some event, if so, what event would that be? I did the integration with Unity, but when I click on the close of the video, it closes the application, is that right?

tyshawngaines commented 6 years ago

document.addEventListener('admob.rewardvideo.events.REWARD',function(event){ /** I noticed users would be rewarded multiple times on 1 video so here's a way to prevent that from happening **/

Var seenAd = false;

if(seenAd==false){ seenAd=true; alert("you are rewarded for watching the ad");} } )

P.S. reward can be replaced with the following (LOAD, LOAD_FAIL, OPEN, CLOSE, EXIT_APP)

diegoestacho999 commented 6 years ago

Is this what I call right after being able to view the reward video? today I have something like

//calls and displays the reward video launchVideoReward() { let rewardConfig: AdMobFreeRewardVideoConfig = { //isTesting: true, autoShow: true, id: 'ca-app-pub-8000726989219599/8229278077' }; this.admob.rewardVideo.config(rewardConfig); this.admob.rewardVideo.prepare().then(() => { console.log('video executado com sucesso'); }) }

tyshawngaines commented 6 years ago

//I think you are using typescript. i am not to familiar with that but here's how i got it to work:

//on my index.html I placed this code inside script tags like such:

// on my application what this did was prepare my rewards and interstitial so i could them later: // afterwards I am able to call them inside of another function for my game like this.

function myGame(){ document.addEventListener('admob.rewardvideo.events.LOAD', function(event) { admob.rewardvideo.show() )

//the code above only works if admob loads the ad into the app else it will do nothing

document.addEventListener('admob.rewardvideo.events.REWARD', function(event) { admob.rewardvideo.show() ) }

myGame()

/the code above only works if admob detects that the user has finished watching the whole reward video else it will do nothing /

/the word load and reward can be inter-changed with one of the following (REWARD,LOAD, LOAD_FAIL, OPEN, CLOSE, EXIT_APP)/

//I hope this helps you out

diegoestacho999 commented 5 years ago

Friend, have you managed to resolve the issue of doubling the reward? I still have this same problem here, even after using your code. What can we do to solve it?