AdsKit Setup
Perform this setup if after you're done setting up DatabaseKit and AuthKit.
Create an AdMob Account
If you haven't already, create an AdMob Account (opens in a new tab).
Set up the first App
In your AdMob Dashboard, go to Apps in the sidebar, and press on Add App.
Select iOS as platform, and No, the App isn't listed yet. Press on Continue.
Enter the name of your app and press on Add App.
Create Ad Unit ID
In the overview of your app in the AdMob Dashboard, press on Add Ad Unit.
Because apps with AdsKit present ads that are natively integrated into the app, select Native Advanced as the ad format.
Enter a name for your ad unit (in our case NativeBanner1), select in advanced setting the media type to Image only, and press on Create Ad Unit.
AdsKit currently only supports natively displayed banner, which doesn't support video ads.
On the next screen you'll see two important values. Write them down.
- First, is your AdMob App ID. This is the same for all ad units in your app.
- Second, is your Ad Unit ID. This is unique for each ad unit displayed in your application. So for each banner you want to display, you can create a new ad unit. But you could also just reuse the same ad unit for all banners.
Adding AdMob App ID to your App
Add App ID to Info.plist
In your App's Info.plist, set the GADApplicationIdentifier
to your AdMob App ID from the previous step.
Adding Network Items to Info.plist
Additionally, add following SKAdNetworkitems
to your Info.plist. Since SwiftyLaunch 1.4.1, these are already automatically
included in the Info.plist
file. We would recommend to add them by opening the Info.plist
file in an editor and copy-pasting
the following XML snippet:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cstr6suwn9.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>4fzdc2evr5.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>2fnua5tdw4.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>ydx93a7ass.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>p78axxw29g.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>v72qych5uu.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>ludvb6z3bs.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cp8zw746q7.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>3sh42y64q3.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>c6k4g5qg8m.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>s39g8k73mm.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>3qy4746246.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>hs6bdukanm.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>mlmmfzh3r3.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>v4nxqhlyqp.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>wzmmz9fp6w.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>su67r6k2v3.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>yclnxrl5pm.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>7ug5zh24hu.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>gta9lk7p23.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>vutu7akeur.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>y5ghdn5j9k.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>v9wttpbfk9.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>n38lu8286q.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>47vhws6wlr.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>kbd757ywx3.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>9t245vhmpl.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>a2p9lx4jpn.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>22mmun2rn5.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>4468km3ulz.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>2u9pt9hc89.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>8s468mfl3y.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>ppxm28t8ap.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>uw77j35x4d.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>pwa73g5rt2.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>578prtvx9j.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>4dzt52r2t5.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>tl55sbb4fm.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>e5fvkxwrpn.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>8c4e2ghe7u.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>3rd42ekr43.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>3qcr597p9d.skadnetwork</string>
</dict>
</array>
Otherwise, you can add them manually:
Add Ad Unit ID to your App
In the generated Xcode Project, we have created a special AdsKitExamples()
view located in
AdsKit/View/AdsKitExamples.swift
. This contains a simple implementation of AdsBanner, which requires
an ad unit ID. copy paste the ad unit ID you wrote down earlier into the adUnitID
variable.
AdBanner(adUnitID: "YOUR_AD_UNIT_ID")
To test the native ads implementation, you can use the test ad unit ID
ca-app-pub-3940256099942544/3986624511
. Remember to replace it with your own
ad unit ID before submitting your app to the App Store.
Run the App
When running the app, and opening AdsKit Examples, you should see a banner ad displayed at the top of the screen.
Setting Test Device ID
If you get following error message in the console:
,
Then add the following line in the initGoogleMobileAds()
function in `Ads.swift``
public class Ads {
public static func initGoogleMobileAds() {
GADMobileAds.sharedInstance().start(completionHandler: nil)
GADMobileAds.sharedInstance()
.requestConfiguration.testDeviceIdentifiers = [ "DEVICE_TEST_ID_FROM_CONSOLE" ]
}
}
X required SKAdNetwork identifier(s) missing from Info.plist.
That means that GoogleAdMob couldn't find all the network identifiers from your Info.plist.
Make sure that you have added all the SKAdNetworkItems
to your Info.plist. We try to keep
the XML above updated, but here is the AdMob Documentation (opens in a new tab)
that should contain all relevant network identifiers.
If this doesn't fix it, try cleaning Xcode cache or reinstalling the app. Sadly this is a common issue with GoogleAdMob.
Account not approved yet
If you see the following message in the console:
Then your account hasn't been approved yet. This can take up to 24 hours. In the meantime, you can use the test ad unit ID.
After Release on the App Store
After your App has been released on the app store, you will be required to link your app in the Google AdMob app with your App Store listing.
In your App Settings, go to App Store Details > ADD and follow the steps there.