Optional Google Advertising ID
The Google Advertising ID is a user-specific, unique, resettable ID for advertising, provided by Google Play services. It gives users better controls and provides developers with a simple, standard system to continue to monetize your apps. It is an anonymous identifier for advertising purposes and enables users to reset their identifier or opt-out of interest-based ads within Google Play apps. See here for more information.
Passing the Google Advertising ID to Braze
The Google Advertising ID is not automatically collected by the Braze SDK and must be set manually via the Appboy.setGoogleAdvertisingId()
method.
important:
Google requires the Advertising ID to be collected on a non-UI thread.
1
2
3
4
5
6
7
8
9
10
11
new Thread(new Runnable() {
@Override
public void run() {
try {
AdvertisingIdClient.Info idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
Appboy.getInstance(getApplicationContext()).setGoogleAdvertisingId(idInfo.getId(), idInfo.isLimitAdTrackingEnabled());
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
1
2
3
4
5
6
7
8
Thread(Runnable {
try {
val idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext())
Appboy.getInstance(getApplicationContext()).setGoogleAdvertisingId(idInfo.id, idInfo.isLimitAdTrackingEnabled)
} catch (e: Exception) {
e.printStackTrace()
}
}).start()