Skip to content

Commit

Permalink
fix(ios): resuming video ad after closing the in-app browser on iOS (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lrusso authored Oct 6, 2023
1 parent 7b6b84c commit e6e8f62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ Determine whether the media should played as picture in picture.
* **false (default)** - Don't not play 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

Expand Down
9 changes: 8 additions & 1 deletion ios/Video/Features/RCTIMAAdsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Foundation
import GoogleInteractiveMediaAds

class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate, IMALinkOpenerDelegate {

private weak var _video: RCTVideo?
private var _pipEnabled:() -> Bool
Expand Down Expand Up @@ -65,6 +65,7 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {

// Create ads rendering settings and tell the SDK to use the in-app browser.
let adsRenderingSettings: IMAAdsRenderingSettings = IMAAdsRenderingSettings();
adsRenderingSettings.linkOpenerDelegate = self;
adsRenderingSettings.linkOpenerPresentingController = _video.reactViewController();

adsManager.initialize(with: adsRenderingSettings)
Expand Down Expand Up @@ -125,6 +126,12 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
_video?.setPaused(false)
}

// MARK: - IMALinkOpenerDelegate

func linkOpenerDidClose(inAppLink linkOpener: NSObject) {
adsManager?.resume()
}

// MARK: - Helpers

func convertEventToString(event: IMAAdEventType!) -> String {
Expand Down

0 comments on commit e6e8f62

Please sign in to comment.