fix(ios): resuming video ad after closing the in-app browser on iOS (#3275)

This commit is contained in:
Leonardo Russo 2023-10-06 13:43:35 -03:00 committed by GitHub
parent 7b6b84c8cb
commit e6e8f621fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

2
API.md
View File

@ -667,7 +667,7 @@ Determine whether the media should played as picture in picture.
* **false (default)** - Don't not play as picture in picture * **false (default)** - Don't not play as picture in picture
* **true** - Play the media as picture in picture * **true** - Play the media as picture in picture
NOTE: Video ads cannot start when you are using the PIP on iOS (more info available at [Google IMA SDK Docs](https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/picture_in_picture?hl=en#starting_ads)). If you are using custom controls, you must disable your PIP button when you receive the ```STARTED``` event from ```onReceiveAdEvent``` and show it again when you receive the ```ALL_ADS_COMPLETED``` event. NOTE: Video ads cannot start when you are using the PIP on iOS (more info available at [Google IMA SDK Docs](https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/picture_in_picture?hl=en#starting_ads)). If you are using custom controls, you must hide your PIP button when you receive the ```STARTED``` event from ```onReceiveAdEvent``` and show it again when you receive the ```ALL_ADS_COMPLETED``` event.
Platforms: iOS Platforms: iOS

View File

@ -2,7 +2,7 @@
import Foundation import Foundation
import GoogleInteractiveMediaAds import GoogleInteractiveMediaAds
class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate { class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate, IMALinkOpenerDelegate {
private weak var _video: RCTVideo? private weak var _video: RCTVideo?
private var _pipEnabled:() -> Bool private var _pipEnabled:() -> Bool
@ -65,6 +65,7 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
// Create ads rendering settings and tell the SDK to use the in-app browser. // Create ads rendering settings and tell the SDK to use the in-app browser.
let adsRenderingSettings: IMAAdsRenderingSettings = IMAAdsRenderingSettings(); let adsRenderingSettings: IMAAdsRenderingSettings = IMAAdsRenderingSettings();
adsRenderingSettings.linkOpenerDelegate = self;
adsRenderingSettings.linkOpenerPresentingController = _video.reactViewController(); adsRenderingSettings.linkOpenerPresentingController = _video.reactViewController();
adsManager.initialize(with: adsRenderingSettings) adsManager.initialize(with: adsRenderingSettings)
@ -125,6 +126,12 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
_video?.setPaused(false) _video?.setPaused(false)
} }
// MARK: - IMALinkOpenerDelegate
func linkOpenerDidClose(inAppLink linkOpener: NSObject) {
adsManager?.resume()
}
// MARK: - Helpers // MARK: - Helpers
func convertEventToString(event: IMAAdEventType!) -> String { func convertEventToString(event: IMAAdEventType!) -> String {