Skip to content

Aniview/ad-player-sdk-ios-pods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AdPlayerSDK iOS

Requirements

Installation

SpotImStandaloneAds is available through CocoaPods. To install it, add the following line to your Podfile:

target 'YourApp' do
  pod 'AdPlayerSDK'
end

Usage example

AppDelegate.swift

import AdPlayerSDK
import AppTrackingTransparency

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // swiftlint:disable:this line_length

        createLandingScreen()
        AdPlayer.initSdk(storeURL: URL(string: "https:apps.apple.com/.....")!)

        return true
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        /// NOTE: request GDPR consent if needed
        /// https://support.google.com/admanager/answer/7673898?hl=en&ref_topic=10366389&sjid=10800144486024696532-EU

        if #available(iOS 14, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                print("Tracking: authorized:", status == .authorized)
            }
        }
    }
}

YourViewController.swift

import AdPlayerSDK

class YourViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        /// NOTE: request GDPR consent if needed
        /// https://support.google.com/admanager/answer/7673898?hl=en&ref_topic=10366389&sjid=10800144486024696532-EU
    
        let placement = AdPlayerPlacementViewController(tagId: tagId)
        placement.view.translatesAutoresizingMaskIntoConstraints = false
        addChild(placement)
        view.addSubview(placement.view)
        NSLayoutConstraint.activate([
            placement.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            placement.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            placement.view.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor)
        ])
        placement.didMove(toParent: self)
    }
}

Sample project

ADPlayerBasicSample

Author

https://aniview.com/

License

All rights reserved to ANIVIEW LTD 2023