A package to help support the implementation of ads on your iOS app.
The Swift Package Manager is a tool for managing the distribution of Swift code. To use AdMobManager
with Swift Package Manger, add it to dependencies in your Package.swift
.
dependencies: [
.package(url: "https://github.com/trinhxuanminh/AdMobManager.git")
]
Initial setup as documented by Google AdMob:
Manually add the -ObjC
linker flag to Other Linker Flags
in your target's build settings:
All
, find Other Linker Flags
.-ObjC
flag for both the Debug
and Release
configurations.Integrate Firebase RemoteConfig with any Key name
and configure it in this json format.
Note: The name of each ad is unique.
Refer to the following Demo project to implement the ad.
Firstly, import AdMobManager
.
import AdMobManager
This function will block registration, loading, and show ads. Note: Priority to use before registration and use after successful premium purchase.
AdMobManager.shared.upgradePremium()
AdMobManager.shared.register(remoteKey: String, defaultData: Data)
Key name
you have set on RemoteConfig.Add actions after completing registration.
AdMobManager.shared.addActionSuccessRegister(_ handler: @escaping Handler)
This function returns the value true/false indicating whether the ad is allowed to show. You can call it to make UI changes, logic in your code.
AdMobManager.shared.status(type: AdType, name: String) -> Bool?
This function will start loading ads.
AdMobManager.shared.load(type: Reuse, name: String)
This function will display ads when ready.
AdMobManager.shared.show(name: String,
rootViewController: UIViewController,
didShow: Handler?,
didFail: Handler?)
CustomNativeAdView.xib
.
Note: Linked outlets to views, update constraints only.File's owner
, inherit NativeAdMobView
.class CustomNativeAdView: NativeAdMobView {
override func setProperties() {
startAnimation()
binding(nativeAdView: nativeAdView) { [weak self] in
guard let self = self else {
return
}
self.stopAnimation()
}
load(name: String, rootViewController: nil)
}
}
binding
method to display ads when loading successfully.Ads will be loaded automatically.
Then, there are two ways you can create BannerAdMobView
:
UIView
to BannerAdMobView
. Note: Set Module
to AdMobManager
.bannerAdMobView.load(name: String, rootViewController: nil)
link |
Stars: 7 |
Last commit: Yesterday |
Add Remote Config
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics