android: add a consistent device ID in Amplitude
Use ANDROID_ID: https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID
This commit is contained in:
parent
87821eb2c0
commit
659eb6b789
|
@ -16,6 +16,10 @@
|
||||||
|
|
||||||
package org.jitsi.meet.sdk;
|
package org.jitsi.meet.sdk;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||||
import com.facebook.react.bridge.ReactMethod;
|
import com.facebook.react.bridge.ReactMethod;
|
||||||
|
@ -49,8 +53,16 @@ class AmplitudeModule
|
||||||
* @param apiKey The API_KEY of the Amplitude project.
|
* @param apiKey The API_KEY of the Amplitude project.
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@SuppressLint("HardwareIds")
|
||||||
public void init(String instanceName, String apiKey) {
|
public void init(String instanceName, String apiKey) {
|
||||||
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
||||||
|
|
||||||
|
// Set the device ID to something consistent.
|
||||||
|
String android_id
|
||||||
|
= Settings.Secure.getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
if (!TextUtils.isEmpty(android_id)) {
|
||||||
|
Amplitude.getInstance(instanceName).setDeviceId(android_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue