| Native Advanced | Banner |
|---|---|
![]() |
![]() |
This package contains useful Banner and Native Ads components for Google AdMob.
- Swift 6.0 or later
- macOS 14, iOS 17, tvOS 17, watchOS 10, macCatalyst 17 or later
-
Using GUI
Type the URL bellow to add this package to your project.
https://github.com/taka-2120/AdMobComponents.git
-
Add to
Package.swiftmanually-
Add this package to the dependencies.
dependencies: [ .package( url: "https://github.com/taka-2120/AdMobComponents.git", .upToNextMajor(from: "1.0.0") ), ],
-
Add this package product to your target.
targets: [ .target( name: "YourTarget", dependencies: [ .product(name: "AdMobComponents", package: "AdMobComponents"), ] ), ]
-
-
Add
configureAdMobmodifier to configure Native Ads and start network observer in yourAppstruct.* Note: Network observer is required to display ad placeholder when the network is not available.
import AdMobComponents @main struct YourApp: App { var body: some Scene { WindowGroup { ContentView() .configureAdMob( nativeAdCount: 5, nativeAdUnitID: "ca-app-pub-....", canLoadNativeAds: !isPurchased, // This variable is just an example. You can use your own variable. nativeAdRefreshInterval: 30 ) } } }
-
Add
bannerAdmodifier to yourView.import AdMobComponents ... @State private var isBannerAdPresented = false ... yourView .bannerAd(isPresented: isBannerAdPresented, adUnitID: "ca-app-pub-....")
-
Add
NativeAdViewcomponent into yourView.import AdMobComponents ... NativeAdView(showsAt: 0)

