A package to help support the implementation of ads on your iOS app.
- For Swift 5.3, Xcode 12.5 (macOS Big Sur) or later.
- Support for apps from iOS 13.0 or newer.
- InterstitialAd
- RewardedAd
- RewardedInterstitialAd
- AppOpenAd
- NativeAd
- BannerAd
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:
- Select target project.
- Select tab
All
, findOther Linker Flags
. - You must set the
-ObjC
flag for both theDebug
andRelease
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()
The function allows receiving additional values from RemoteConfig.
AdMobManager.shared.addActionConfigValue(_ handler: @escaping ((RemoteConfig) -> Void))
AdMobManager.shared.register(remoteKey: String, defaultData: Data)
- remoteKey: The
Key name
you have set on RemoteConfig. - defaultData: The data of the default json string in the application, it is used when the remote cannot be loaded.
Status of consent.
unknow
: Consent has not been requested, do not call show splash in this state.allow
: Agreed. Call to load ads in this state.reject
: Denied.
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.
- Returns nil when registration is not successful or there is no ad with the corresponding name.
AdMobManager.shared.status(type: AdType, name: String) -> Bool?
This function will start loading ads.
AdMobManager.shared.load(type: Reuse,
name: String,
success: Handler? = nil,
fail: Handler? = nil)
This function will start preloading NativeAd
.
AdMobManager.shared.preloadNative(name: String,
success: Handler? = nil,
fail: Handler? = nil)
This function will display ads when ready.
- didFail: The block executes after the ad is not displayed.
- didEarnReward: The block handle the reward for the user.
- didHide: The block executes after the ad has disappeared.
AdMobManager.shared.show(type: Reuse,
name: String,
rootViewController: UIViewController,
didFail: Handler?,
didEarnReward: Handler? = nil,
didHide: Handler?)
This function will display permission change form.
AdMobManager.shared.requestConsentUpdate()
- Download & add file
CustomNativeAdView.xib
. Note: Linked outlets to views, update constraints only. - Create the corresponding
File's owner
, inheritNativeAdMobView
.
class CustomNativeAdView: NativeAdMobView {
override func setProperties() {
load(name: String,
nativeAdView: GADNativeAdView,
rootViewController: UIViewController? = nil,
didReceive: Handler?,
didError: Handler?)
}
}
- Ads will be loaded automatically.
- Call
binding
method to display ads when loading successfully.
Ads will be loaded automatically.
Then, there are two ways you can create BannerAdMobView
:
- By storyboard, changing class of any
UIView
toBannerAdMobView
. Note: SetModule
toAdMobManager
. - By code, using initializer.
bannerAdMobView.load(name: String, rootViewController: UIViewController, didReceive: Handler?)
A package to help supports MMP AppsFlyer and ATT tracking integration on your iOS app.
- For Swift 5.3, Xcode 12.5 (macOS Big Sur) or later.
- Support for apps from iOS 13.0 or newer.
The Swift Package Manager is a tool for managing the distribution of Swift code. To use TrackingSDK
with Swift Package Manger, add it to dependencies in your Package.swift
.
dependencies: [
.package(url: "https://github.com/trinhxuanminh/TrackingSDK.git")
]
Add key - value to the file Info.plist
.
<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key>
<true/>
<key>NSUserTrackingUsageDescription</key>
<string>This will help us optimize the content and improve the app experience for you</string>
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://appsflyer-skadnetwork.com/</string>
Firstly, import TrackingSDK
.
import TrackingSDK
Initialize, start tracking once permission is granted.
- devKey: The AppsFlyer dev key.
- appID: The Apple App ID (without the id prefix).
- timeout: Set
timeout
as such that app users have enough time to see and engage with the ATT prompt.
TrackingSDK.shared.initialize(devKey: String, appID: String, timeout: Double? = nil)
You can enable debug logs.
TrackingSDK.shared.debug(enable: Bool)
This function indicates whether tracking authorization needs to be displayed.
TrackingSDK.shared.status() -> Bool
This function will display the tracking authorization request.
TrackingSDK.shared.requestAuthorization(completed: Handler?)