Skip to content

Commit

Permalink
Merge pull request #273 from rm3rdmodules/master
Browse files Browse the repository at this point in the history
Override abstract method onRewardedVideoCompleted()
  • Loading branch information
koenpunt authored Apr 16, 2018
2 parents a6d1909 + 52e5863 commit 900216a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ Unfortunately, events are not consistent across iOS and Android. To have one uni
<td><code>rewardBasedVideoAdDidStartPlaying</code></td>
<td><code>onRewardedVideoStarted</code></td>
</tr>
<tr>
<td><code>videoCompleted</code></td>
<td><code>rewardBasedVideoAdDidCompletePlaying</code></td>
<td><code>rewardedVideoAdVideoCompleted</code></td>
</tr>
<tr>
<td><code>adClosed</code></td>
<td><code>rewardBasedVideoAdDidClose</code></td>
Expand Down
1 change: 1 addition & 0 deletions RNAdMobRewarded.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const eventMap = {
adLeftApplication: 'rewardedVideoAdLeftApplication',
rewarded: 'rewardedVideoAdRewarded',
videoStarted: 'rewardedVideoAdVideoStarted',
videoCompleted: 'rewardedVideoAdVideoCompleted',
};

const _subscriptions = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class RNAdMobRewardedVideoAdModule extends ReactContextBaseJavaModule imp
public static final String EVENT_AD_LEFT_APPLICATION = "rewardedVideoAdLeftApplication";
public static final String EVENT_REWARDED = "rewardedVideoAdRewarded";
public static final String EVENT_VIDEO_STARTED = "rewardedVideoAdVideoStarted";
public static final String EVENT_VIDEO_COMPLETED = "rewardedVideoAdVideoCompleted";

RewardedVideoAd mRewardedVideoAd;
String adUnitID;
Expand Down Expand Up @@ -85,6 +86,11 @@ public void onRewardedVideoAdLeftApplication() {
sendEvent(EVENT_AD_LEFT_APPLICATION, null);
}

@Override
public void onRewardedVideoCompleted() {
sendEvent(EVENT_VIDEO_COMPLETED, null);
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
String errorString = "ERROR_UNKNOWN";
Expand Down
11 changes: 10 additions & 1 deletion ios/RNAdMobRewarded.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
static NSString *const kEventAdLeftApplication = @"rewardedVideoAdLeftApplication";
static NSString *const kEventRewarded = @"rewardedVideoAdRewarded";
static NSString *const kEventVideoStarted = @"rewardedVideoAdVideoStarted";
static NSString *const kEventVideoCompleted = @"rewardedVideoAdVideoCompleted";

@implementation RNAdMobRewarded
{
Expand All @@ -39,7 +40,8 @@ - (dispatch_queue_t)methodQueue
kEventAdOpened,
kEventVideoStarted,
kEventAdClosed,
kEventAdLeftApplication ];
kEventAdLeftApplication,
kEventVideoCompleted ];
}

#pragma mark exported methods
Expand Down Expand Up @@ -132,6 +134,13 @@ - (void)rewardBasedVideoAdDidStartPlaying:(__unused GADRewardBasedVideoAd *)rewa
}
}

- (void)rewardBasedVideoAdDidCompletePlaying:(__unused GADRewardBasedVideoAd *)rewardBasedVideoAd
{
if (hasListeners) {
[self sendEventWithName:kEventVideoCompleted body:nil];
}
}

- (void)rewardBasedVideoAdDidClose:(__unused GADRewardBasedVideoAd *)rewardBasedVideoAd
{
if (hasListeners) {
Expand Down

0 comments on commit 900216a

Please sign in to comment.