addPasswordlessCallback

AppDelegate.reachfive().addPasswordlessCallback(passwordlessCallback)

Setup

Before using this method, you need to setup deep link interception by using application(_:open:options).

About this command

Add the callback that will be executed when the magic link is intercepted. Parse the link and perform a code exchange for authentification.

Examples

You can call this method when the app is launched:

import Reach5

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
      AppDelegate.reachfive().addPasswordlessCallback { result in
        switch (result) {
          case .success(authToken):
            // Handle authToken
          case .failure(error):
            // Handle error
          }
      }

      return true
  }
}

Parameters

Parameter Description

passwordlessCallback PasswordlessCallback

The callback that will be executed when the magic link is intercepted. The callback takes a Result with either an AuthToken or a ReachFiveError.

AuthToken

When the code exchange succeed and the user is authenticated.

ReachFiveError

When an error occured.