To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];

前端 未结 6 769
情歌与酒
情歌与酒 2021-02-07 13:54

While i test Admob in simulator, it throws below error

To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATO

6条回答
  •  春和景丽
    2021-02-07 14:04

    Since the newest update the request.testDevices has been replaced with:

    GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers
    

    I have gotten it to work with this:

    GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [(kGADSimulatorID as! String)]
    

    [EDIT]

    In my app delegate I am using this code:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            
        // use this for production 
        GADMobileAds.sharedInstance().start(completionHandler: nil)
        // use this for testing 
        GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = [ kGADSimulatorID ]
            
        return true
    }
    

    This is for Swift 5, iOS 13 and Google-Mobile-Ads-SDK (7.58.0)

提交回复
热议问题