Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify the test device for Admob

Tags:

swift

admob

I use the code below:

let request : GADRequest = GADRequest ()

request.testDevices = ["xxxxxxx",kGADSimulatorID]

But I am getting the below warning:

'testDevices' is deprecated: Use GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers.

Do I use a syntax to remove the warning?

like image 273
Mahmut K. Avatar asked Sep 18 '19 20:09

Mahmut K.


1 Answers

This is a modification to 10623169's answer.

To get a valid ID, for the current device, that can be set in "testDevices", get the MD5 of this: UIDevice.current.identifierForVendor?.uuidString

The asIdentifier value can be completely invalid if the user hasn't given permission for tracking. But the UIDevice.current.identifierForVendor is a valid UUID for the app, that will persist across launches (but perhaps not if you delete the app and reinstall).

like image 127
Dan Morrow Avatar answered Jan 01 '23 21:01

Dan Morrow