Skip to content

Commit a5b5dc1

Browse files
committed
syncHashedEmail deprecation and lower case auth
* Deprecated syncHashedEmail in favor of setEmail * Added force lower case of auth hash which is expected by the OneSignal server
1 parent e701ba4 commit a5b5dc1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,10 +1156,9 @@ private static void registerUserTask() throws JSONException {
11561156
}
11571157

11581158
/**
1159-
* Sync hashed email if you have a login system or collect it from the user. It will be used to
1160-
* reach the user at the most optimal time of the day.
1161-
* @param email the email that you want to sync with the user
1159+
* @deprecated Please migrate to setEmail. This will be removed in next major release
11621160
*/
1161+
@Deprecated
11631162
public static void syncHashedEmail(final String email) {
11641163
if (!OSUtils.isValidEmail(email))
11651164
return;
@@ -1202,7 +1201,7 @@ public static void setEmail(@NonNull final String email, @Nullable final String
12021201
* the user logs into your app.
12031202
* DO NOT generate this from your app!
12041203
* Omit this value if you do not have a backend to authenticate the user.
1205-
* @param callback Fire onSucces or onFailure if the update fails or successes.
1204+
* @param callback Fire onSuccess or onFailure depending if the update successes or fails
12061205
*/
12071206
public static void setEmail(@NonNull final String email, @Nullable final String emailAuthHash, @Nullable EmailUpdateHandler callback) {
12081207
if (!OSUtils.isValidEmail(email)) {
@@ -1227,8 +1226,13 @@ public static void setEmail(@NonNull final String email, @Nullable final String
12271226
@Override
12281227
public void run() {
12291228
String trimmedEmail = email.trim();
1229+
1230+
String internalEmailAuthHash = emailAuthHash;
1231+
if (internalEmailAuthHash != null)
1232+
internalEmailAuthHash.toLowerCase();
1233+
12301234
getCurrentEmailSubscriptionState(appContext).setEmailAddress(trimmedEmail);
1231-
OneSignalStateSynchronizer.setEmail(trimmedEmail.toLowerCase(), emailAuthHash);
1235+
OneSignalStateSynchronizer.setEmail(trimmedEmail.toLowerCase(), internalEmailAuthHash);
12321236
}
12331237
};
12341238

0 commit comments

Comments
 (0)