📦 SwiftyLaunch Modules
📢 AdsKit
Overview

AdsKit Module Overview

SwiftyLaunch Module - AdsKit

Powered by Google AdMob

AdsKit wraps Google AdMob SDK to allow you to monetize your apps by showcasing ads that look native and don't annoy your users.

After generating a project with AdsKit enabled and completing the initial project setup, you will get following features out of the box:

  • Native-Looking Ad Banners: Ad Banners that look right in place in your app, without using the default AdMob banners. Refer to Using AdsKit for more information.
  • AnalyticsKit Integration: Automatically track events related to the user interacting with ads. Read more.
  • InAppPurchaseKit Integration: Ability to remove ads for the user after purchasing a premium plan. Read more.

Module Deep Dive

AdsKit utilized AdMob's Native Ads Advanced API to create ad banners that look native in your app. The ads are loaded asynchronously and are displayed in a AdBanner SwiftUI view.

Fetching of ads occurs in the NativeAdBannerViewModel by calling the refreshAd() function, which is called every time the AdBanner is shown on screen. Even though the function can be called multiple times in a row, we set a fixed request interval to only fetch ads at minimum every 30 minutes.

After the ad is fetched, we the ad data is stored in the nativeAd property, and is used to build our own native ad within the NativeAdView and NativeAdBannerView.

NativeAdView takes all the information and passes it to the NativeAdBannerView, which is a subclass of GADNativeAdView and programmatically builds the ad using UIKit.

AnalyticsKit Integration

If AnalyticsKit was selected during project generation, events regarding user interacting with ads will automatically be tracked with adskit as the source. Currently, two events are tracked by default: when user views an ad and when user interacts (tap) with an ad.

InAppPurchaseKit Integration

If InAppPurchaseKit was selected during project generation, the AdBanner view will check whether the user has a premium subscription and will not display the ad banner if the user is subscribed.