From f54288c54d7bd2f4a9d667efadbbba2300bb56dc Mon Sep 17 00:00:00 2001 From: Axel Vencatareddy Date: Mon, 14 Nov 2022 11:49:15 +0100 Subject: [PATCH] [IOS] Fix ads when no controls displayed --- Video.js | 1 + ios/Video/RCTVideo.swift | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Video.js b/Video.js index 5a794b56..7dd3c9e5 100644 --- a/Video.js +++ b/Video.js @@ -535,6 +535,7 @@ Video.propTypes = { onPictureInPictureStatusChanged: PropTypes.func, needsToRestoreUserInterfaceForPictureInPictureStop: PropTypes.func, onExternalPlaybackChange: PropTypes.func, + adTagUrl: PropTypes.string, onReceiveAdEvents: PropTypes.func, /* Required by react-native */ diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 0a368c41..1ee827e3 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -1116,20 +1116,18 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH } func requestAds() { - if self._playerViewController != nil { - // Create ad display container for ad rendering. - let adDisplayContainer = IMAAdDisplayContainer(adContainer: self, viewController: self.reactViewController()) + // Create ad display container for ad rendering. + let adDisplayContainer = IMAAdDisplayContainer(adContainer: self, viewController: self.reactViewController()) - if _adTagUrl != nil { - // Create an ad request with our ad tag, display container, and optional user context. - let request = IMAAdsRequest( - adTagUrl: _adTagUrl!, - adDisplayContainer: adDisplayContainer, - contentPlayhead: contentPlayhead, - userContext: nil) + if _adTagUrl != nil { + // Create an ad request with our ad tag, display container, and optional user context. + let request = IMAAdsRequest( + adTagUrl: _adTagUrl!, + adDisplayContainer: adDisplayContainer, + contentPlayhead: contentPlayhead, + userContext: nil) - adsLoader.requestAds(with: request) - } + adsLoader.requestAds(with: request) } } @@ -1142,7 +1140,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH // Create ads rendering settings and tell the SDK to use the in-app browser. let adsRenderingSettings: IMAAdsRenderingSettings = IMAAdsRenderingSettings(); - adsRenderingSettings.linkOpenerPresentingController = self._playerViewController; + adsRenderingSettings.linkOpenerPresentingController = self.reactViewController(); adsManager.initialize(with: adsRenderingSettings) }