Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions android/src/main/java/com/stallion/storage/StallionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.provider.Settings;

import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -53,22 +52,15 @@ public StallionConfig(Context context, SharedPreferences sharedPreferences) {
);
this.publicSigningKey = stallionPublicKeyRes != 0 ? context.getString(stallionPublicKeyRes) : "";

// get or generate UID
// get or generate UID (random install-scoped UUID)
String cachedUniqueId = sharedPreferences.getString(
StallionConfigConstants.UNIQUE_ID_IDENTIFIER,
""
);
if(!cachedUniqueId.isEmpty()) {
this.uid = cachedUniqueId;
} else {
try {
this.uid = Settings.Secure.getString(
context.getContentResolver(),
Settings.Secure.ANDROID_ID
);
} catch (Exception ignored) {
this.uid = UUID.randomUUID().toString();
}
this.uid = UUID.randomUUID().toString();
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(StallionConfigConstants.UNIQUE_ID_IDENTIFIER, this.uid);
editor.apply();
Expand Down
8 changes: 2 additions & 6 deletions ios/main/StallionConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ - (instancetype)initWithDefaults:(NSUserDefaults *)defaults {
_lastUnverifiedHash = [defaults stringForKey:LAST_UNVERIFIED_KEY_IDENTIFIER] ?: @"";
_baseUrl = [defaults stringForKey:BASE_URL_IDENTIFIER] ?: @"";

// get or generate UID (random install-scoped UUID)
NSString *cachedUid = [defaults stringForKey:UNIQUE_ID_IDENTIFIER];
if (cachedUid && ![cachedUid isEqualToString:@""]) {
_uid = cachedUid;
} else {
NSString *newUid = @"";
if ([UIDevice currentDevice].identifierForVendor) {
newUid = [UIDevice currentDevice].identifierForVendor.UUIDString;
} else {
newUid = [[NSUUID UUID] UUIDString];
}
NSString *newUid = [[NSUUID UUID] UUIDString];
[defaults setObject:newUid forKey:UNIQUE_ID_IDENTIFIER];
[defaults synchronize];
_uid = newUid;
Expand Down