Skip to content

Commit

Permalink
implement client unique id using uuid for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailSuendukov committed Oct 30, 2023
1 parent 777e202 commit 1c06bb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ public class CodePushConstants {
public static final String LATEST_ROLLBACK_PACKAGE_HASH_KEY = "packageHash";
public static final String LATEST_ROLLBACK_TIME_KEY = "time";
public static final String LATEST_ROLLBACK_COUNT_KEY = "count";
public static final String CLIENT_UNIQUE_ID_KEY = "clientUniqueId";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.microsoft.codepush.react;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
Expand Down Expand Up @@ -34,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class CodePushNativeModule extends ReactContextBaseJavaModule {
private String mBinaryContentsHash = null;
Expand All @@ -60,7 +62,13 @@ public CodePushNativeModule(ReactApplicationContext reactContext, CodePush codeP

// Initialize module state while we have a reference to the current context.
mBinaryContentsHash = CodePushUpdateUtils.getHashForBinaryContents(reactContext, mCodePush.isDebugMode());
mClientUniqueId = Settings.Secure.getString(reactContext.getContentResolver(), Settings.Secure.ANDROID_ID);

SharedPreferences preferences = codePush.getContext().getSharedPreferences(CodePushConstants.CODE_PUSH_PREFERENCES, 0);
mClientUniqueId = preferences.getString(CodePushConstants.CLIENT_UNIQUE_ID_KEY, null);
if (mClientUniqueId == null) {
mClientUniqueId = UUID.randomUUID().toString();
preferences.edit().putString(CodePushConstants.CLIENT_UNIQUE_ID_KEY, mClientUniqueId).apply();
}
}

@Override
Expand Down

0 comments on commit 1c06bb3

Please sign in to comment.