Swift 4.2, iOS 12.x
Trying to implement AdMob in my app, but not getting very far.
- Created an adMob account, looks ok?
- Added NSAppTransportSecurity keys to info.plist ok?
Added this code to load an banner add ok.
bannerView = GADBannerView(adSize: GADAdSize(size: CGSize(width: 320, height: 50), flags: 0), origin: CGPoint(x: 0, y: 0)) bannerView.adUnitID = "ca-app-pub-A/B" // changed this code in this post bannerView.rootViewController = self.view?.window?.rootViewController bannerView.delegate = self let request = GADRequest() request.testDevices = [ kGADSimulatorID ] bannerView.load(request) self.view?.window?.rootViewController?.view.addSubview(bannerView)
Extended class to support GADBannerViewDelegate; getting a call back on it which says error, no ad to show. The console in fact reports this.
2018-12-18 11:49:35.468445+0100 DeX[1547:900808] WF: _WebFilterIsActive returning: YES 2018-12-18 11:49:35.468729+0100 DeX[1547:900808] WF: _userSettingsForUser mobile: { filterBlacklist = ( ); filterWhitelist = ( ); noOverridingAllowed = 1; restrictWeb = 1; useContentFilter = 1; useContentFilterOverrides = 0; whitelistEnabled = 0; } 2018-12-18 11:49:35.468821+0100 DeX[1547:900808] WF: Checking if https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html is in contentFilterOverriddenBlackList 2018-12-18 11:49:35.469159+0100 DeX[1547:900808] WF: Checking if https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html is in contentFilterOverriddenWhiteList 2018-12-18 11:49:35.513610+0100 DeX[1547:900808] WF: * WFLSMMap initWithMap: unable to retrieve threshold from map file. 2018-12-18 11:49:35.518259+0100 DeX[1547:900808] WF: WFLSMScoreNormalizedMap category:1 min:0.338760 max:0.663066 scope:0.324306 2018-12-18 11:49:35.518377+0100 DeX[1547:900808] WF: WFLSMScoreNormalizedMap category:2 min:0.336934 max:0.661240 scope:0.324306 2018-12-18 11:49:35.518439+0100 DeX[1547:900808] WF: +[WFJudge defaultJudge] map:/System/Library/PrivateFrameworks/WebContentAnalysis.framework/content_filter_map3 2018-12-18 11:49:35.518559+0100 DeX[1547:900808] WF: Page not worth analyzing [pageContent length]:7 [[self images] count]==0 [[self scriptBlocks] count]:2 2018-12-18 11:49:35.518693+0100 DeX[1547:900808] WF: WebFilterEvaluator:addData: https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html is not blocked: 'googleads.g.doubleclick.net' is not explicit 2018-12-18 11:49:35.518760+0100 DeX[1547:900808] WF: WebFilterEvaluator:addData: 'googleads.g.doubleclick.net' at https://googleads.g.doubleclick.net/mads/static/sdk/native/sdk-core-v40.html is not blocked * error *** Request Error: No ad to show.
What have I missed out here? Created the account yesterday afternoon, so less than 24 hours past since I did so?
bannerUIView.rootViewController = self.view?.window?.rootViewController