BrainCloudWrapper
The BrainCloudWrapper class provides an easier way for developers to handle user authentication when they are getting started with the authentication system. This includes persisting authentication data between application runs.
By using the wrapper authentication methods, the anonymous and profile IDs will be automatically persisted upon successful authentication. When authenticating, any stored anonymous/profile IDs will be sent to the server. This strategy is useful when using Anonymous authentication.
Note - you should initialize the wrapper before using it. It will in turn initialize the brainCloud client for you - don't do both!
Method Parameters
Parameter | Description |
---|---|
wrapperName | Distincts saved wrapper data. Use when using more than one instance of brainCloud |
Usage
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
// Unity
//Note: Ensure of have selected your app using the brainCloud Unity Plugin
using UnityEngine;
public class BCConfig : MonoBehaviour {
private BrainCloudWrapper _bc;
public BrainCloudWrapper Get()
{
return _bc;
}
void Awake ()
{
DontDestroyOnLoad(gameObject);
_bc = gameObject.AddComponent<BrainCloudWrapper>();
_bc.WrapperName = gameObject.name; // Optional: Set a wrapper name
_bc.Init(); // Init data is taken from the brainCloud Unity Plugin
}
}
// C#
_bc = new BrainCloudWrapper("_mainWrapper");
_bc = new BrainCloudWrapper("_mainWrapper");
_bc = [[BrainCloudWrapper alloc] init: @"_mainWrapper"]
_bc = new BrainCloudWrapper("_mainWrapper");
_bc = new BrainCloudWrapper("_mainWrapper");
BrainCloudWrapper _bc = BrainCloudWrapper(wrapperName: "_mainWrapper");
📄️ AuthenticateAdvanced
A generic Authenticate method that translates to the same as calling a specific one, except it takes an extraJson that will be passed along to pre- or post- hooks.
📄️ AuthenticateAnonymous
Authenticate a user anonymously with - used for apps that don't want to bother the user to login, or for users who are sensitive to their privacy.
📄️ AuthenticateApple
Authenticates the user using Sign in with Apple.
📄️ AuthenticateEmailPassword
Authenticate the user with a custom Email and Password. Note that the client app is responsible for collecting (and storing) the e-mail and potentially password (for convenience) in the client data. For the greatest security, force the user to re-enter their password at each login (or at least give them that option).
📄️ AuthenticateExternal
Authenticate the user via cloud code (which in turn validates the supplied credentials against an external system).
📄️ AuthenticateFacebook
Authenticate the user with using their Facebook Credentials.
📄️ AuthenticateFacebookLimited
Authenticate the user with using their Facebook Credentials.
📄️ AuthenticateGameCenter
Authenticate the user using their Game Center ID.
📄️ AuthenticateGoogle
Authenticate the user using a google user ID (gXXX) and google authentication token.
📄️ AuthenticateGoogleOpenId
Authenticate the user using a google user ID (gXXX) and google authentication token.
📄️ AuthenticateNintendo
Authenticate the user on Nintendo Switch.
📄️ AuthenticateOculus
Authenticate the user with using their Oculus Credentials.
📄️ AuthenticatePlaystationNetwork
Authenticate the user with using their PlaystationNetwork Credentials.
📄️ AuthenticateSteam
Authenticate the user using a steam userId and session ticket (without any validation on the userId).
📄️ AuthenticateTwitter
Authenticate the user using a Twitter user ID, authentication token, and secret from Twitter.
📄️ AuthenticateUltra
Authenticate the user for Ultra.
📄️ AuthenticateUniversal
Universal authentication allows the developer to pass in any user/password string combination. As with all authentication methods, if the create new profile flag is specified as false, the authentication will fail if the user/password combination does not match a user in the database.
📄️ CanReconnect
Returns true if there is a stored profile id and anonymous id on the device.
📄️ EnableLongSession
Maintains the user's session alive by calling the reconnect method upon detecting the expiration of the user's session.
📄️ GetAlwaysAllowProfileSwitch
For non-anonymous authentication methods, a profile ID will be passed in when this value is set to false. This will generate an error on the server if the profile ID passed in does not match the profile associated with the authentication credentials.
📄️ GetStoredAnonymousId
Returns the stored anonymous ID
📄️ GetStoredProfileId
Returns the stored profile ID
📄️ Initialize
Method initializes both ` and `.
📄️ InitializeWithApps
Method initializes ` and ` with a map of appid->secretkey.
📄️ Logout
Logs user out of server. It's basically just a wrapper version for logout method of playerState service and ResetStoredProfileId method
📄️ LogoutOnApplicationQuit
Logs out user in one frame, meant to be used when OnApplicationQuit() occurs in Unity.
📄️ Reconnect
Re-authenticates the user with
📄️ ResetEmailPassword
Sends a password reset email to the specified address.
📄️ ResetEmailPasswordAdvanced
Advanced reset email password using templates
📄️ ResetStoredAnonymousId
Resets the anonymous ID to empty string. When the anonymousId is empty a new one will be generated automatically on authentication.
📄️ ResetStoredProfileId
Resets the profile ID to empty string.
📄️ RunCallbacks
Run callbacks, to be called once per frame from your main thread
📄️ RunScriptAndLogoutOnApplicationQuit
Execute a script on the server and Logout in one frame, meant to be used when application closes/exits
📄️ SetAlwaysAllowProfileSwitch
For non-anonymous authentication methods, a profile ID will be passed in when this value is set to false. This will generate an error on the server if the profile ID passed in does not match the profile associated with the authentication credentials.
📄️ SetStoredAnonymousId
Sets the stored anonymous ID
📄️ SetStoredProfileId
Sets the stored profile ID
📄️ SmartSwitchAuthenticateAdvanced
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateApple
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateEmailPassword
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateExternal
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateFacebook
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateFacebookLimited
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateGameCenter
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateGoogle
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateGoogleOpenId
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateNintendo
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateOculus
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticatePlaystation5
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticatePlaystationNetwork
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateSteam
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateTwitter
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateUltra
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
📄️ SmartSwitchAuthenticateUniversal
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.