Monday, December 26, 2016

Getting Device Ids for AdMob

4:18 AM Posted by Kerim , , , , 2 comments
When using AdMob in our projects, be it a Unity game or an app, we better test our ads on a real device besides emulators. But to comply with the AdMob policy, we need to add the tester device's Id as a test device in our AdMob code. But how to find our device's Id?

iOS

When we create an ad request in code, we can add test devices too.

For Objective-C: 

GADRequest *request = [GADRequest request];
request.testDevices = @[@"3423aa7873bec7837928"];

And for Swift:

let request = GADRequest()
request.testDevices = ["3423aa7873bec7837928"]

Just run your app or your game from XCode with those arbitrary values and look at the Logs window. You'll see something like that:

<Google> To get test ads on this device, call: request.testDevices = @[@"xxxx" ];

So, what is written instead of "xxxx" is your device's Id. Just copy this Id and paste it to your code.


Android

The simplest way to find the device id for Android is to use Android Studio. Just open the Android Studio and run your app and look at the LogCat window. Type "Ads" to the filter of this LogCat window and search for :

2 comments:

  1. In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips. I like your writing style and I hope you will keep doing this good working.keep it up!!

    android training in chennai

    android online training in chennai

    android training in bangalore

    android training in hyderabad

    android Training in coimbatore

    android training

    android online training

    ReplyDelete