Skip to content

Commit 12f0cc4

Browse files
authored
Merge pull request #868 from Iterable/evan/MOB-10624-add-anonymous-user-id-to-keychain
[MOB-10624] add anonymous user id to keychain
2 parents 6ac0049 + cc5eae9 commit 12f0cc4

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableConfig.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,12 @@ public class IterableConfig {
102102
final boolean enableEmbeddedMessaging;
103103

104104
/**
105-
106-
/**
107105
* This controls whether the SDK should allow event replay from local storage to logged in profile
108106
* and merging between the generated anonymous profile and the logged in profile by default.
109107
*/
110108
final IterableIdentityResolution identityResolution;
111109

112-
/**
110+
/**
113111
* Handler for decryption failures of PII information.
114112
* Before calling this handler, the SDK will clear the PII information and create new encryption keys
115113
*/
@@ -154,15 +152,13 @@ public static class Builder {
154152
private String[] allowedProtocols = new String[0];
155153
private IterableDataRegion dataRegion = IterableDataRegion.US;
156154
private boolean useInMemoryStorageForInApps = false;
157-
private IterableDecryptionFailureHandler decryptionFailureHandler;
158-
155+
private IterableDecryptionFailureHandler decryptionFailureHandler;
159156
private boolean encryptionEnforced = false;
160157
private boolean enableAnonActivation = false;
161158
private boolean enableEmbeddedMessaging = false;
162159
private int eventThresholdLimit = 100;
163160
private IterableIdentityResolution identityResolution = new IterableIdentityResolution();
164161
private IterableAnonUserHandler iterableAnonUserHandler;
165-
private IterableDecryptionFailureHandler decryptionFailureHandler;
166162

167163
@NonNull
168164
public Builder setIterableAnonUserHandler(@NonNull IterableAnonUserHandler iterableAnonUserHandler) {
@@ -346,8 +342,6 @@ public Builder setEnableEmbeddedMessaging(boolean enableEmbeddedMessaging) {
346342
}
347343

348344
/**
349-
350-
/**
351345
* Set whether the SDK should replay events from local storage to the logged in profile
352346
* and set whether the SDK should merge the generated anonymous profile and the logged in profile.
353347
* This can be overwritten by a parameter passed into setEmail or setUserId.
@@ -357,8 +351,10 @@ public Builder setEnableEmbeddedMessaging(boolean enableEmbeddedMessaging) {
357351

358352
public Builder setIdentityResolution(IterableIdentityResolution identityResolution) {
359353
this.identityResolution = identityResolution;
354+
return this;
355+
}
360356

361-
/**
357+
/**
362358
* Set a handler for decryption failures that can be used to handle data recovery
363359
* @param handler Decryption failure handler provided by the app
364360
*/

iterableapi/src/main/java/com/iterable/iterableapi/IterableKeychain.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class IterableKeychain {
88
private const val TAG = "IterableKeychain"
99
const val KEY_EMAIL = "iterable-email"
1010
const val KEY_USER_ID = "iterable-user-id"
11+
const val KEY_ANON_USER_ID = "iterable-anon-user-id"
1112
const val KEY_AUTH_TOKEN = "iterable-auth-token"
1213
}
1314

@@ -39,7 +40,7 @@ class IterableKeychain {
3940
}
4041
}
4142
dataMigrator.attemptMigration()
42-
IterableLogger.v(TAG, "Migration completed")
43+
IterableLogger.v(TAG, "Migration completed")
4344
}
4445
} catch (e: Exception) {
4546
IterableLogger.w(TAG, "Migration failed, clearing data", e)
@@ -52,6 +53,7 @@ class IterableKeychain {
5253
sharedPrefs.edit()
5354
.remove(KEY_EMAIL)
5455
.remove(KEY_USER_ID)
56+
.remove(KEY_ANON_USER_ID)
5557
.remove(KEY_AUTH_TOKEN)
5658
.apply()
5759

@@ -96,4 +98,7 @@ class IterableKeychain {
9698

9799
fun getAuthToken() = secureGet(KEY_AUTH_TOKEN)
98100
fun saveAuthToken(authToken: String?) = secureSave(KEY_AUTH_TOKEN, authToken)
101+
102+
fun getUserIdAnon() = secureGet(KEY_ANON_USER_ID)
103+
fun saveUserIdAnon(userIdAnon: String?) = secureSave(KEY_ANON_USER_ID, userIdAnon)
99104
}

0 commit comments

Comments
 (0)