A newer version of this documentation is available.

View Latest

Authentication

Usage

You have to use ReachFive SDK through the com.reach5.android.reachFive class.

Initialization

ReachFive reachFive = ReachFive.newClient()
    .withContext(context)
    .withDomain(domain)
    .withCallback(initCallback) // not mandatory
    .init();

with:

  • context: Screen context

  • domain: ReachFive Domain

  • initCallback: Callback method. As init is an async method, it may be a good practice to use a callback method to catch errors or continue process at the end of init. Callback method has to be a R5InitCallback instance.

The ReachFive SDK must be initialized within the onCreate method on your current activity.

ReachFive class

Logging in through a provider requires an initialized instance of the ReachFive class.

Field Type Description Description

mReachFive

ReachFive

-

Initialized instance of the ReachFive class

provider

String

Yes

Provider code

activity

Activity

Yes

Current Activity (this)

origin

String

No

Call Origin

loginCallback

R5LoginCallback

No

Callback that will handle the response of the call

Facebook Call Example

mReachFive.newLoginRequest()
          .withOrigin(origin)
          .withCallback(loginCallback)
          .withProvider(R5NativeProviderEnum.FACEBOOK)
          .withActivity(activity)
          .execute();

Google Call Example

mReachFive.newLoginRequest()
          .withOrigin(origin)
          .withCallback(loginCallback)
          .withProvider(R5NativeProviderEnum.GOOGLE)
          .withActivity(activity)
          .execute();

Login/Password authentication Example

mReachFive.newPasswordLoginRequest(mUserName,mPassword)
          .withCallback(new R5LoginCallback() {
            @Override
            public void success(@NonNull R5LoginResponse response) {}

            @Override
            public void failure(@NonNull R5Exception error) {}
          })
          .execute();

Login/Password Signup Example

mReachFive.newSignupRequest(mUserName, mPassword)
          .withCallback(new R5SignUpCallback() {
            @Override
            public void success(@NonNull R5SignUpResponse signUpResponse, R5LoginResponse loginResponse) {}

            @Override
            public void failure(@NonNull R5Exception error) {}
          })
          .execute();

Response

R5LoginResponse

Field Type Nullable Description

accessToken

String

Yes

ReachFive access token

userInfo

userInfo

No

Object with provider data

R5Exception

Field Type Nullable Description

code

String

No

Error code

message

String

No

Error message

Life cycle

To notify ReachFive SDK at some steps of your activity, you must override the following methods:

  • onActivityResult

  • onRequestPermissionsResult

  • onStop

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mReachFive.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
    mReachFive.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
protected void onStop() {
    super.onStop();
    mReachFive.onStop();
}

Exception codes:

  • PROVIDER_UNAVAILABLE: The provider is not supported by the platform.

  • LOGIN_ERROR: Error during the login process returned by the provider.

  • LOGIN_CANCELLED: This is not an error, but rather information returned when the user decides not to continue the login process.

  • PROVIDER_TOKEN_MISSING: The provider did not return the access token, this may be due to an error on the provider side.

  • SDK_CONFIGURATION_ERROR: Wrong configuration on the application side or ReachFive backend.

  • API_ERROR: Error when calling the API. See message for more information.

  • API_TECHNICAL_ERROR: Fail to call ReachFive API.