getProvider

AppDelegate.reachfive().getProvider(name)

Description

Retrieve a provider registered on the ReachFive client by name.

Refer at the iOS SDK Installation to initialize the providers at the client’s instantiation.

  • The scopes provided are the permissions setup in the provider’s configuration through the console.

Usage

For .login, pass the initiating UIViewController wrapped in a Presentation:

try await provider.login(scope: scope, origin: origin, presenting: Presentation(from: self))

Each provider derives what it needs from it, depending on how it authenticates:

  • Web-based providers (WebProvider, and any provider with no matching native creator, falling back to DefaultProvider) open an ASWebAuthenticationSession and need a presentation context. The SDK derives one from the view controller; if it already implements ASWebAuthenticationPresentationContextProviding, its own presentationAnchor(for:) keeps precedence.

  • AppleProvider needs the view controller to be attached to a window at call time.

  • Native SDK providers (GoogleProvider, FacebookProvider, WeChat) need only the view controller itself, or nothing at all.

In every case, call .login from viewDidAppear or a user interaction, not from viewDidLoad, so the view controller is attached to a window.

Examples

  • Login

  • Logout

import Reach5

let providerName: String = // Here paste the name of the provider

let scope = ["openid", "email", "profile", "phone", "full_write", "offline_access"]

do {
    if let provider = AppDelegate.reachfive().getProvider(name: providerName) {
        let authToken = try await provider.login(
            scope: scope,
            origin: "home",
            presenting: Presentation(from: self)
        )
        // Get the profile's authentication token
    }
} catch {
    // Return a ReachFive error
}
import Reach5

let providerName: String = // Here paste the name of the provider

do {
    if let provider = AppDelegate.reachfive().getProvider(name: providerName) {
        try await provider.logout()
        // Do something
    }
} catch {
    // Return a ReachFive error
}

Parameters

Parameter Description

name string

The name of the provider.

possible values
  • facebook

  • google

  • paypal

  • twitter

  • franceconnect

  • apple

  • oney

  • bconnect

  • line

Response

Type: Provider

Provider

The provider which name matches the name passed in argument.

name string

The name of the provider.

possible values
  • facebook

  • google

  • paypal

  • twitter

  • franceconnect

  • apple

  • oney

  • bconnect

  • line

login function

Expect the following arguments:

  • scope [String]: the list of the profileโ€™s scopes. Make sure they are allowed by the client. Default scopes are the allowed scopes set up in the clientโ€™s configuration.

  • origin String: the origin of the call

  • presenting Presentation: where the provider presents its UI. Build it from the initiating view controller: Presentation(from: self). The view controller must be attached to a window at call time.

It authenticates the profile with the provider otherwise it returns a ReachFiveError.

logout function

No argument is expected. Kill the SSO session of the profile otherwise returns a ReachFiveError.

R5 AI Assistant

Confirm Deletion