Skip to content

Commit

Permalink
refactor: rewarded ads v8
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom authored and mikehardy committed Dec 10, 2021
1 parent f516929 commit 4be5993
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 220 deletions.
6 changes: 1 addition & 5 deletions ios/RNGoogleAds/RNGoogleAdsFullScreenContentDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@

@interface RNGoogleAdsFullScreenContentDelegate : NSObject <GADFullScreenContentDelegate>

+ (void)sendInterstitialEvent:(NSString *)type
requestId:(NSNumber *)requestId
adUnitId:(NSString *)adUnitId
error:(nullable NSDictionary *)error;

@property(nonatomic, copy) NSString *sendAdEvent;
@property(nonatomic, copy) NSNumber *requestId;
@property(nonatomic, copy) NSString *adUnitId;

Expand Down
49 changes: 20 additions & 29 deletions ios/RNGoogleAds/RNGoogleAdsFullScreenContentDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,38 @@
@implementation RNGoogleAdsFullScreenContentDelegate

#pragma mark -
#pragma mark Helper Methods
#pragma mark GADFullScreenContentDelegate Methods

+ (void)sendInterstitialEvent:(NSString *)type
requestId:(NSNumber *)requestId
adUnitId:(NSString *)adUnitId
error:(nullable NSDictionary *)error {
[RNGoogleAdsCommon sendAdEvent:GOOGLE_ADS_EVENT_INTERSTITIAL
requestId:requestId
type:type
adUnitId:adUnitId
error:error
/// Tells the delegate that the ad presented full screen content.
- (void)adDidPresentFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
[RNGoogleAdsCommon sendAdEvent:_sendAdEvent
requestId:_requestId
type:GOOGLE_ADS_EVENT_OPENED
adUnitId:_adUnitId
error:nil
data:nil];
}

#pragma mark -
#pragma mark GADFullScreenContentDelegate Methods

/// Tells the delegate that the ad failed to present full screen content.
- (void)ad:(nonnull id<GADFullScreenPresentingAd>)ad
didFailToPresentFullScreenContentWithError:(nonnull NSError *)error {
NSDictionary *codeAndMessage = [RNGoogleAdsCommon getCodeAndMessageFromAdError:error];
[RNGoogleAdsFullScreenContentDelegate sendInterstitialEvent:GOOGLE_ADS_EVENT_ERROR
requestId:_requestId
adUnitId:_adUnitId
error:codeAndMessage];
}

/// Tells the delegate that the ad presented full screen content.
- (void)adDidPresentFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
[RNGoogleAdsFullScreenContentDelegate sendInterstitialEvent:GOOGLE_ADS_EVENT_OPENED
requestId:_requestId
adUnitId:_adUnitId
error:nil];
[RNGoogleAdsCommon sendAdEvent:_sendAdEvent
requestId:_requestId
type:GOOGLE_ADS_EVENT_ERROR
adUnitId:_adUnitId
error:codeAndMessage
data:nil];
}

/// Tells the delegate that the ad dismissed full screen content.
- (void)adDidDismissFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
[RNGoogleAdsFullScreenContentDelegate sendInterstitialEvent:GOOGLE_ADS_EVENT_CLOSED
requestId:_requestId
adUnitId:_adUnitId
error:nil];
[RNGoogleAdsCommon sendAdEvent:_sendAdEvent
requestId:_requestId
type:GOOGLE_ADS_EVENT_CLOSED
adUnitId:_adUnitId
error:nil
data:nil];
}

@end
1 change: 1 addition & 0 deletions ios/RNGoogleAds/RNGoogleAdsInterstitialModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ - (void)invalidate {
}
GADInterstitialAd *interstitial = ad;
RNGoogleAdsFullScreenContentDelegate *fullScreenContentDelegate = [[RNGoogleAdsFullScreenContentDelegate alloc] init];
fullScreenContentDelegate.sendAdEvent = GOOGLE_ADS_EVENT_INTERSTITIAL;
fullScreenContentDelegate.requestId = requestId;
fullScreenContentDelegate.adUnitId = ad.adUnitID;
interstitial.fullScreenContentDelegate = fullScreenContentDelegate;
Expand Down
36 changes: 0 additions & 36 deletions ios/RNGoogleAds/RNGoogleAdsRewardedDelegate.h

This file was deleted.

95 changes: 0 additions & 95 deletions ios/RNGoogleAds/RNGoogleAdsRewardedDelegate.m

This file was deleted.

Loading

0 comments on commit 4be5993

Please sign in to comment.