diff --git a/TeadsSampleApp.xcodeproj/project.pbxproj b/TeadsSampleApp.xcodeproj/project.pbxproj index ed448269..f67b91d8 100644 --- a/TeadsSampleApp.xcodeproj/project.pbxproj +++ b/TeadsSampleApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 3C3CF0BD2BC80530002A20FA /* PrebidAdResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C3CF0BC2BC80530002A20FA /* PrebidAdResponse.swift */; }; 4079F243252CBE7F00B0AC31 /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4079F242252CBE7F00B0AC31 /* ColorExtension.swift */; }; 4079F253252CC1EF00B0AC31 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4079F252252CC1EF00B0AC31 /* RootViewController.swift */; }; 408A2D49253D995200CCFF44 /* RootButtonCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 408A2D46253D995200CCFF44 /* RootButtonCollectionViewCell.swift */; }; @@ -227,6 +228,7 @@ isa = PBXGroup; children = ( B5555A4D1F7D3177007406D4 /* InReadDirectScrollViewController.swift */, + 3C3CF0BC2BC80530002A20FA /* PrebidAdResponse.swift */, ); path = ScrollView; sourceTree = ""; @@ -763,6 +765,7 @@ E954312827CD03E8005004B4 /* NativeAppLovinTableViewController.swift in Sources */, B5966D1E269D8FC6005CA2FF /* InReadAdmobScrollViewController.swift in Sources */, A956713829E95A3600505C29 /* NativeTagDirectTableViewController.swift in Sources */, + 3C3CF0BD2BC80530002A20FA /* PrebidAdResponse.swift in Sources */, E9A3AC582795AF2C00F124D6 /* AdOpportunityTrackerTableViewCell.swift in Sources */, B56A8ABB2698A0A20090A14A /* InReadDirectTableViewController.swift in Sources */, E9984EFA26B2D46F000D42D3 /* NativeTableViewCell.swift in Sources */, diff --git a/TeadsSampleApp/Controllers/InRead/Direct/ScrollView/InReadDirectScrollViewController.swift b/TeadsSampleApp/Controllers/InRead/Direct/ScrollView/InReadDirectScrollViewController.swift index 471c5b14..331d3282 100644 --- a/TeadsSampleApp/Controllers/InRead/Direct/ScrollView/InReadDirectScrollViewController.swift +++ b/TeadsSampleApp/Controllers/InRead/Direct/ScrollView/InReadDirectScrollViewController.swift @@ -14,22 +14,32 @@ class InReadDirectScrollViewController: TeadsViewController { @IBOutlet var teadsAdView: TeadsInReadAdView! @IBOutlet var teadsAdHeightConstraint: NSLayoutConstraint! var adRatio: TeadsAdRatio? - var placement: TeadsInReadAdPlacement? + var placement: TeadsPrebidAdPlacement? override func viewDidLoad() { super.viewDidLoad() - let pSettings = TeadsAdPlacementSettings { settings in - settings.enableDebug() + + // Create Prebid placement + let adPlacementSettings = TeadsAdPlacementSettings { settings in + settings.enableDebug() // remove in production + } + placement = Teads.createPrebidPlacement(settings: adPlacementSettings, delegate: self) + + // Get the ad request data + let adRequestSettings = TeadsAdRequestSettings { settings in + // Ensure to inform your article url or domain url for brand safety matters + settings.pageUrl("https://www.your.url.com") + + // Add this extra to enable your standalone integration + settings.addExtras("1", for: TeadsAdapterSettings.prebidStandaloneKey) } + let teadsBidRequestExtraData = try? placement?.getData(requestSettings: adRequestSettings) - // keep a strong reference to placement instance - placement = Teads.createInReadPlacement(pid: Int(pid) ?? 0, settings: pSettings, delegate: self) - placement?.requestAd(requestSettings: TeadsAdRequestSettings { settings in - settings.pageUrl("https://www.teads.com") - }) - // We use an observer to know when a rotation happened, to resize the ad - // You can use whatever way you want to do so - NotificationCenter.default.addObserver(self, selector: #selector(rotationDetected), name: UIDevice.orientationDidChangeNotification, object: nil) + // Prebid request with the getData + print(teadsBidRequestExtraData) + + // Load ad + placement?.loadAd(adResponse: PrebidAdResponse.TAMEDIA_FAKE_WINNING_BID_RESPONSE, requestSettings: adRequestSettings) } deinit { @@ -95,3 +105,22 @@ extension InReadDirectScrollViewController: TeadsAdDelegate { func didCollapsedFromFullscreen(ad _: TeadsAd) {} } + +enum PrebidAdResponse { + // Ad that will evoke resizing callbacks + static let FAKE_VAST_URL = "https://s8t.teads.tv/vast/a7165340-d714-11ee-9d18-8d6ab288a268" + + static let FAKE_VAST_CONTENT = "Brainient800:00:15" + + static let XML_TYPE = "VastXml" + static let URL_TYPE = "VastUrl" + + static let VAST_TYPE = URL_TYPE + static let VAST_CONTENT = FAKE_VAST_URL + + static let FAKE_ADM_CONTENT = "{\\\"ads\\\":[{\\\"settings\\\":{\\\"values\\\":{\\\"animations\\\":{\\\"expand\\\":0,\\\"collapse\\\":0.5},\\\"placementId\\\":84242,\\\"adType\\\":\\\"video\\\",\\\"placementFormat\\\":\\\"inread\\\",\\\"allowedPlayer\\\":\\\"any\\\",\\\"threshold\\\":50,\\\"pageId\\\":77781},\\\"components\\\":{\\\"closeButton\\\":{\\\"display\\\":false,\\\"countdown\\\":0},\\\"label\\\":{\\\"display\\\":true,\\\"text\\\":\\\"\\\"},\\\"credits\\\":{\\\"display\\\":false},\\\"soundButton\\\":{\\\"display\\\":true,\\\"countdown\\\":0,\\\"type\\\":\\\"equalizer\\\"},\\\"slider\\\":{\\\"closeButtonDisplay\\\":false}},\\\"behaviors\\\":{\\\"smartPosition\\\":{\\\"top\\\":false,\\\"corner\\\":false,\\\"mustBypassWhitelist\\\":true},\\\"slider\\\":{\\\"enable\\\":false},\\\"playerClick\\\":\\\"fullscreen\\\",\\\"soundStart\\\":{\\\"type\\\":\\\"mute\\\"},\\\"soundMute\\\":\\\"threshold\\\",\\\"soundOver\\\":\\\"over\\\",\\\"launch\\\":\\\"auto\\\",\\\"videoStart\\\":\\\"threshold\\\",\\\"videoPause\\\":\\\"threshold\\\",\\\"secure\\\":false,\\\"friendly\\\":false}},\\\"type\\\":\\\"\(VAST_TYPE)\\\",\\\"content\\\":\\\"\(VAST_CONTENT)\\\",\\\"connection_id\\\":460794,\\\"scenario_id\\\":18603,\\\"dsp_campaign_id\\\":\\\"590162\\\",\\\"ad_source_id\\\":200,\\\"dsp_creative_id\\\":\\\"625187\\\",\\\"insertion_id\\\":590162,\\\"placement_id\\\":84242,\\\"portfolio_item_id\\\":1,\\\"early_click_protection_duration\\\":0,\\\"exclusiveAdOnScreen\\\":false}],\\\"wigoEnabled\\\":false,\\\"placementMetadata\\\":{\\\"84242\\\":{\\\"auctionId\\\":\\\"a9995fbe-1cb5-4e1a-858f-266903d7d772\\\"}},\\\"viewerId\\\":\\\"b1aefcc416eb3116e70d52e5ac0618abcf6645f4\\\"}" + + static let FAKE_WINNING_BID_RESPONSE = "{\"id\":\"prebid-demo-response-video-outstream\",\"impid\":\"03ec3cdd-e144-40bd-98cc-1947235ce897\",\"price\":0.11701999999468729,\"nurl\":\"https://localhost:8080/prebid-server/win-notice?data=base64&clearingPrice=${1000}\",\"adm\":\"\(FAKE_ADM_CONTENT)\",\"adid\":\"test-ad-id-12345\",\"adomain\":[\"prebid.org\"],\"crid\":\"test-creative-id-1\",\"cid\":\"test-cid-1\",\"ext\":{\"prebid\":{\"type\":\"video\",\"targeting\":{\"hb_pb\":\"0.10\",\"hb_env\":\"mobile-app\",\"hb_size_prebid\":\"300x250\",\"hb_pb_prebid\":\"0.10\",\"hb_bidder_prebid\":\"prebid\",\"hb_size\":\"300x250\",\"hb_bidder\":\"prebid\",\"hb_env_prebid\":\"mobile-app\"},\"meta\":{\"renderername\":\"SampleRendererName\",\"rendererversion\":\"1.0\"}},\"origbidcpm\":0.11701999999468729,\"origbidcur\":\"USD\"}}" + + static let TAMEDIA_FAKE_WINNING_BID_RESPONSE = "{\"id\":\"58343531-5f75-4b9b-889a-2b069390bdc0\",\"impid\":\"2348926d-ba31-4fc3-a092-6b68f3daa264\",\"price\":5.14,\"nurl\":\"https://a.teads.tv/prebid-server/win-notice?data=CgQIuLwMEgQImvcHGgQIq5EBIgQI%2Bo8cKgQIq5EBMgQI%2Bo8cOgQI9bdCQgQIo5QmSggKBjYyNTE4N1IJCgcxMDg4NTAxWvkBCiYKJDAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMRK9AQq6AVJhdyhNb3ppbGxhLzUuMCAoTGludXg7IEFuZHJvaWQgOTsgQW5kcm9pZCBTREsgYnVpbHQgZm9yIGFybTY0IEJ1aWxkL1BTUjEuMjEwMzAxLjAwOS5CMTsgd3YpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIFZlcnNpb24vNC4wIENocm9tZS82Ni4wLjMzNTkuMTU4IE1vYmlsZSBTYWZhcmkvNTM3LjM2KRoPCg05MS4xMjYuMjE4LjI0YnIKcDIzNDg5MjZkLWJhMzEtNGZjMy1hMDkyLTZiNjhmM2RhYTI2NF9fMjM0ODkyNmQtYmEzMS00ZmMzLWEwOTItNmI2OGYzZGFhMjY0X19kNWNlYzQ1Yi05ZjFjLTQxODktYjRiMS0wNDEyYzNjODllYzJqCAoGMjA0MzQ0egsKCXNkay1pbmFwcIIBAggBkgFQCiQKIm9yZy5wcmViaWQubW9iaWxlLnJlbmRlcmluZ3Rlc3RhcHASHgocUHJlYmlkIFJlbmRlcmluZyBLb3RsaW4gRGVtbxoICgZnb29nbGWiAQUKA1VTRKoBIwoaChhjamExNW9HQ1J4dHYxdm90clR1bEZhRWkSBQoDVVNE&clearingPrice=5.14&clearingPriceCurr=CHF\",\"adm\":\"{\\\"ads\\\":[{\\\"settings\\\":{\\\"values\\\":{\\\"animations\\\":{\\\"expand\\\":0,\\\"collapse\\\":0.5},\\\"placementId\\\":84242,\\\"adType\\\":\\\"video\\\",\\\"placementFormat\\\":\\\"inread\\\",\\\"allowedPlayer\\\":\\\"any\\\",\\\"threshold\\\":50,\\\"pageId\\\":77781},\\\"components\\\":{\\\"closeButton\\\":{\\\"display\\\":false,\\\"countdown\\\":0},\\\"label\\\":{\\\"display\\\":true,\\\"text\\\":\\\"\\\"},\\\"credits\\\":{\\\"display\\\":false},\\\"soundButton\\\":{\\\"display\\\":true,\\\"countdown\\\":0,\\\"type\\\":\\\"equalizer\\\"},\\\"slider\\\":{\\\"closeButtonDisplay\\\":false}},\\\"behaviors\\\":{\\\"smartPosition\\\":{\\\"top\\\":false,\\\"corner\\\":false,\\\"mustBypassWhitelist\\\":true},\\\"slider\\\":{\\\"enable\\\":false},\\\"playerClick\\\":\\\"fullscreen\\\",\\\"soundStart\\\":{\\\"type\\\":\\\"mute\\\"},\\\"soundMute\\\":\\\"threshold\\\",\\\"soundOver\\\":\\\"over\\\",\\\"launch\\\":\\\"auto\\\",\\\"videoStart\\\":\\\"threshold\\\",\\\"videoPause\\\":\\\"threshold\\\",\\\"secure\\\":false,\\\"friendly\\\":false}},\\\"type\\\":\\\"VastUrl\\\",\\\"content\\\":\\\"https://s8t.teads.tv/vast/a7165340-d714-11ee-9d18-8d6ab288a268\\\",\\\"connection_id\\\":460794,\\\"scenario_id\\\":18603,\\\"dsp_campaign_id\\\":\\\"590162\\\",\\\"ad_source_id\\\":200,\\\"dsp_creative_id\\\":\\\"625187\\\",\\\"insertion_id\\\":590162,\\\"placement_id\\\":84242,\\\"portfolio_item_id\\\":1,\\\"early_click_protection_duration\\\":0,\\\"exclusiveAdOnScreen\\\":false}],\\\"wigoEnabled\\\":false,\\\"placementMetadata\\\":{\\\"84242\\\":{\\\"auctionId\\\":\\\"a9995fbe-1cb5-4e1a-858f-266903d7d772\\\"}},\\\"viewerId\\\":\\\"b1aefcc416eb3116e70d52e5ac0618abcf6645f4\\\"}\",\"adid\":\"625187\",\"adomain\":[\"teads.com\"],\"cid\":\"1088501\",\"crid\":\"625187\",\"cat\":[\"IAB12\"],\"ext\":{\"prebid\":{\"meta\":{\"rendererName\":\"teads\",\"rendererVersion\":\"1.0.0\",\"rendererData\":{\"resize\":true,\"sdkEngineVersion\":\"189\"}}}}}" +}