diff --git a/CriteoAdViewer/Sources/AdViewer/AdNetwork.swift b/CriteoAdViewer/Sources/AdViewer/AdNetwork.swift index d89111b4..61cf0733 100644 --- a/CriteoAdViewer/Sources/AdViewer/AdNetwork.swift +++ b/CriteoAdViewer/Sources/AdViewer/AdNetwork.swift @@ -73,6 +73,7 @@ struct AdNetworks { let standalone: AdNetwork let inHouse: AdNetwork let mraid: AdNetwork + let standaloneSKAdNetwork: AdNetwork let all: [AdNetwork] static let defaultPublisherId = "B-056946" @@ -82,7 +83,8 @@ struct AdNetworks { self.inHouse = inHouseNetwork(controller: controller) self.mediation = googleMediationNetwork(controller) self.mraid = standaloneMRAIDNetwork(controller) - self.all = [mediation, google, standalone, inHouse, mraid] + self.standaloneSKAdNetwork = standaloneWithSKAdNetworkParams(controller) + self.all = [mediation, google, standalone, inHouse, mraid, standaloneSKAdNetwork] } } @@ -170,3 +172,14 @@ private func inHouseNetwork(controller: AdViewController) -> AdNetwork { AdFormat.interstitial: "6yws53jyfjgoq1ghnuqb" ], adViewBuilder: CriteoAdViewBuilder(controller: controller, type: .inHouse)) } + +private func standaloneWithSKAdNetworkParams(_ controller: AdViewController) -> AdNetwork { + AdNetwork( + name: "Standalone - SKAdNetwork", + supportedFormats: [ + AdFormat.banner320x50 + ], + defaultAdUnits: [ + AdFormat.banner320x50: "31589da9edb442329e17" + ], adViewBuilder: CriteoAdViewBuilder(controller: controller, type: .standalone)) + } diff --git a/CriteoAdViewer/Sources/AdViewer/AdViewerViewController.swift b/CriteoAdViewer/Sources/AdViewer/AdViewerViewController.swift index 9bc90069..08dc0671 100644 --- a/CriteoAdViewer/Sources/AdViewer/AdViewerViewController.swift +++ b/CriteoAdViewer/Sources/AdViewer/AdViewerViewController.swift @@ -151,7 +151,7 @@ class AdViewerViewController: FormViewController { $0.options = defaultNetwork.sizes(type: .banner) $0.value = $0.options?.first $0.hidden = .function([Tags.network.rawValue, Tags.type.rawValue]) { form in - if let networkRow: SegmentedRow = self.form.rowBy(tag: Tags.network.rawValue), + if let networkRow: PickerInputRow = self.form.rowBy(tag: Tags.network.rawValue), let typeRow: SegmentedRow = self.form.rowBy(tag: Tags.type.rawValue), let sizeRow: SegmentedRow = self.form.rowBy(tag: Tags.size.rawValue), let network = networkRow.value, @@ -172,27 +172,27 @@ class AdViewerViewController: FormViewController { private func networkSection() -> Section { Section("Network") - <<< SegmentedRow(Tags.network.rawValue) { - $0.options = self.networks.all - $0.value = $0.options?.first - $0.displayValueFor = { network in - network?.name - } - $0.onChange { (row: SegmentedRow) in - if let network = row.value, - let typeRow: SegmentedRow = self.form.rowBy(tag: Tags.type.rawValue), - let sizeRow: SegmentedRow = self.form.rowBy(tag: Tags.size.rawValue) { - typeRow.options = network.types - typeRow.value = typeRow.options?.first - typeRow.reload() - let sizes: [AdSize] = network.sizes(type: typeRow.value!) - sizeRow.options = sizes - sizeRow.value = sizeRow.options?.first - sizeRow.reload() + <<< PickerInputRow(Tags.network.rawValue){ + $0.options = self.networks.all + $0.value = $0.options.first + $0.displayValueFor = { network in + network?.name + } + $0.onChange { (row: PickerInputRow) in + if let network = row.value, + let typeRow: SegmentedRow = self.form.rowBy(tag: Tags.type.rawValue), + let sizeRow: SegmentedRow = self.form.rowBy(tag: Tags.size.rawValue) { + typeRow.options = network.types + typeRow.value = typeRow.options?.first + typeRow.reload() + let sizes: [AdSize] = network.sizes(type: typeRow.value!) + sizeRow.options = sizes + sizeRow.value = sizeRow.options?.first + sizeRow.reload() + } + self.updateAdConfig() } - self.updateAdConfig() } - } } private func updateAdConfig() {