MergeUniversalIdentity
Merge the profile associated with the provided user ID with the current profile.
NOTE: If using the BrainCloudWrapper, once the merge is complete you should call SetStoredProfileId
in the BrainCloudWrapper with the profileId returned in the Merge call.
Error Handling Example
public void FailureCallback(int statusCode, int reasonCode, string statusMessage, object cbObject) {
switch (reasonCode) {
case ReasonCodes.MISSING_IDENTITY_ERROR: { // User attempted to merge an identity that doesn't exist
/**
* Need to provide the correct information of the identity to merge
*/
break;
}
case ReasonCodes.DUPLICATE_IDENTITY_TYPE: { // Users cannot attach an identity of a type that exists on there account
/**
* Inform user to detach identities that are of the same type of the merging account,
* before the merge
*/
break;
}
default: { // Uncaught reasonCode
/**
* Log the unexpected reasonCode to your own internal logs,
* to implement needed error handling later
*/
break;
}
}
}
Service | Operation |
---|---|
identity | MERGE |
Method Parameters
Parameter | Description |
---|---|
userId | The player's user ID |
password | The player's password |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string userId = "someId";
string password = "someToken";
_bc.IdentityService.MergeUniversalIdentity(
userId,
password,
SuccessCallback, FailureCallback);
const char * userId = "someId";
const char * password = "someToken";
_bc->getIdentityService()->mergeUniversalIdentity(
userId, password, this);
- (void)mergeUniversaIdentity:(NSString *)userId
authenticationToken:(NSString *)password
completionBlock:(BCCompletionBlock)cb
errorCompletionBlock:(BCErrorCompletionBlock)ecb
cbObject:(BCCallbackObject)cbObject;
public void mergeUniversalIdentity(String userId, String password, IServerCallback callback)
_bc.identity.mergeUniversalIdentity = function(userId, password, callback)
var userId = "someId";
var password = "password";
ServerResponse result = await _bc.identityService.mergeUniversalIdentity(userId:userId, password:password);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
// N/A
// N/A
JSON Response
{
"data": {
"profileId": "f94f7e2d-3cdd-4fd6-9c28-392f7875e9df"
},
"status": 200
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40206 | MISSING_IDENTITY_ERROR | A "profileId" was supplied in the authentication request submitted with new credentials. In other words the credentials record was not found in the brainCloud database. The solution would be to provide known credentials or not supply a "profileId" if the user is actually new. |
40211 | DUPLICATE_IDENTITY_TYPE | Returned when trying to attach an identity type that already exists for that profile. For instance you can have only one Universal identity for a profile. |