Skip to content

Commit c86def8

Browse files
committed
Fix onSuccess callbacks for setting email, SMS
- Don't call the `onSuccess` callbacks for `setEmail` and `setSMSNumber` within the push synchronizer. - Previously, this callback may be triggered before the email or sms player is actually created or saved to the SDK through calls to `saveChannelId` (ie `saveEmailId` or `saveSMSId`) - The UserStateEmailSynchronizer or UserStateSMSSynchronizer will call these `onSuccess` callbacks later. - For the unhappy path for the failure callbacks, leave that as it is.
1 parent ac8c2a7 commit c86def8

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,7 @@ protected void fireEventsForUpdateFailure(JSONObject jsonFields) {
229229

230230
@Override
231231
protected void onSuccessfulSync(JSONObject jsonFields) {
232-
if (jsonFields.has(EMAIL_KEY))
233-
OneSignal.fireEmailUpdateSuccess();
234-
235-
if (jsonFields.has(SMS_NUMBER_KEY)) {
236-
JSONObject result = new JSONObject();
237-
try {
238-
result.put(SMS_NUMBER_KEY, jsonFields.get(SMS_NUMBER_KEY));
239-
if (jsonFields.has(SMS_AUTH_HASH_KEY))
240-
result.put(SMS_AUTH_HASH_KEY, jsonFields.get(SMS_AUTH_HASH_KEY));
241-
} catch (JSONException e) {
242-
e.printStackTrace();
243-
}
244-
OneSignal.fireSMSUpdateSuccess(result);
245-
}
232+
// Previously, the onSuccess callbacks for setEmail and setSMSNumber were triggered here if applicable.
233+
// However, this is too early, and the UserStateSecondaryChannelSynchronizer will fire the successful callback.
246234
}
247235
}

0 commit comments

Comments
 (0)