Swift Admob Console没有显示设备测试ID?

时间:2017-04-18 23:59:52

标签: ios swift firebase admob

我已将Admob实施到我的项目中但是我无法为我的iPhone添加测试设备。

以下是代码:

 let request = GADRequest()
    request.testDevices = [kGADSimulatorID, "XXXXX"]
    myAd = GADInterstitial(adUnitID: "ca-app-pub-4411736350819540/1731977917")
    myAd.delegate = self
    myAd.load(request)

我在运行应用时未在控制台中显示我的设备ID,它只显示实际广告,而不是测试广告。

它在模拟器中工作正常。

iPhone设备ID是否是iTunes中的UDID?

当我注释掉testDevices行时,这就是控制台显示的内容:

2017-04-20 01:57:57.311 SpaceShip[2798:] <FIRAnalytics/INFO> Firebase Analytics v.3600000 started
2017-04-20 01:57:57.392 SpaceShip[2798:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled 
2017-04-20 01:57:57.398: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-04-20 01:57:57.397 SpaceShip[2798:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
true
2017-04-20 01:58:05.367 SpaceShip[2798:] <FIRAnalytics/INFO> Firebase Analytics enabled

1 个答案:

答案 0 :(得分:0)

您的测试ID未在控制台中打印,因为您已将测试ID设置为:

request.testDevices = [kGADSimulatorID, "XXXXX"] // It thinks "XXXXX" is your test ID

request

中注释掉
let request = GADRequest()
// request.testDevices = [kGADSimulatorID, "XXXXX"]
myAd = GADInterstitial(adUnitID: "ca-app-pub-4411736350819540/1731977917")
myAd.delegate = self
myAd.load(request)

在您评论之后再次运行您的应用程序。测试ID现在应该在您的控制台中。

获得测试ID后,取消注释request.testDevices,然后将XXXXX替换为您的测试ID。

let request = GADRequest()
request.testDevices = [kGADSimulatorID, "XXXXX"]
myAd = GADInterstitial(adUnitID: "ca-app-pub-4411736350819540/1731977917")
myAd.delegate = self
myAd.load(request)