Skip to content

Commit

Permalink
Implement iOS Omid API
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhaevre authored and tvanlaerhoven committed Oct 30, 2024
1 parent 0f4b0b8 commit 6c52bd3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ios/ads/THEOplayerRCTAdsAPI+Omid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,37 @@ import Foundation
import THEOplayerSDK
import UIKit

let PROP_OMID_VIEW: String = "view"
let PROP_OMID_PURPOSE: String = "purpose"
let PROP_OMID_REASON: String = "reason"

extension THEOplayerRCTAdsAPI {

#if canImport(THEOplayerGoogleIMAIntegration)
@objc(addFriendlyObstruction:obstruction:)
func addFriendlyObstruction(_ node: NSNumber, obstruction: NSDictionary) {
DispatchQueue.main.async {
if let obstructionNode = obstruction[PROP_OMID_VIEW] as? NSNumber,
let purposeString = obstruction[PROP_OMID_PURPOSE] as? String,
let theView = self.bridge.uiManager.view(forReactTag: node) as? THEOplayerRCTView,
let obstructionView = self.bridge.uiManager.view(forReactTag: obstructionNode),
let ads = theView.ads() {
let obstruction = OmidFriendlyObstruction(view: obstructionView,
purpose: THEOplayerRCTTypeUtils.omidFriendlyObstructionPurposeFromString(purposeString),
detailedReason: obstruction[PROP_OMID_REASON] as? String)
ads.omid.addFriendlyObstruction(friendlyObstruction: obstruction)
}
}
}

@objc(removeAllFriendlyObstructions:)
func removeAllFriendlyObstructions(_ node: NSNumber) {
DispatchQueue.main.async {
if let theView = self.bridge.uiManager.view(forReactTag: node) as? THEOplayerRCTView,
let ads = theView.ads() {
ads.omid.removeFriendlyObstructions()
}
}
}

#else
Expand Down

0 comments on commit 6c52bd3

Please sign in to comment.