Skip to content

Commit

Permalink
chore: format ios code
Browse files Browse the repository at this point in the history
  • Loading branch information
wjaykim committed Dec 27, 2024
1 parent 6b47b10 commit cdd3587
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
_mediaView.mediaContent = nativeAd.mediaContent;
_mediaView.contentMode = _contentMode;
}

if (oldViewProps.resizeMode != newViewProps.resizeMode) {
NSString *resizeMode = [[NSString alloc] initWithUTF8String:newViewProps.resizeMode.c_str()];
if ([resizeMode isEqualToString:@"cover"]) {
Expand Down
34 changes: 14 additions & 20 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
typedef void (^RNGMANativeAdLoadCompletionHandler)(GADNativeAd *_Nullable nativeAd,
NSError *_Nullable error);

@interface RNGMANativeAdHolder : NSObject <GADNativeAdLoaderDelegate, GADNativeAdDelegate, GADVideoControllerDelegate>
@interface RNGMANativeAdHolder
: NSObject <GADNativeAdLoaderDelegate, GADNativeAdDelegate, GADVideoControllerDelegate>

@property GADNativeAd *nativeAd;

Expand Down Expand Up @@ -164,11 +165,11 @@ - (instancetype)initWithNativeModule:(RNGoogleMobileAdsNativeModule *)nativeModu
videoOptions.startMuted = [requestOptions[@"startVideoMuted"] boolValue];
}

_adLoader =
[[GADAdLoader alloc] initWithAdUnitID:adUnitId
rootViewController:[RNGoogleMobileAdsCommon currentViewController]
adTypes:@[ GADAdLoaderAdTypeNative ]
options:@[ imageOptions, mediaOptions, adViewOptions, videoOptions ]];
_adLoader = [[GADAdLoader alloc]
initWithAdUnitID:adUnitId
rootViewController:[RNGoogleMobileAdsCommon currentViewController]
adTypes:@[ GADAdLoaderAdTypeNative ]
options:@[ imageOptions, mediaOptions, adViewOptions, videoOptions ]];
_adLoader.delegate = self;
_adRequest = [RNGoogleMobileAdsCommon buildAdRequest:requestOptions];
}
Expand Down Expand Up @@ -223,36 +224,29 @@ - (void)nativeAdWillLeaveApplication:(GADNativeAd *)nativeAd {
// Not in use
}

- (void)videoControllerDidPlayVideo:
(nonnull GADVideoController *)videoController {
- (void)videoControllerDidPlayVideo:(nonnull GADVideoController *)videoController {
[self emitAdEvent:@"video_played"];
}

- (void)videoControllerDidPauseVideo:
(nonnull GADVideoController *)videoController {
- (void)videoControllerDidPauseVideo:(nonnull GADVideoController *)videoController {
[self emitAdEvent:@"video_paused"];
}

- (void)videoControllerDidEndVideoPlayback:
(nonnull GADVideoController *)videoController {
- (void)videoControllerDidEndVideoPlayback:(nonnull GADVideoController *)videoController {
[self emitAdEvent:@"video_ended"];
}

- (void)videoControllerDidMuteVideo:
(nonnull GADVideoController *)videoController {
- (void)videoControllerDidMuteVideo:(nonnull GADVideoController *)videoController {
[self emitAdEvent:@"video_muted"];
}

- (void)videoControllerDidUnmuteVideo:
(nonnull GADVideoController *)videoController {
- (void)videoControllerDidUnmuteVideo:(nonnull GADVideoController *)videoController {
[self emitAdEvent:@"video_unmuted"];
}

- (void)emitAdEvent:(NSString *)type {
[_nativeModule emitOnAdEvent:@{
@"responseId" : _nativeAd.responseInfo.responseIdentifier,
@"type" : type
}];
[_nativeModule
emitOnAdEvent:@{@"responseId" : _nativeAd.responseInfo.responseIdentifier, @"type" : type}];
}

@end
Expand Down

0 comments on commit cdd3587

Please sign in to comment.