Getting Started

Requirements

The ReachFive SDK supports Android SDK from API Level 19 (Android version 4.4 KitKat).

To initialize the ReachFive client:

  • You need a Domain URL and Client ID.

  • You must whitelist all available domains where the ReachFive SDK will be used.

    This is done in the Allowed Origins (CORS) field of your ReachFive console, in the Settings menu.
Upgrading to version 8.x

If you are upgrading to version 8.x, be aware that several major changes have occurred.

We highly recommend reading the Migration guide for further details.

Installation

ReachFive SDKs are published to Maven Central as separate modules.

allprojects {
    repositories {
        mavenCentral() (1)
    }
}
1 Add mavenCentral as a repository location in your project’s top-level build.gradle file.
Below are installation instructions for each module.

SDK Core

Core contains all the main tools and interfaces, and the methods related to authentication.

Add the following line to your app/build.gradle, replacing x.y.z with the latest SDK version:

dependencies {
    implementation "co.reachfive.identity:sdk-core:x.y.z"
}

The following permissions are required to communicate with the ReachFive servers. Add them to the AndroidManifest.xml file.

<manifest>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
</manifest>

Proguard rule exception

If you have set minifyEnabled true in your Android build, you need to add the following Proguard rule in order to make an exception for certain ReachFive SDK models.

Add the following rule to your proguard-rules.pro file to prevent ReachFive API models from being obfuscated:

-keep class co.reachfive.identity.sdk.core.models.** {*;}

Web-based Flows

If you intend on using non-native social login providers (SDK WebView) or our orchestrated web login flow (Core), then you must properly configure your application accordingly.

Check out the Web-Based Flows guide for more details.

SDK WebView

This module uses a Custom Tab to authenticate users through a social login provider configured in your account; it enables all providers that are supported by ReachFive.

providers config

Add the following line to your app/build.gradle, replacing x.y.z with the latest version:

dependencies {
  implementation "co.reachfive.identity:sdk-webview:x.y.z"
}

Facebook Native Provider

This module uses the Facebook native SDK to provide a better user experience.

Refer to the Facebook Connect guide to create your Facebook application.
  1. Add the following lines to your app/build.gradle, replacing x.y.z with the latest version:

    dependencies {
        implementation "co.reachfive.identity:sdk-facebook:x.y.z"
    }
  2. Add the line below into your string.xml resource file with your Facebook application ID:

    <resources>
        <string name="facebook_app_id">FACEBOOK_APPLICATION_ID</string>
    </resources>
  3. Then add these lines into the AndroidManifest.xml file:

    <manifest>
        <meta-data
          android:name="com.facebook.sdk.ApplicationId"
          android:value="@string/facebook_app_id" />
        <activity
          android:name="com.facebook.FacebookActivity"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="@string/app_name" />
    </manifest>

Configure Google native provider

This module uses the Google native SDK to provide a better user experience.

  1. First, include Google’s Maven repository in your top-level build.gradle file:

    allprojects {
        repositories {
            google()
        }
    }

To enable the service, add the line below at the bottom of your app/build.gradle file so that no dependency collisions are introduced:

apply plugin: 'com.google.gms.google-services'
  1. Add the following line to your app/build.gradle, replacing x.y.z with the latest version:

    dependencies {
        implementation "co.reachfive.identity:sdk-google:x.y.z"
    }
  2. Use the Google Connect guide to create your Google application.

  3. Create a new Firebase project.

  4. Once the project is created, configure the release (keystore.jks) and production (Google Play) SHA1s in FireBase with the application’s package name as shown with the command below:

    keytool -list -v -keystore [keystorePath] - alias [aliasName] -storepass [storePassword] -keypass [keyPassword]
More information about the keytool utility in the Authenticating Your Client guide.
The ANDROID AUTH2 CLIENTS are generated automatically in the Google Console API through Firebase.
  1. Download the google-services.json file and put it at the root of your Android project. You can find more information in Add Firebase to your Android project and Adding the JSON File.

sha1 firebase


android client google

Client Initialization

In all the code example below, the ReachFive client is instantiated and stored in a variable named client.

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import co.reachfive.identity.sdk.core.ReachFive
import co.reachfive.identity.sdk.core.SdkConfig
import co.reachfive.identity.sdk.core.models.AuthToken
import co.reachfive.identity.sdk.core.models.ProfileSignupRequest
import co.reachfive.identity.sdk.facebook.FacebookProvider
import co.reachfive.identity.sdk.google.GoogleProvider
import co.reachfive.identity.sdk.webview.WebViewProvider
import io.github.cdimascio.dotenv.dotenv
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    private const val TAG = "YourApp"

    // The ReachFive client
    private lateinit var client: ReachFive

    val DOMAIN    = "Your ReachFive domain"
    val CLIENT_ID = "Your ReachFive client ID"
    val SCHEME    = "Your ReachFive scheme"

    override fun onCreate(savedInstanceState: Bundle?) {

        // The configuration parameters needed by the ReachFive client
        val sdkConfig = SdkConfig(domain = DOMAIN, clientId = CLIENT_ID, scheme = SCHEME)

        // The list of the social providers needed by your application
        val providersCreators = listOf(GoogleProvider(), FacebookProvider(), WebViewProvider())

        client = ReachFive(
            sdkConfig = sdkConfig,
            providersCreators = providersCreators,
        )

        // Initialize the ReachFive client
        client.initialize({ providers ->
            // On success, do something with the retrieved list of providers registered for this ReachFive client
            // ...
        }, {
            // On failure, log the error message returned by the ReachFive client
            Log.d(TAG, "ReachFive init ${it.message}")
        })

        // Load the social providers
        client.loadSocialProviders(
            applicationContext,
            success = **{ **providers **-> **providerAdapter.refresh(providers) **}**,
            failure = **{ **Log.d(TAG, "Loading providers failed ${**it**.message}") **}**
        )
    }
}