Skip to content

Commit

Permalink
add reward video closed and clicked event
Browse files Browse the repository at this point in the history
  • Loading branch information
nyancodeid committed Sep 3, 2019
1 parent 93ecd1c commit 3171c0f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ document.addEventListener('startappads.interstitial.load_fail', () => {
//do something here
});
```
#### IMPORTANT:
```
Do not call `showInterstitial()` from within `load_fail` event. The SDK will automatically try to reload an ad upon a failure.
```

### 5. Show Rewarded Video Ads
Show a Rewarded Video Ad:
Expand All @@ -127,6 +131,16 @@ document.addEventListener('startappads.reward_video.load', () => {
//do something here
});

document.addEventListener('startappads.reward_video.closed', () => {
//user closed video reward
//do something here
});

document.addEventListener('startappads.reward_video.clicked', () => {
//user click on video reward
//do something here
});

document.addEventListener('startappads.reward_video.load_fail', () => {
//reward video failed to load. Probably no Ads available at the moment
//do something here
Expand Down
20 changes: 19 additions & 1 deletion src/android/StartAppAdsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,25 @@ public void onFailedToReceiveAd(Ad arg0) {

public void showRewardVideo(CallbackContext callbackContext) {
if (rewardedVideo != null) {
rewardedVideo.showAd();
Log.d(TAG, "Reward Video show now!");
rewardedVideo.showAd(new AdDisplayListener() {
@Override
public void adHidden(Ad ad) {
Log.d(TAG, "Rewarded Video closed!");
cWebView.loadUrl("javascript:cordova.fireDocumentEvent('startappads.reward_video.closed');");
}
@Override
public void adClicked(Ad ad) {
Log.d(TAG, "Rewarded Video clicked!");
cWebView.loadUrl("javascript:cordova.fireDocumentEvent('startappads.reward_video.clicked');");
}
@Override
public void adDisplayed(Ad ad) {
}
@Override
public void adNotDisplayed(Ad ad) {
}
});
} else {
Log.d(TAG, "Video Reward need to load before call it!");
}
Expand Down

0 comments on commit 3171c0f

Please sign in to comment.