我正在尝试使用 Google 的 AdMob SDK 为我的 iOS 应用程序实施广告。
我一直在关注官方 [docs](https://developers.google.com/admob/ios/quick-start),但我无法让它发挥作用。
到目前为止我所做的:
- 创建了一个 AdMob 帐户并注册了我的应用。
- 更新了我的info.plist,使其与教程中显示的格式相匹配。
不用说,我用我从 Google AdMob 帐户获得的 ID 替换了教程的应用 ID。 - 使用info.plist更改(没有任何导入或其他代码)按原样构建我的应用程序已经引入了一些奇怪的日志:
2020-11-16 03:14:08.242623+0200 [5520:1418287] - <Google>[I-ACS025031] AdMob App ID changed. Original, new: (nil), ca-app-pub-2838133095156647~5679250242
2020-11-16 03:14:08.249700+0200 [5520:1418287] [NetworkInfo] Could not successfully update network info for descriptor <CTServiceDescriptor 0x281b3cec0, domain=1, instance=2> during initialization.
2020-11-16 03:14:08.250665+0200 [5520:1418287] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x281b3f1a0, domain=1, instance=1>
2020-11-16 03:14:08.251144+0200 [5520:1418287] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x281b3cec0, domain=1, instance=2>
2020-11-16 03:14:08.258569+0200 [5520:1418287] - <Google>[I-ACS023007] Analytics v.70100000 started
2020-11-16 03:14:08.259511+0200 [5520:1418287] - <Google>[I-ACS023008] To enable debug logging set the following application argument: -APMAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
2020-11-16 03:14:08.285264+0200 [5520:1418283] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2020-11-16 03:14:08.286833+0200 [5520:1418283] [MC] Reading from public effective user settings.
2020-11-16 03:14:08.303409+0200 [5520:1418283] - <Google>[I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-11-16 03:14:08.325373+0200 [5520:1418286] - <Google>[I-ACS023012] Analytics collection enabled
- 然后,我使用 cocoapods 下载了 Google-Mobile-Ads-SDK 并尝试使用以下代码初始化移动广告 SDK:
AppDelegate.swift:
// other imports
import GoogleMobileAds
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window : UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
GADMobileAds.sharedInstance().start(completionHandler: nil)
if #available(iOS 13, *) {
return true
}
else {
self.window = UIWindow()
let vc = ViewController()
self.window!.rootViewController = vc
self.window!.makeKeyAndVisible()
}
return true
}
...
这引入了一个新错误:主线程检查器:在后台线程上调用的 UI API(除了来自 #3 的奇怪日志记录之外)。
我的问题是什么?任何帮助,将不胜感激!