Skip to content
Draft
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.5.1'
pod 'TeadsSDK', '6.0.0'

pod 'TeadsSASAdapter', '5.5.1'
pod 'TeadsAdMobAdapter', '5.5.1'
pod 'TeadsAppLovinAdapter', '5.5.1'
pod 'TeadsSASAdapter', '6.0.0'
pod 'TeadsAdMobAdapter', '6.0.0'
pod 'TeadsAppLovinAdapter', '6.0.0'

pod 'SwiftFormat/CLI'
end
48 changes: 24 additions & 24 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
PODS:
- AppLovinSDK (13.3.1)
- Google-Mobile-Ads-SDK (12.7.0):
- AppLovinSDK (13.5.0)
- Google-Mobile-Ads-SDK (12.12.0):
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleUserMessagingPlatform (3.0.0)
- GoogleUserMessagingPlatform (3.1.0)
- Smart-Display-SDK (7.24.2)
- SwiftFormat/CLI (0.56.4)
- TeadsAdMobAdapter (5.5.1):
- TeadsAdMobAdapter (6.0.0):
- Google-Mobile-Ads-SDK (>= 12.2.0)
- TeadsSDK (= 5.5.1)
- TeadsAppLovinAdapter (5.5.1):
- TeadsSDK (= 6.0.0)
- TeadsAppLovinAdapter (6.0.0):
- AppLovinSDK (>= 11.5.1)
- TeadsSDK (= 5.5.1)
- TeadsSASAdapter (5.5.1):
- TeadsSDK (= 6.0.0)
- TeadsSASAdapter (6.0.0):
- Smart-Display-SDK (>= 7.6.2)
- TeadsSDK (= 5.5.1)
- TeadsSDK (5.5.1):
- TeadsSDK/Core (= 5.5.1)
- TeadsSDK/Core (5.5.1)
- TeadsSDK (= 6.0.0)
- TeadsSDK (6.0.0):
- TeadsSDK/Core (= 6.0.0)
- TeadsSDK/Core (6.0.0)

DEPENDENCIES:
- SwiftFormat/CLI
- TeadsAdMobAdapter (= 5.5.1)
- TeadsAppLovinAdapter (= 5.5.1)
- TeadsSASAdapter (= 5.5.1)
- TeadsSDK (= 5.5.1)
- TeadsAdMobAdapter (= 6.0.0)
- TeadsAppLovinAdapter (= 6.0.0)
- TeadsSASAdapter (= 6.0.0)
- TeadsSDK (= 6.0.0)

SPEC REPOS:
trunk:
Expand All @@ -38,16 +38,16 @@ SPEC REPOS:
- TeadsSDK

SPEC CHECKSUMS:
AppLovinSDK: 5075837afdee4fb429121799b8cbcc5918ef3a23
Google-Mobile-Ads-SDK: 90a3936b11fcb1a9a69b2a33fb608e793666ce73
GoogleUserMessagingPlatform: f8d0cdad3ca835406755d0a69aa634f00e76d576
AppLovinSDK: bf8974163120910e6b902e9610e7c5a2c0f577b6
Google-Mobile-Ads-SDK: 4dde70a8c18d96b14f9548759b8cec6ecb0bc3e6
GoogleUserMessagingPlatform: befe603da6501006420c206222acd449bba45a9c
Smart-Display-SDK: e2c9c881236a0a9f0f6e99e2a2410ca74d9bb41a
SwiftFormat: 40d72dd2f67aa4d8ed5deb5e30011067c986f9cb
TeadsAdMobAdapter: b8d300374bac7c6e23115ae6ddb492cefa2d4be4
TeadsAppLovinAdapter: 1548d97367cd4d0c3ae691a082a082a8d534542d
TeadsSASAdapter: 540464b2b592ef6c8770e734511e6341ee464f32
TeadsSDK: 35d63fcaf798494f84fc61c19a56e4bc0c86a66e
TeadsAdMobAdapter: 217491fb7645382dcb7722bb52f47d8eddcb8115
TeadsAppLovinAdapter: c365029a91c7d16a8b9fafa220dd1819073f117b
TeadsSASAdapter: 60b3e09e1c0ca24faea08cda75f788c1d4f66eed
TeadsSDK: 3f3f102735c45aa127becc84017d85060dae67e5

PODFILE CHECKSUM: 2a1c753588923a4acdf293c9321c923d3e8a3a54
PODFILE CHECKSUM: b1e6f42268f24ac51b54ad1b2bbd8454ea14611d

COCOAPODS: 1.16.2
4 changes: 4 additions & 0 deletions TeadsSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
28AED0FC9C839CB0F08FB2ED /* Pods_TeadsSampleApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25FE69E124DD7520D4468526 /* Pods_TeadsSampleApp.framework */; };
3C4D052A2EB8AD280050513C /* CustomNativeAdView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4D05292EB8AD280050513C /* CustomNativeAdView.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 */
25FE69E124DD7520D4468526 /* Pods_TeadsSampleApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TeadsSampleApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3C4D05292EB8AD280050513C /* CustomNativeAdView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNativeAdView.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 @@ -384,6 +386,7 @@
B5555A4B1F7CEF1C007406D4 /* Cells */ = {
isa = PBXGroup;
children = (
3C4D05292EB8AD280050513C /* CustomNativeAdView.swift */,
E9984EF726B2D46F000D42D3 /* AdmobNativeAdTableViewCell.swift */,
E9984EF526B2D46F000D42D3 /* FakeArticleNativeTableViewCell.swift */,
E9984EF626B2D46F000D42D3 /* NativeTableViewCell.swift */,
Expand Down Expand Up @@ -795,6 +798,7 @@
4079F243252CBE7F00B0AC31 /* ColorExtension.swift in Sources */,
E96C1F9A27E4902D00151530 /* UIView-extension.swift in Sources */,
E9B7170627C7965900FB7DCB /* InReadAppLovinScrollViewController.swift in Sources */,
3C4D052A2EB8AD280050513C /* CustomNativeAdView.swift in Sources */,
B5966D1F269D9982005CA2FF /* InReadAdmobWebViewController.swift in Sources */,
E9984EED26AF3CCC000D42D3 /* NativeAdmobTableViewController.swift in Sources */,
);
Expand Down
223 changes: 223 additions & 0 deletions TeadsSampleApp/Cells/CustomNativeAdView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
//
// CustomNativeAdView.swift
// demo
//
// Created by Assistant on 13/08/2025.
//

import TeadsSDK
import UIKit

/// Factory for creating customized TeadsNativeAdView instances
@available(iOS 13.0, *)
class CustomNativeAdView {
static func create() -> TeadsNativeAdView {
let nativeAdView = TeadsNativeAdView(frame: .zero)
setupCustomLayout(for: nativeAdView)
return nativeAdView
}

private static func setupCustomLayout(for adView: TeadsNativeAdView) {
// adView.translatesAutoresizingMaskIntoConstraints = false
adView.backgroundColor = .systemBackground
adView.layer.cornerRadius = 12
adView.layer.borderWidth = 1
adView.layer.borderColor = UIColor.systemGray4.cgColor

// Add shadow
adView.layer.shadowColor = UIColor.black.cgColor
adView.layer.shadowOpacity = 0.1
adView.layer.shadowOffset = CGSize(width: 0, height: 2)
adView.layer.shadowRadius = 4

// Create and configure UI components
let containerStackView = createContainerStack()
let headerStackView = createHeaderStack()
let contentStackView = createContentStack()

// Create native ad components
let titleLabel = createTitleLabel()
let contentLabel = createContentLabel()
let mediaView = createMediaView()
let iconImageView = createIconImageView()
let advertiserLabel = createAdvertiserLabel()
let callToActionButton = createCallToActionButton()
let sponsoredLabel = createSponsoredLabel()

// Connect outlets
adView.titleLabel = titleLabel
adView.contentLabel = contentLabel
adView.mediaView = mediaView
adView.iconImageView = iconImageView
adView.advertiserLabel = advertiserLabel
adView.callToActionButton = callToActionButton

// Setup hierarchy
adView.addSubview(containerStackView)

// Header with icon and advertiser
headerStackView.addArrangedSubview(iconImageView)
headerStackView.addArrangedSubview(advertiserLabel)
headerStackView.addArrangedSubview(UIView()) // Spacer
headerStackView.addArrangedSubview(sponsoredLabel)

// Content section
contentStackView.addArrangedSubview(titleLabel)
contentStackView.addArrangedSubview(contentLabel)
contentStackView.addArrangedSubview(mediaView)
contentStackView.addArrangedSubview(callToActionButton)

// Main container
containerStackView.addArrangedSubview(headerStackView)
containerStackView.addArrangedSubview(contentStackView)

// Setup constraints
setupConstraints(
containerStackView: containerStackView,
iconImageView: iconImageView,
mediaView: mediaView,
sponsoredLabel: sponsoredLabel,
callToActionButton: callToActionButton,
adView: adView
)
}

// MARK: - Component Factories

private static func createContainerStack() -> UIStackView {
let stack = UIStackView()
stack.axis = .vertical
stack.spacing = 12
stack.distribution = .fill
stack.alignment = .fill
stack.translatesAutoresizingMaskIntoConstraints = false
return stack
}

private static func createHeaderStack() -> UIStackView {
let stack = UIStackView()
stack.translatesAutoresizingMaskIntoConstraints = false
stack.axis = .horizontal
stack.spacing = 8
stack.alignment = .center
stack.distribution = .fill
return stack
}

private static func createContentStack() -> UIStackView {
let stack = UIStackView()
stack.translatesAutoresizingMaskIntoConstraints = false
stack.axis = .vertical
stack.spacing = 8
stack.distribution = .fill
stack.alignment = .fill
return stack
}

private static func createTitleLabel() -> UILabel {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.boldSystemFont(ofSize: 16)
label.textColor = .label
label.numberOfLines = 2
return label
}

private static func createContentLabel() -> UILabel {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = .secondaryLabel
label.numberOfLines = 3
return label
}

private static func createMediaView() -> TeadsMediaView {
let mediaView = TeadsMediaView()
mediaView.translatesAutoresizingMaskIntoConstraints = false
mediaView.contentMode = .scaleAspectFill
mediaView.clipsToBounds = true
mediaView.layer.cornerRadius = 8
mediaView.backgroundColor = .systemGray5
return mediaView
}

private static func createIconImageView() -> UIImageView {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 16
imageView.backgroundColor = .systemGray4
return imageView
}

private static func createAdvertiserLabel() -> UILabel {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 12, weight: .medium)
label.textColor = .tertiaryLabel
label.numberOfLines = 1
return label
}

private static func createCallToActionButton() -> UIButton {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14)
button.backgroundColor = .systemBlue
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 6
return button
}

private static func createSponsoredLabel() -> UILabel {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Sponsored"
label.font = UIFont.systemFont(ofSize: 10)
label.textColor = .tertiaryLabel
label.backgroundColor = .systemGray6
label.textAlignment = .center
label.layer.cornerRadius = 4
label.clipsToBounds = true
return label
}

// MARK: - Constraints

private static func setupConstraints(
containerStackView: UIStackView,
iconImageView: UIImageView,
mediaView: TeadsMediaView,
sponsoredLabel: UILabel,
callToActionButton: UIButton,
adView: TeadsNativeAdView
) {
NSLayoutConstraint.activate([
// Container
containerStackView.topAnchor.constraint(equalTo: adView.topAnchor, constant: 12),
containerStackView.leadingAnchor.constraint(
equalTo: adView.leadingAnchor, constant: 12
),
containerStackView.trailingAnchor.constraint(
equalTo: adView.trailingAnchor, constant: -12
),
containerStackView.bottomAnchor.constraint(equalTo: adView.bottomAnchor, constant: -12),

// Icon
iconImageView.widthAnchor.constraint(equalToConstant: 32),
iconImageView.heightAnchor.constraint(equalToConstant: 32),

// Media view
mediaView.heightAnchor.constraint(equalToConstant: 160),

// Sponsored label
sponsoredLabel.widthAnchor.constraint(equalToConstant: 70),
sponsoredLabel.heightAnchor.constraint(equalToConstant: 18),

// CTA button
callToActionButton.heightAnchor.constraint(equalToConstant: 36),
])
}
}
Loading