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 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.

Installation

ReachFive SDKs are published on Cocoapods as independent modules.

For further reference on Cocoapods, check their official documentation.
Below, you’ll find a description and instructions for installation for each module.

SDK Core

The core SDK 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.

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

    pod 'IdentitySdkCore', '~> x.y.z'
  2. Then run:

    pod install

SDK Webview

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

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

    pod 'IdentitySdkWebView', '~> x.y.z'
  2. 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.

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

    <!-- Info.plist -->
    
    <key>CFBundleURLTypes</key>
    
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>reachfive-${clientId}</string>
            </array>
        </dict>
    </array>

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 these lines to your Podfile file, replacing x.y.z with the latest version:

    pod 'IdentitySdkFacebook', '~> x.y.z'
  2. Then run:

    pod install
    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.
  3. 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>
  4. 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>
See Info.plist reference for a comprehensive look a the file.

Google native provider

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

Refer to the Google Connect guide to create your Google application.
  1. Add these lines to your Podfile file, replacing x.y.z with the latest version:

    pod 'IdentitySdkGoogle', '~> x.y.z'
  2. Then run:

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

    <key>CFBundleURLTypes</key>
    <array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>{YOUR_REVERSED_GOOGLE_CLIENT_ID}</string> (1)
        </array>
    </dict>
    </array>
    1 The URL Scheme is the reversed Google Client ID (not ReachFive’s clientID), which is your Google Client ID with the order of the dot-delimited fields reversed. For example, com.googleusercontent.apps.1234567890-abcdefg.
    See Info.plist reference for a comprehensive look a the file.

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)")
            }
    }
}

iOS methods

The sidebar contains are all the functions/methods 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.

Info.plist reference

If you configure all four SDKs, your Info.plist file should contain the following XML Snippet:

<key>CFBundleURLTypes</key>
<array>
   <dict>
      <key>CFBundleURLSchemes</key>
      <array>
         <string>fb1634029666893228</string>
      </array>
   </dict>
   <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
         <string>com.googleusercontent.apps.20987199831-rhdm7eji4ctus4ufg6a4froha2pdoc5f</string>
      </array>
   </dict>
   <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
         <string>tyaihfrj2a1fgj1t8pkd</string>
      </array>
   </dict>
   <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
         <string>reachfive-TYAIHFRJ2a1FGJ1T8pKD</string>
      </array>
   </dict>
</array>
<key>FacebookAppID</key>
<string>1634029666893228</string>
<key>FacebookDisplayName</key>
<string>Reach5 SDK Mobile</string>
<key>LSApplicationQueriesSchemes</key>
<array>
   <string>fbapi</string>
   <string>fb-messenger-share-api</string>
   <string>fbauth2</string>
   <string>fbshareextension</string>
</array>