DetachUniversalIdentity
Detach the universal identity from the current profile
Error Handling Example
public void FailureCallback(int statusCode, int reasonCode, string statusMessage, object cbObject) {
switch (reasonCode) {
case ReasonCodes.DOWNGRADING_TO_ANONYMOUS_ERROR: { // User is detaching their last idenitity
// To proceed, contiuneAsAnonymous must be set to true
_bc.IdentityService.DetachUniversalIdentity(userId, true);
break;
}
case ReasonCodes.MISSING_IDENTITY_ERROR: { // User attempted to detach an identity that doesn't exist
/**
* Need to provide the correct information of an attached identity
*/
break;
}
case ReasonCodes.MISSING_IDENTITY_ERROR: { // User attempted to detach an identity that doesn't belong to them
/**
* Need to provide the correct identity
*/
break;
}
default: { // Uncaught reasonCode
/**
* Log the unexpected reasonCode to your own internal logs,
* to implement needed error handling later
*/
break;
}
}
}
Service | Operation |
---|---|
identity | DETACH |
Method Parameters
Parameter | Description |
---|---|
userId | The player's user ID |
continueAnon | Proceed even if the profile will revert to anonymous? |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string userId = "someId";
_bc.IdentityService.DetachUniversalIdentity(
userId,
true,
SuccessCallback, FailureCallback);
const char * userId = "someId";
_bc->getIdentityService()->detachUniversalIdentity(
userId, false, this);
- (void)detachUniversalIdentity:(NSString *)userId
continueAnon:(bool)continueAnon
completionBlock:(BCCompletionBlock)cb
errorCompletionBlock:(BCErrorCompletionBlock)ecb
cbObject:(BCCallbackObject)cbObject;
public void detachUniversalIdentity(String userId, boolean continueAnon, IServerCallback callback)
_bc.identity.detachUniversalIdentity = function(userId, continueAnon, callback)
var userId = "someId";
var continueAnon = true;
ServerResponse result = await _bc.identityService.detachUniversalIdentity(userId:userId, continueAnon:continueAnon);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
// N/A
// N/A
JSON Response
{
"status": 200,
"data": null
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40210 | DOWNGRADING_TO_ANONYMOUS_ERROR | Occurs when detaching the last non-anonymous identity from an account with continueAnon set to false. |
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. |
40209 | SECURITY_ERROR | Returned if a security exception was encountered. |