Skip to content

Commit 01327be

Browse files
committed
Fetch User needed after Create User
* Motivation: Create User's response won't send us the user's complete info if this user already existed. * For now, do both, as we should parse to get the subscription_id from this request. * TODO: Differentiate if we need to Fetch based on response code to not make extraneous call.
1 parent 481bde9 commit 01327be

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,17 @@ class OSUserExecutor {
167167
return
168168
}
169169
OneSignalClient.shared().execute(request) { response in
170+
// TODO: Differentiate if we need to fetch based on response code 200, 201, 202
171+
// Create User's response won't send us the user's complete info if this user already existed.
172+
// We can parse the response OR fetch user (and then parse response then)
173+
// For now, do both, as we should parse to get the subscription_id from this request
170174
if let response = response {
171175
parseFetchUserResponse(response: response, identityModel: request.identityModel, originalPushToken: originalPushToken)
176+
// If we logged into an external_id, fetch the user data
177+
if let identity = request.parameters?["identity"] as? [String: String],
178+
let externalId = identity[OS_EXTERNAL_ID] {
179+
fetchUser(aliasLabel: OS_EXTERNAL_ID, aliasId: externalId, identityModel: request.identityModel)
180+
}
172181
}
173182
executePendingRequests()
174183
} onFailure: { error in

0 commit comments

Comments
 (0)