Getting Started

Requirements

The minimal iOS version of an application using the ReachFive iOS SDKs has to be 10.0.

To initialize the ReachFive client, you need a Domain URL and a Client ID.

For more information, refer to Domain and client configuration.

For security reasons, you have to whitelist all available domains where the ReachFive SDK will be used.

This has to be done in the Allowed Origins (CORS) field of your ReachFive console, in the Settings menu.

The ReachFive client detects the user locale from the browser, and you can override the local at initialization by providing a language. Supported languages are: en, es, fr, it, nl, de.

Installation

ReachFive SDKs are published on Cocoapods as independent modules.

For further reference on Cocoapods, check their official documentation.

You’ll find below for each module a description and instructions for installation.

SDK Core

It contains all the main tools and interfaces, and methods related to standard authentication by identifier and password.

It contains all common tools and interfaces and enables users to authenticate with their passwords.

Add these lines to your Podfile file, replacing x.y.z with the latest version:

pod 'IdentitySdkCore', '~> x.y.z'

Then run:

pod install

SDK Webview

This module uses a web page in Safari to authenticate users. It enables all providers that are configured in your ReachFive account.

providers config

Add these lines to your Podfile file, replacing x.y.z with the latest version:

pod 'IdentitySdkWebView', '~> x.y.z'

Then run:

pod install

For mobile contexts, you must whitelist reachfive-${clientId}://callback, using your Reachfive identity client ID.

This URL scheme is the default callback URL and is used to request a token when implementing the SDK Webview.

Configure your application’s Info.plist file with the following XML snippet:

<!-- Info.plist -->

<dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>reachfive-${clientId}</string>
    </array>
</dict>

Facebook native provider

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

Add these lines to your Podfile file, replacing x.y.z with the latest version:

pod 'IdentitySdkFacebook', '~> x.y.z'

Then run:

pod install

Refer to the Facebook Connect guide to create your Facebook application.

If you’re using the latest version of the Facebook API, please remove the user_gender scope from the ReachFive client configuration to prevent any issues.

Configure the Info.plist file with the following XML snippet that contains data about your application:

<!-- Info.plist -->

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb$(YOUR_FACEBOOK_APPLICATION_ID)</string>
        </array>
    </dict>
</array>
<key>FacebookAppID</key>
<string>$(YOUR_FACEBOOK_APPLICATION_ID)</string>
<key>FacebookDisplayName</key>
<string>$(YOUR_APPLICATION_NAME)</string>

Then to use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, include the following lines:

<!-- Info.plist -->

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

Google native provider

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

Add these lines to your Podfile file, replacing x.y.z with the latest version:

pod 'IdentitySdkGoogle', '~> x.y.z'

Then run:

pod install

Refer to the Google Connect guide to create your Google application.

Google Sign-in requires a custom URL Scheme to be added to your project. To add the custom scheme:

  1. Open your project configuration: double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section.

  2. Click the + button, and add your reversed client ID as a URL scheme.

    The reversed client ID is your client ID with the order of the dot-delimited fields reversed. For example com.googleusercontent.apps.1234567890-abcdefg.

    When completed, your config should look something similar to the following (but with your application-specific values):

    xcode infotab url type values

Finally, add the Google Sign-In interface and declare that your view controller managing your app’s sign-in screen implements the GIDSignInUIDelegate protocol.

import UIKit
import IdentitySdkCore
import GoogleSignIn

class ViewController: UIViewController, GIDSignInUIDelegate {
    ...
}

Initialization

import UIKit
import IdentitySdkCore
import IdentitySdkFacebook
import IdentitySdkWebView
import IdentitySdkGoogle

class AppDelegate: UIResponder, UIApplicationDelegate {
    let DOMAIN    = "Here paste your ReachFive domain"
    let CLIENT_ID = "Here paste your ReachFive client ID"
    let SCHEME    = "Here paste your ReachFive scheme"

    let reachfive = ReachFive(
        // The configuration parameters required to initialize the ReachFive client
        sdkConfig: SdkConfig(domain: DOMAIN, clientId: CLIENT_ID, scheme: SCHEME),
        // The list of the social providers needed by the application
        providersCreators: [GoogleProvider(), FacebookProvider(), WebViewProvider()]
    )

    // Return the ReachFive client
    static func reachfive() -> ReachFive {
        let app = UIApplication.shared.delegate as! AppDelegate
        return app.reachfive
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return reachfive.application(app, open: url, options: options)
    }
}
import UIKit
import IdentitySdkCore

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // Initialize the ReachFive client and create the several providers
        AppDelegate
            .reachfive()
            .initialize()
            .onSuccess { providers in
                // If success, retrieve the list of providers registred on the ReachFive client
                // ...
            }
            .onFailure { error in
                // If failure, log the error message returned by the ReachFive client
                print("ReachFive init \(error)")
            }
    }
}

Below are all the functions accessible via the iOS SDK.

In all the code examples below, the ReachFive client is instantiated and stored in your AppDelegate class. You can access it through the AppDelegate.reachfive() method.