Runtime Consumer Key

In some scenarios, a single mobile app must support multiple Salesforce orgs, each with its own external client app or connected app configuration. For example, production and sandbox environments can use different consumer keys, redirect URIs, or OAuth scopes.

Historically, Mobile SDK required the consumer key to be defined statically in the boot config file. Starting in Mobile SDK 13.2, you can dynamically provide the correct OAuth configuration at login time based on the server selected by the user.

By default, the SDK returns values from your app's boot config file for all login hosts. If you do not customize this behavior, your app uses one external client app or connected app configuration for every server.

If your custom runtime selector returns null (Android) or nil (iOS), the SDK falls back to the static boot configuration.

To implement a runtime consumer key on Android, set the appConfigForLoginHost property on SalesforceSDKManager.

appConfigForLoginHost accepts a suspended lambda, supporting asynchronous operations. To simplify host comparisons, use the String.urlHostOrNull() extension function from com.salesforce.androidsdk.util.

To implement a runtime consumer key on iOS, set bootConfigRuntimeSelector on SalesforceManager (Swift) or appConfigRuntimeSelectorBlock on SalesforceSDKManager (Objective-C).

These properties accept a closure/block that receives the login host and a callback.