Skip to content

Commit 900216a

Browse files
authored
Merge pull request #273 from rm3rdmodules/master
Override abstract method onRewardedVideoCompleted()
2 parents a6d1909 + 52e5863 commit 900216a

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ Unfortunately, events are not consistent across iOS and Android. To have one uni
317317
<td><code>rewardBasedVideoAdDidStartPlaying</code></td>
318318
<td><code>onRewardedVideoStarted</code></td>
319319
</tr>
320+
<tr>
321+
<td><code>videoCompleted</code></td>
322+
<td><code>rewardBasedVideoAdDidCompletePlaying</code></td>
323+
<td><code>rewardedVideoAdVideoCompleted</code></td>
324+
</tr>
320325
<tr>
321326
<td><code>adClosed</code></td>
322327
<td><code>rewardBasedVideoAdDidClose</code></td>

RNAdMobRewarded.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const eventMap = {
1717
adLeftApplication: 'rewardedVideoAdLeftApplication',
1818
rewarded: 'rewardedVideoAdRewarded',
1919
videoStarted: 'rewardedVideoAdVideoStarted',
20+
videoCompleted: 'rewardedVideoAdVideoCompleted',
2021
};
2122

2223
const _subscriptions = new Map();

android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class RNAdMobRewardedVideoAdModule extends ReactContextBaseJavaModule imp
3333
public static final String EVENT_AD_LEFT_APPLICATION = "rewardedVideoAdLeftApplication";
3434
public static final String EVENT_REWARDED = "rewardedVideoAdRewarded";
3535
public static final String EVENT_VIDEO_STARTED = "rewardedVideoAdVideoStarted";
36+
public static final String EVENT_VIDEO_COMPLETED = "rewardedVideoAdVideoCompleted";
3637

3738
RewardedVideoAd mRewardedVideoAd;
3839
String adUnitID;
@@ -85,6 +86,11 @@ public void onRewardedVideoAdLeftApplication() {
8586
sendEvent(EVENT_AD_LEFT_APPLICATION, null);
8687
}
8788

89+
@Override
90+
public void onRewardedVideoCompleted() {
91+
sendEvent(EVENT_VIDEO_COMPLETED, null);
92+
}
93+
8894
@Override
8995
public void onRewardedVideoAdFailedToLoad(int errorCode) {
9096
String errorString = "ERROR_UNKNOWN";

ios/RNAdMobRewarded.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
static NSString *const kEventAdLeftApplication = @"rewardedVideoAdLeftApplication";
1414
static NSString *const kEventRewarded = @"rewardedVideoAdRewarded";
1515
static NSString *const kEventVideoStarted = @"rewardedVideoAdVideoStarted";
16+
static NSString *const kEventVideoCompleted = @"rewardedVideoAdVideoCompleted";
1617

1718
@implementation RNAdMobRewarded
1819
{
@@ -39,7 +40,8 @@ - (dispatch_queue_t)methodQueue
3940
kEventAdOpened,
4041
kEventVideoStarted,
4142
kEventAdClosed,
42-
kEventAdLeftApplication ];
43+
kEventAdLeftApplication,
44+
kEventVideoCompleted ];
4345
}
4446

4547
#pragma mark exported methods
@@ -132,6 +134,13 @@ - (void)rewardBasedVideoAdDidStartPlaying:(__unused GADRewardBasedVideoAd *)rewa
132134
}
133135
}
134136

137+
- (void)rewardBasedVideoAdDidCompletePlaying:(__unused GADRewardBasedVideoAd *)rewardBasedVideoAd
138+
{
139+
if (hasListeners) {
140+
[self sendEventWithName:kEventVideoCompleted body:nil];
141+
}
142+
}
143+
135144
- (void)rewardBasedVideoAdDidClose:(__unused GADRewardBasedVideoAd *)rewardBasedVideoAd
136145
{
137146
if (hasListeners) {

0 commit comments

Comments
 (0)