Package 

Class BrainCloudWrapperAndroid

  • All Implemented Interfaces:
    com.bitheads.braincloud.client.IBrainCloudWrapper , com.bitheads.braincloud.client.IServerCallback

    
    public class BrainCloudWrapperAndroid
     implements IServerCallback, IBrainCloudWrapper
                        

    The BrainCloudWrapper provides some convenience functionality to developers when they are getting started with the authentication system.

    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.

    • Constructor Detail

      • BrainCloudWrapperAndroid

        BrainCloudWrapperAndroid()
      • BrainCloudWrapperAndroid

        BrainCloudWrapperAndroid(String wrapperName)
        Instantiate a copy of the brainCloud wrapper.
        Parameters:
        wrapperName - value used to differentiate saved wrapper data
    • Method Detail

      • getClient

         BrainCloudClient getClient()

        Returns a singleton instance of the BrainCloudClient, if this is the BrainCloudWrapper Singleton.Otherwise, return an instance of the BrainCloudClient, if this is an instance of the BrainCloudWrapper.

      • getBC

         static BrainCloudClient getBC()

        Returns a singleton instance of the BrainCloudClient.

      • setContext

         void setContext(Context ctx)

        Sets the context required for saving anonymous and profile ids to theprivate SharedPreferences file.

        Parameters:
        ctx - The application context
      • initialize

         void initialize(Context ctx, String appId, String secretKey, String appVersion)

        Method initializes the BrainCloudClient.

        Parameters:
        ctx - The application context
        appId - The app id
        secretKey - The secret key for your app
        appVersion - The app version
      • initialize

         void initialize(Context ctx, String appId, String secretKey, String appVersion, String serverUrl)

        Method initializes the BrainCloudClient.

        Parameters:
        ctx - The application context
        appId - The app id
        secretKey - The secret key for your app
        appVersion - The app version
        serverUrl - The url to the brainCloud server
      • initialize

         void initialize(String appId, String secretKey, String appVersion, String serverUrl)

        Method initializes the BrainCloudClient. Make sure toset the context via setContext() if you're using this method.

        Parameters:
        appId - The app id
        secretKey - The secret key for your app
        appVersion - The app version
        serverUrl - The url to the brainCloud server
      • initialize

         void initialize(String appId, String secretKey, String appVersion)

        Method initializes the BrainCloudClient. Make sure toset the context via setContext() if you're using this method.

        Parameters:
        appId - The app id
        secretKey - The secret key for your app
        appVersion - The app version
      • initializeWithApps

         void initializeWithApps(String url, String defaultAppId, Map<String, String> secretMap, String version)

        Method initializes the BrainCloudClient. - Note this is here for toggling purposes to testdifferent initializations.

        Parameters:
        url - The URL to the brainCloud server
        defaultAppId - The default app ID
        secretMap - All app ids to secret keys used by this application
        version - The app version
      • setStoredProfileId

         void setStoredProfileId(String profileId)

        Sets the stored profile id

        Parameters:
        profileId - The profile id to set
      • setStoredAnonymousId

         void setStoredAnonymousId(String anonymousId)

        Sets the stored anonymous id

        Parameters:
        anonymousId - The anonymous id to set
      • setAlwaysAllowProfileSwitch

         void setAlwaysAllowProfileSwitch(boolean alwaysAllow)

        For non-anonymous authentication methods, a profile id will be passed inwhen this value is set to false. This will generate an error on the serverif the profile id passed in does not match the profile associated with theauthentication credentials. By default, this value is true.

        Parameters:
        alwaysAllow - Controls whether the profile id is passed in withnon-anonymous authentications.
      • authenticateAnonymous

         void authenticateAnonymous(IServerCallback callback)

        Authenticate a user anonymously with brainCloud - used for apps thatdon't want to bother the user to login, or for users who are sensitive totheir privacy

        Parameters:
        callback - The callback handler
      • authenticateHandoff

         void authenticateHandoff(String handoffId, String securityToken, IServerCallback callback)

        Authenticate the user using a handoffId and an authentication token.

        Parameters:
        handoffId - braincloud handoffId generated frim cloud script
        securityToken - The authentication token
        callback - The callback handler
      • authenticateSettopHandoff

         void authenticateSettopHandoff(String handoffCode, IServerCallback callback)

        Authenticate the user using a handoffId and an authentication token.

        Parameters:
        handoffCode - generate in cloud code
        callback - The callback handler
      • authenticateEmailPassword

         void authenticateEmailPassword(String email, String password, boolean forceCreate, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        email - The e-mail address of the user
        password - The password of the user
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateExternal

         void authenticateExternal(String userId, String token, String externalAuthName, boolean forceCreate, IServerCallback callback)

        Authenticate the user via cloud code (which in turn validates the supplied credentials against an external system).This allows the developer to extend brainCloud authentication to support other backend authentication systems.

        Service Name - AuthenticateServer Operation - Authenticate

        Parameters:
        userId - The user id
        token - The user token (password etc)
        externalAuthName - The name of the cloud script to call for external authentication
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
      • authenticateFacebook

         void authenticateFacebook(String fbUserId, String fbAuthToken, boolean forceCreate, IServerCallback callback)

        Authenticate the user with brainCloud using their Facebook Credentials

        Parameters:
        fbUserId - The facebook id of the user
        fbAuthToken - The validated token from the Facebook SDK (that will befurther validated when sent to the bC service)
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateFacebookLimited

         void authenticateFacebookLimited(String fbLimitedUserId, String fbAuthToken, boolean forceCreate, IServerCallback callback)

        Authenticate the user with brainCloud using their FacebookLimited Credentials

        Parameters:
        fbLimitedUserId - The facebookLimited id of the user
        fbAuthToken - The validated token from the Facebook SDK (that will befurther validated when sent to the bC service)
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateOculus

         void authenticateOculus(String oculusUserId, String oculusNonce, boolean forceCreate, IServerCallback callback)

        Authenticate the user with brainCloud using their Oculus Credentials

        Parameters:
        oculusUserId - The oculus id of the user
        oculusNonce - from the Oculus SDK (that will befurther validated when sent to the bC service)
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateApple

         void authenticateApple(String appleUserId, String identityToken, boolean forceCreate, IServerCallback callback)

        Authenticate the user using an apple id

        Parameters:
        appleUserId - This can be the user id OR the email of the user for the account
        identityToken - The token confirming the user's identity
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateGoogle

         void authenticateGoogle(String googleUserId, String serverAuthCode, boolean forceCreate, IServerCallback callback)

        Authenticate the user using a google userid(email address) and googleauthentication token.

        Parameters:
        googleUserId - String representation of google+ userId.
        serverAuthCode - The server authentication token derived via the google apis.
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateGoogleOpenId

         void authenticateGoogleOpenId(String googleUserAccountEmail, String IdToken, boolean forceCreate, IServerCallback callback)

        Authenticate the user using a google openId

        Parameters:
        googleUserAccountEmail - The email associated with the google user
        IdToken - The id token of the google account.
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateSteam

         void authenticateSteam(String steamUserId, String steamSessionTicket, boolean forceCreate, IServerCallback callback)

        Authenticate the user using a steam userid and session ticket (withoutany validation on the userid).

        Parameters:
        steamUserId - String representation of 64 bit steam id
        steamSessionTicket - The session ticket of the user (hex encoded)
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateUltra

         void authenticateUltra(String ultraUsername, String ultraIdToken, boolean forceCreate, IServerCallback callback)

        Authenticate the user for Ultra.

        Parameters:
        ultraUsername - it's what the user uses to log into the Ultra endpoint initially
        ultraIdToken - The "id_token" taken from Ultra's JWT.
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateTwitter

         void authenticateTwitter(String userId, String token, String secret, boolean forceCreate, IServerCallback callback)

        Authenticate the user using a Twitter userid, authentication token, and secret from Twitter.

        Service Name - AuthenticateService Operation - Authenticate

        Parameters:
        userId - String representation of Twitter userid
        token - The authentication token derived via the Twitter apis.
        secret - The secret given when attempting to link with Twitter
        forceCreate - Should a new profile be created for this user if the account does not exist?
        callback - The callback handler
      • authenticateUniversal

         void authenticateUniversal(String userId, String userPassword, boolean forceCreate, IServerCallback callback)

        Authenticate the user using a userid and password (without any validationon the userid). Similar to AuthenticateEmailPassword - except that thatmethod has additional features to allow for e-mail validation, passwordresets, etc.

        Parameters:
        userId - The e-mail address of the user
        userPassword - The password of the user
        forceCreate - Should a new profile be created for this user if the accountdoes not exist?
        callback - The callback handler
      • authenticateAdvanced

         void authenticateAdvanced(AuthenticationType authenticationType, AuthenticationIds ids, boolean forceCreate, String extraJson, IServerCallback callback)
      • smartSwitchAuthenticateAdvanced

         void smartSwitchAuthenticateAdvanced(AuthenticationType authenticationType, AuthenticationIds ids, boolean forceCreate, String extraJson, IServerCallback callback)
      • reconnect

         void reconnect(IServerCallback callback)

        Re-authenticates the user with brainCloud

        Parameters:
        callback - The callback handler
      • resetEmailPassword

         void resetEmailPassword(String email, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        email - The e-mail address of the user
        callback - The callback handler
      • resetEmailPasswordAdvanced

         void resetEmailPasswordAdvanced(String email, String serviceParams, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        email - The e-mail address of the user
        serviceParams - Parameters to send to the email service.
        callback - The callback handler
      • resetEmailPasswordWithExpiry

         void resetEmailPasswordWithExpiry(String email, int tokenTtlInMinutes, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        email - The e-mail address of the user
        tokenTtlInMinutes - Token expiry time
        callback - The callback handler
      • resetEmailPasswordAdvancedWithExpiry

         void resetEmailPasswordAdvancedWithExpiry(String email, String serviceParams, Integer tokenTtlInMinutes, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        email - The e-mail address of the user
        serviceParams - Parameters to send to the email service.
        tokenTtlInMinutes - Token expiry time
        callback - The callback handler
      • resetUniversalIdPassword

         void resetUniversalIdPassword(String universalId, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        universalId - The e-mail address of the user
        callback - The callback handler
      • resetUniversalIdPasswordAdvanced

         void resetUniversalIdPasswordAdvanced(String universalId, String serviceParams, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        universalId - The e-mail address of the user
        serviceParams - Parameters to send to the email service.
        callback - The callback handler
      • resetUniversalIdPasswordWithExpiry

         void resetUniversalIdPasswordWithExpiry(String universalId, int tokenTtlInMinutes, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        universalId - The e-mail address of the user
        tokenTtlInMinutes - Token expiry time
        callback - The callback handler
      • resetUniversalIdPasswordAdvancedWithExpiry

         void resetUniversalIdPasswordAdvancedWithExpiry(String universalId, String serviceParams, Integer tokenTtlInMinutes, IServerCallback callback)

        Authenticate the user with a custom Email and Password. Note that theclient app is responsible for collecting (and storing) the e-mail andpotentially password (for convenience) in the client data. For thegreatest security, force the user to re-enter their * password at eachlogin. (Or at least give them that option).

        Note that the password sent from the client to the server is protectedvia SSL.

        Parameters:
        universalId - The e-mail address of the user
        serviceParams - parameters to send to the email service.
        tokenTtlInMinutes - Token expiry time
        callback - The callback handler
      • runCallbacks

         void runCallbacks()

        Run callbacks, to be called once per frame from your main thread

      • enableCompression

         void enableCompression()

        Enable compression in comms transactions

      • serverCallback

         void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)

        The serverCallback() method returns server data back to the layerinterfacing with the BrainCloud library.

        Parameters:
        serviceName - - name of the requested service
        serviceOperation - - requested operation
        jsonData - - returned data from the server
      • serverError

         void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)

        Errors are returned back to the layer which is interfacing with theBrainCloud library through the serverError() callback.

        A server error might indicate a failure of the client to communicatewith the server after N retries.

        Parameters:
        serviceName - - name of the requested service
        serviceOperation - - requested operation
        statusCode - The error status return code (400, 403, 500, etc)
        reasonCode - The brainCloud reason code (see reason codes on apidocs site)
        jsonError - The error json string