HI,
ALManager is a lightweight library that helps developers structure and easily use Ads with AppLovin.
To integrate MiTuKit into your Xcode project using CocoaPods, specify it in your Podfile:
target 'MyApp' do
pod 'ALManager'
endThe Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but ALManager does support its use on supported platforms.
Once you have your Swift package set up, adding ALManager as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.package(url: "https://github.com/hominhtuong/ALManager.git", .upToNextMajor(from: "0.0.1"))
]import ALManager
class ViewController: UIViewController {
func setupAd() {
Task {
let adUnits = ALAdUnits(
openAdUnitID: AdUnits.openAdUnitID,
bannerAdUnitID: AdUnits.bannerAdUnitID,
interstitialAdUnitID: AdUnits.interstitialAdUnitID,
rewardAdID: AdUnits.rewardAdID
)
await ALManager.shared.setup(sdkKey: applovinSDKKey, units: adUnits)
ALManager.shared.loadInterstitial()
//...
}
}
}
import ALManager
class ViewController: UIViewController {
func nextScreen() {
ALManager.shared.showInterstitial()
self.navigationController?.pushViewController(NextScreen(), animated: true)
}
func showAdAndNextScreen() {
ALManager.shared.showInterstitial { state in
if state == .showed {
} else {
self.navigationController?.pushViewController(NextScreen(), animated: true)
}
}
}
}The state from the completion handler in a successful case will be called twice (didDisplay and didHide - .showed and .hidden).
You can navigate to another screen when state == .showed while the interstitial is being presented (without affecting the user experience) or after it is dismissed with state == .hidden.
import ALManager
class ViewController: UIViewController {
func setupView() {
let bannerView = UIView()
bannerView >>> view >>> {
$0.snp.makeConstraints {
$0.leading.trailing.equalToSuperview()
$0.bottom.equalTo(botSafe)
$0.height.equalTo(50)
}
$0.attachBanner()
}
}
}ALManager is released under the MIT license. See LICENSE for details.
My website: Visit