Skip to content

Commit 20e9bb9

Browse files
committed
Change handling of Identify User 409 conflict
* On Identify User 409 conflict response, no longer fetch user by External ID nor transfer subscription. * Instead, make a call to CreateUser with the push subscription in the payload. * If the user has changed since then, make a CreateUser call with just the Identity Model to hydrate the OneSignal ID for any pending updates that need to be sent for the past user. * Nit: remove an extraneous error log. The SDK already logs that it handles the 409 response. And the Client will already log this error as well.
1 parent 454909d commit 20e9bb9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,22 +343,20 @@ extension OSUserExecutor {
343343
executePendingRequests()
344344
}
345345
} onFailure: { error in
346-
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "executeIdentifyUserRequest failed with error \(error.debugDescription)")
347346
if let nsError = error as? NSError {
348347
let responseType = OSNetworkingUtils.getResponseStatusType(nsError.code)
349348
if responseType == .conflict {
350349
// Returns 409 if any provided (label, id) pair exists on another User, so the SDK will switch to this user.
351350
OneSignalLog.onesignalLog(.LL_DEBUG, message: "executeIdentifyUserRequest returned error code user-2. Now handling user-2 error response... switch to this user.")
352351

353352
removeFromQueue(request)
354-
// Transfer the push subscription, and fetch only if it's the current user
353+
355354
if OneSignalUserManagerImpl.sharedInstance.isCurrentUser(request.identityModelToUpdate) {
356-
fetchUser(aliasLabel: OS_EXTERNAL_ID, aliasId: request.aliasId, identityModel: request.identityModelToUpdate)
357-
transferPushSubscriptionTo(aliasLabel: request.aliasLabel, aliasId: request.aliasId)
355+
// Generate a Create User request, if it's still the current user
356+
createUser(OneSignalUserManagerImpl.sharedInstance.user)
358357
} else {
359-
// Use external_id for any pending requests, avoiding a fetch to hydrate onesignal_id
360-
request.identityModelToUpdate.primaryAliasLabel = .external_id
361-
executePendingRequests()
358+
// This will hydrate the OneSignal ID for any pending requests
359+
createUser(identityModel: request.identityModelToUpdate)
362360
}
363361
} else if responseType == .invalid || responseType == .unauthorized {
364362
// Failed, no retry

0 commit comments

Comments
 (0)