Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid standalone integration sample app #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ target 'TeadsSampleApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

pod 'TeadsSDK', '~> 5.1'
pod 'TeadsSDK', '~> 5.1.2'

pod 'TeadsSASAdapter', '~> 5.1'
pod 'TeadsAdMobAdapter', '~> 5.1'
pod 'TeadsAppLovinAdapter', '~> 5.1'
pod 'TeadsSASAdapter', '~> 5.1.2'
pod 'TeadsAdMobAdapter', '~> 5.1.2'
pod 'TeadsAppLovinAdapter', '~> 5.1.2'

pod 'SwiftFormat/CLI'
end
48 changes: 24 additions & 24 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ PODS:
- Google-Mobile-Ads-SDK (10.8.0):
- GoogleAppMeasurement (< 11.0, >= 7.0)
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleAppMeasurement (10.23.1):
- GoogleAppMeasurement/AdIdSupport (= 10.23.1)
- GoogleAppMeasurement (10.24.0):
- GoogleAppMeasurement/AdIdSupport (= 10.24.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (10.23.1):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.23.1)
- GoogleAppMeasurement/AdIdSupport (10.24.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.24.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (10.23.1):
- GoogleAppMeasurement/WithoutAdIdSupport (10.24.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
Expand Down Expand Up @@ -59,25 +59,25 @@ PODS:
- Smart-Display-SDK (7.18.0):
- Smart-Core-SDK (~> 7.18)
- SwiftFormat/CLI (0.50.1)
- TeadsAdMobAdapter (5.1.1):
- TeadsAdMobAdapter (5.1.2):
- Google-Mobile-Ads-SDK (>= 9.0.0)
- TeadsSDK (= 5.1.1)
- TeadsAppLovinAdapter (5.1.1):
- TeadsSDK (= 5.1.2)
- TeadsAppLovinAdapter (5.1.2):
- AppLovinSDK (>= 11.5.1)
- TeadsSDK (= 5.1.1)
- TeadsSASAdapter (5.1.1):
- TeadsSDK (= 5.1.2)
- TeadsSASAdapter (5.1.2):
- Smart-Display-SDK (>= 7.6.2)
- TeadsSDK (= 5.1.1)
- TeadsSDK (5.1.1):
- TeadsSDK/Core (= 5.1.1)
- TeadsSDK/Core (5.1.1)
- TeadsSDK (= 5.1.2)
- TeadsSDK (5.1.2):
- TeadsSDK/Core (= 5.1.2)
- TeadsSDK/Core (5.1.2)

DEPENDENCIES:
- SwiftFormat/CLI
- TeadsAdMobAdapter (~> 5.1)
- TeadsAppLovinAdapter (~> 5.1)
- TeadsSASAdapter (~> 5.1)
- TeadsSDK (~> 5.1)
- TeadsAdMobAdapter (~> 5.1.2)
- TeadsAppLovinAdapter (~> 5.1.2)
- TeadsSASAdapter (~> 5.1.2)
- TeadsSDK (~> 5.1.2)

SPEC REPOS:
trunk:
Expand All @@ -99,19 +99,19 @@ SPEC REPOS:
SPEC CHECKSUMS:
AppLovinSDK: 5c667a790725d9529c01c3f3acf12ab195865fbb
Google-Mobile-Ads-SDK: 69daa7fb42061b425340706e382e87fab3e666a3
GoogleAppMeasurement: 794d1d2f71fdf77a077a3986258a5c2dac0f9d48
GoogleAppMeasurement: f3abf08495ef2cba7829f15318c373b8d9226491
GoogleUserMessagingPlatform: 5f8b30daf181805317b6b985bb51c1ff3beca054
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
nanopb: 438bc412db1928dac798aa6fd75726007be04262
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Smart-Core-SDK: 7f2b321a2f8a4233481db716a30a2715d2fafbd1
Smart-Display-SDK: 83450dd0befaa55f08779a8c67c30bd6d8e80ee9
SwiftFormat: e73212c71908404e333da34e303772b9e516ac9b
TeadsAdMobAdapter: 97c740bade7f433ec73372d0fe1c2e7bedaeeab4
TeadsAppLovinAdapter: f44f998464a570cb7ae37b2e4cdf9134f797f8d2
TeadsSASAdapter: 851149447b24293cbcb8c0f2ca93c8739ca6d969
TeadsSDK: 70452f9e291c33fc148ef9eca8425c72b903fa16
TeadsAdMobAdapter: ee85996c50697f1e8161b39ccf6869bfa8cc719d
TeadsAppLovinAdapter: 5b9e97b1f3f00b8879afd006b2688b810f89c888
TeadsSASAdapter: 2c51148a09fa727849655ef40bb1d836f1164599
TeadsSDK: 2a325eb7ee215db3b58df6ced5495ead2b3dfb8c

PODFILE CHECKSUM: 393b53fe773fe70c29dfb94ca995faa7d222f72d
PODFILE CHECKSUM: 638a8ade2e5537f7bb26e59df959b3cba02c3ee2

COCOAPODS: 1.15.2
4 changes: 4 additions & 0 deletions TeadsSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -71,6 +72,7 @@

/* Begin PBXFileReference section */
13915D12E3814B15B3832777 /* Pods_TeadsSampleApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TeadsSampleApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3C3CF0BC2BC80530002A20FA /* PrebidAdResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidAdResponse.swift; sourceTree = "<group>"; };
40077B422534AABF00D53197 /* InReadDirectCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InReadDirectCollectionViewController.swift; sourceTree = "<group>"; };
4079F242252CBE7F00B0AC31 /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
4079F252252CC1EF00B0AC31 /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -219,6 +221,7 @@
isa = PBXGroup;
children = (
B5555A4D1F7D3177007406D4 /* InReadDirectScrollViewController.swift */,
3C3CF0BC2BC80530002A20FA /* PrebidAdResponse.swift */,
);
path = ScrollView;
sourceTree = "<group>";
Expand Down Expand Up @@ -763,6 +766,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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

// Prebid request with the getData
print(teadsBidRequestExtraData)

// 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)
// Load ad
placement?.loadAd(adResponse: PrebidAdResponse.FAKE_WINNING_BID_RESPONSE, requestSettings: adRequestSettings)
}

deinit {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PrebidAdResponse.swift
// TeadsSampleApp
//
// Created by Richard Dépierre on 11/04/2024.
// Copyright © 2024 Teads. All rights reserved.
//

import Foundation

enum PrebidAdResponse {
static let FAKE_VAST_CONTENT = "<VAST xmlns:xsi=\\\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\\\" version=\\\\\\\"2.0\\\\\\\"><Ad id=\\\\\\\"5766402401632256\\\\\\\"><InLine><AdSystem>Brainient8</AdSystem><AdTitle><![CDATA[Brainient8 6833-5766402401632256]]></AdTitle><Impression><![CDATA[https://studio-t.teads.tv/track?action=studio_impression&studio_cid=5766402401632256&random=[CACHEBUSTING]&]]></Impression><Creatives><Creative sequence=\\\\\\\"1\\\\\\\"><Linear><Duration>00:00:15</Duration><MediaFiles><MediaFile id=\\\\\\\"brhtml5\\\\\\\" delivery=\\\\\\\"progressive\\\\\\\" width=\\\\\\\"960\\\\\\\" height=\\\\\\\"540\\\\\\\" type=\\\\\\\"application/javascript\\\\\\\" apiFramework=\\\\\\\"VPAID\\\\\\\"><![CDATA[https://s8t.teads.tv/vpaid/5766402401632256]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>"

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\\\":\\\"VastXml\\\",\\\"content\\\":\\\"\(FAKE_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\"}}"
}