SalesforceSDKManager

This class serves as an interface to the various functions of the Salesforce SDK. In order to use the SDK, your app must first instantiate the singleton SalesforceSDKManager object by calling the static init() method. After calling init(), use the static getInstance() method to access the singleton SalesforceSDKManager object.

TODO: Remove the Android Context property of this object, as it is a memory leak.

Parameters

context

The Android context

mainActivity

Activity that should be launched after the login flow

loginActivity

Login activity

googleCloudProjectId

The Google Cloud Project ID to use with Google Play Integrity API and Salesforce App Attestation or null to disable both features

Constructors

Link copied to clipboard
constructor(context: Context, mainActivity: Class<out Activity>, loginActivity: Class<out Activity>? = null, googleCloudProjectId: Long? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

An action handler in the developer support dialog.

Link copied to clipboard
fun interface RestClientCallback

Callback used by getRestClient.

Link copied to clipboard

The available Mobile SDK style themes.

Properties

Link copied to clipboard
var accountSwitcherActivityClass: <Error class: unknown class>

The class for the account switcher activity

Link copied to clipboard

The authentication account type, which should match authenticator.xml

Link copied to clipboard

An additional list of OAuth keys to fetch and store from the token endpoint

Link copied to clipboard

The Salesforce SDK manager's admin permissions manager

Link copied to clipboard

The Salesforce SDK manager's admin settings manager

Link copied to clipboard

The client side implementation of the Salesforce App Attestation External Client App (ECA) Plugin or null when Salesforce App Attestation is disabled.

Link copied to clipboard
var appConfigForLoginHost: suspend (server: String) -> OAuthConfig?

Asynchronously retrieves the app config for the specified login host. If not set or null is returned the values found in the BootConfig file will be used for all servers.

Link copied to clipboard

The Android context

Link copied to clipboard

Returns the app display name used by the passcode dialog

Link copied to clipboard

Returns the name of the app as defined in AndroidManifest.xml

Link copied to clipboard
@get:JvmName(name = "provideAppName")
open var appName: String?

The app name to use in .getUserAgent. This string must only contain printable ASCII characters.

Link copied to clipboard
open val appType: String

The app type

Link copied to clipboard

The app version

Link copied to clipboard

The Salesforce SDK manager's biometric authentication manager

Link copied to clipboard

Determines if the authentication web view's cookies will be cleared after authentication. The default behavior is true to protect against re-use of authentication related cookies and duplication authentication action. Only apps the specifically require persistent cookies should set this to false.

Link copied to clipboard

Returns a manager bound to the user who is current at the time of access, or null when there is no current user. Retaining the returned manager retains that user's identity even if the application later switches users.

Link copied to clipboard

The regular expression pattern used to detect "Use Custom Domain" input from login web view.

Link copied to clipboard

The custom tab browser to use during advanced authentication. NB: The default browser on the device is used:

Link copied to clipboard

The unique device ID

Link copied to clipboard

Information to display in the developer support dialog

Link copied to clipboard
@get:JvmName(name = "shouldForceAdvancedAuthentication")
var forceAdvancedAuthentication: Boolean

Forces advanced (browser based) authentication to always be used for login, regardless of the target server's auth configuration, including standard login servers with no My Domain. Defaults to true.

Link copied to clipboard

The Salesforce SDK manager's admin settings manager. Only defined if setAllowedSPApps() was called first

Link copied to clipboard

Optionally enables browser based login instead of web view login. This should NOT be used directly by apps as this is meant for internal use based on the value configured on the server

Link copied to clipboard

Indicates if the The Salesforce Mobile SDK user interface dark theme is enabled. It defaults to Android's dark theme enablement if a Salesforce Mobile SDK theme is not set.

Link copied to clipboard
open val isHybrid: Boolean = false

Indicates whether the app is a hybrid app

Link copied to clipboard

Indicates if IDP login flow is enabled

Link copied to clipboard

Indicates if any logout is in progress.

Link copied to clipboard

Optionally enables browser session sharing

Link copied to clipboard
@get:JvmName(name = "getIsTestRun")
@set:JvmName(name = "setIsTestRun")
var isTestRun: Boolean

Optionally enables features for automated testing.

Link copied to clipboard

When true (and isDebugBuild is also true), debug-only UI test affordances such as the Welcome Discovery simulation editor in com.salesforce.androidsdk.ui.LoginOptionsActivity are visible. Mirrors iOS' check for the IS_UI_TESTING launch argument in LoginOptionsViewController.swift.

Link copied to clipboard

The class of the activity used to perform the login process and create the account.

Link copied to clipboard

The login brand. In the following example, "" should be set here. https://community.force.com/services/oauth2/authorize/?response_type=code&...

Link copied to clipboard
open val loginServerManager: <Error class: unknown class>

The Salesforce SDK manager's login server manager

Link copied to clipboard

ViewModel Factory the SDK will use in LoginActivity and composable functions. Setting this will allow for visual customization without overriding LoginActivity.

Link copied to clipboard

Returns the class for the main activity.

Link copied to clipboard

The Salesforce SDK manager's native login manager

Link copied to clipboard

An implementation of PushNotificationInterface that handles received push notifications.

Link copied to clipboard

The class fulfilling push notification registration features. A default implementation is provided in PushService. Setting this property to a subclass will inject the specified class instead.

Link copied to clipboard
@get:JvmName(name = "getScreenLockManager")
var screenLockManager: ScreenLockManager?

The Salesforce SDK manager's screen lock manager

Link copied to clipboard

Sets authentication ability for Salesforce integration users. When true, Salesforce integration users will be prohibited from initial authentication and receive an error message.

Link copied to clipboard

The Salesforce SDK manager's SP manager. Only defined if setIdpAppPackageName() was called first

Link copied to clipboard

The Salesforce Mobile SDK user interface theme. The value is not persistent across instances of Salesforce SDK Manager

Link copied to clipboard
@get:JvmName(name = "isUseDPoP")
var useDPoP: Boolean

Flag for DPoP (Demonstration of Proof-of-Possession, RFC 9449). Defaults to true as of Mobile SDK 14. Controls whether new logins initiate DPoP key generation and DPoP-bound token requests: when true, the SDK attaches a DPoP proof JWT to token endpoint requests and uses the DPoP Authorization scheme for resource requests when the token endpoint advertises token_type: DPoP. Changing this flag only affects logins that happen after the change; it does not retroactively affect existing credentials.

Link copied to clipboard
@get:JvmName(name = "shouldUseHybridAuthentication")
var useHybridAuthentication: Boolean

Optionally, enables the hybrid authentication flow. Defaults to true

Link copied to clipboard

The Salesforce SDK manager's user account manager

Link copied to clipboard

Returns a user agent string based on the Salesforce Mobile SDK version. The user agent takes the following form: SalesforceMobileSDK/{salesforceSDK version} android/{android OS version} appName/appVersion {Native|Hybrid} uid_{device id}

Link copied to clipboard
@get:JvmName(name = "shouldUseWebServerAuthentication")
var useWebServerAuthentication: Boolean

Optionally enables the web server flow for web view log on. Defaults to true

Functions

Link copied to clipboard
Link copied to clipboard
open fun compactScreen(activity: Activity): Boolean

Determines whether the device has a compact screen. Taken directly from https://developer.android.com/guide/topics/large-screens/large-screen-cookbook#kotlin

Link copied to clipboard
fun createAppAttestationClient(googleCloudProjectId: Long? = null): <Error class: unknown class>

Creates the Salesforce App Attestation ECA Plugin Client for the selected Google Cloud Project ID. When using Salesforce App Attestation, this value must match the linked Google Cloud Project ID for the app in Google Play Console's Play Integrity API and provided to the Salesforce App Attestation External Client App Plugin.

Link copied to clipboard
Link copied to clipboard

Builds developer support actions for the developer support dialog.

Link copied to clipboard
fun getNotificationsType(type: String): <Error class: unknown class>

Returns the Salesforce Notifications API types endpoint notification type with the provided type.

Link copied to clipboard
fun getRestClient(activityContext: Activity, restClientCallback: SalesforceSDKManager.RestClientCallback)

Returns an authenticated client for the current user or starts login when no persisted account is current. If the current account cannot produce a valid user and client, removes that exact corrupt account and completes the normal logout, account-switching, or login flow without invoking restClientCallback.

Link copied to clipboard

Returns a client that carries no persisted user credentials.

Link copied to clipboard
open fun getUserAgent(qualifier: String): String

Returns a user agent string based on the Salesforce Mobile SDK version. The user agent takes the following form: SalesforceMobileSDK/{salesforceSDK version} android/{android OS version} {provideAppName()}/appVersion {Native|Hybrid} uid_{device id}

open fun getUserAgent(qualifier: String, user: UserAccount?): String

Returns a per-user agent string. Feature flags include both global and user-specific codes.

Link copied to clipboard

Indicates if a network connection is available.

Link copied to clipboard
fun invokeServerNotificationAction(notificationId: String, actionKey: String, restClient: RestClient? = clientManager?.peekRestClient()): NotificationsActionsResponseBody?

Invokes a Salesforce Notifications API notification action.

Link copied to clipboard

Indicates if developer support features are enabled. Defaults to BuildConfig.DEBUG unless another value is specified.

Link copied to clipboard

Returns true if the feature code is in the global (non-user-specific) set.

Link copied to clipboard

Returns whether this exact Android account is currently being logged out.

Link copied to clipboard
Link copied to clipboard
open fun logout(account: Account? = userAccountManager.currentAccount, frontActivity: Activity?, showLoginPage: Boolean = true, reason: OAuth2.LogoutReason = UNKNOWN)

Destroys the stored authentication credentials (removes the account) and, if requested, restarts the app.

Link copied to clipboard
open fun onCreate(owner: LifecycleOwner)
Link copied to clipboard
open fun onDestroy(owner: LifecycleOwner)
Link copied to clipboard
open override fun onPause(owner: LifecycleOwner)
Link copied to clipboard
open override fun onResume(owner: LifecycleOwner)
Link copied to clipboard
open fun onStart(owner: LifecycleOwner)
Link copied to clipboard
open fun onStop(owner: LifecycleOwner)
Link copied to clipboard
fun registerUsedAppFeature(appFeatureCode: String?): Boolean

Adds an app feature code for reporting in the user agent header

fun registerUsedAppFeature(appFeatureCode: String, user: UserAccount?)

Adds a per-user app feature code for reporting in the user agent header. Falls back to the global set when user is null.

Link copied to clipboard
fun setAllowedSPApps(allowedSPApps: List<SPConfig>)

Sets the allowed SP apps for this app. As a result this app gets an IDP manager and can be used as an IDP

Link copied to clipboard
Link copied to clipboard
fun setIDPAppPackageName(idpAppPackageName: String?)

Sets the IDP package name for this app. As a result, this app gets an SP Manager and can be used as an SP

Link copied to clipboard

Sets if developer support features are enabled.

Link copied to clipboard
Link copied to clipboard

Sets the system status and navigation bars to the light theme without regard to the system theme. This is useful when the background is light even when dark theme is enabled.

Link copied to clipboard
fun showDevSupportDialog(frontActivity: Activity?)

Displays developer support for a specified Android activity.

Link copied to clipboard
open override fun toString(): <Error class: unknown class>
Link copied to clipboard
fun unregisterUsedAppFeature(appFeatureCode: String?): Boolean

Removes an app feature code from reporting in the user agent header

fun unregisterUsedAppFeature(appFeatureCode: String, user: UserAccount?)

Removes a per-user app feature code from reporting in the user agent header. Falls back to the global set when user is null.

Link copied to clipboard
fun useNativeLogin(consumerKey: String, callbackUrl: String, communityUrl: String, reCaptchaSiteKeyId: String? = null, googleCloudProjectId: String? = null, isReCaptchaEnterprise: Boolean = false): NativeLoginManager

Creates a NativeLoginManager instance that allows the app to use its own native UI for authentication.