diff --git a/README.md b/README.md index 2c543ccb7..c9627cafd 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,11 @@ Unfortunately, events are not consistent across iOS and Android. To have one uni rewardBasedVideoAdDidStartPlaying onRewardedVideoStarted + + videoCompleted + rewardBasedVideoAdDidCompletePlaying + rewardedVideoAdVideoCompleted + adClosed rewardBasedVideoAdDidClose diff --git a/RNAdMobRewarded.js b/RNAdMobRewarded.js index 7a901ee98..6ccea6ba9 100644 --- a/RNAdMobRewarded.js +++ b/RNAdMobRewarded.js @@ -17,6 +17,7 @@ const eventMap = { adLeftApplication: 'rewardedVideoAdLeftApplication', rewarded: 'rewardedVideoAdRewarded', videoStarted: 'rewardedVideoAdVideoStarted', + videoCompleted: 'rewardedVideoAdVideoCompleted', }; const _subscriptions = new Map(); diff --git a/android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java b/android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java index 6cdfbd192..0c1760b7a 100644 --- a/android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java +++ b/android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java @@ -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; @@ -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"; diff --git a/ios/RNAdMobRewarded.m b/ios/RNAdMobRewarded.m index a554c7e27..2a034a075 100644 --- a/ios/RNAdMobRewarded.m +++ b/ios/RNAdMobRewarded.m @@ -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 { @@ -39,7 +40,8 @@ - (dispatch_queue_t)methodQueue kEventAdOpened, kEventVideoStarted, kEventAdClosed, - kEventAdLeftApplication ]; + kEventAdLeftApplication, + kEventVideoCompleted ]; } #pragma mark exported methods @@ -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) {