📦 SwiftyLaunch Modules
📢 AdsKit
Using AdsKit

Using AdsKit to Display Banner Ads in your SwiftUI App

AdsKit (SwiftyLaunch Module) - Using AdsKit to Display Banner Ads in your SwiftUI App

SwiftyLaunch's AdsKit allows you to seemlessly integrate banner ads into your SwiftUI app. For this, we have created a SwiftUI View called AdBanner, which takes a single parameter: the Ad Unit ID.

💡

Don't know how to get the Ad Unit ID? Follow our initial AdsKit setup to get started.

The Ad will then appear whenever you placed it. It will take up the whole width of the parent view and have a height of 75 points.

Here's an example from the AdsKitExamples view:

AdsKitExamples.swift
public struct AdsKitExamples: View {
    // ...
	public var body: some View {
		// ...
        VStack {
            // ...
            AdBanner(adUnitID: "ca-app-pub-3940256099942544/3986624511")
            Spacer()
            // ...
        }
        // ...
	}
}

That's it! You now have a banner ad in your app.

Best Practices

It is recommended to place your AdBanner at the top of your view, or at the bottom of your view, to avoid overlapping with other content.

Ad Placement

Additionally, make sure to not include it inside a ScrollView, but keep it outside of it.

Ad Unit ID

The Ad Unit ID is reserved for one type of ad (ad format). Make sure to pick Native Advanced when creating your ad unit in Google AdMob. You can use a single Ad Unit ID for all banner ads in your app, or create a unique Ad Unit ID for each banner ad (which is the recommended approach, as you can better track what ad placements perform better).