PrimaryUserService
¶
Some customers may have a different onboarding process for the primary user, defined as the first user to be onboarded, compared to other users. For example, the primary user may need to use a browser for authentication, while other users can only use the WebView
. This service is built to accommodate such requirements.
Features¶
Specify the Effective Multiple User Mode¶
open class PrimaryUserService(internal val defaultEffectiveMultiMode: Boolean? = null) { ... }
The PrimaryUserService
has an argument in the constructor, defaultEffectiveMultiMode
, with a default value of null. If the argument is not specified, the multiple-user mode property inside AppConfig
is either retrieved from MDM, QR code, or other means. Otherwise, the specified multiple-user mode will be used.
When specifying a value here, please note that the AppConfig
defined in the SAP mobile service cockpit must be a multiple user app, otherwise, the argument value will be ignored.
Switch the Multiple User Mode at Runtime¶
If the application in SAP mobile service cockpit is a multiple user mode app, the primary user can change the mode at runtime. When switching from multiple to single user mode, all users except the primary user will be deleted.
suspend fun switchMultipleUserMode() {...}
suspend fun effectiveMultipleUserMode(): Boolean { ... }
fun appConfigMultipleUserMode(): Boolean { ... }
The function effectiveMultipleUserMode
can be used to check the current effective multiple user mode. appConfigMultipleUserMode
is used to check the multiple-user mode setting in AppConfig
, and switchMultipleUserMode
can be used to switch between single and multiple-user modes.
If the user is not the primary user, switchMultipleUserMode
will throw an exception.
How to Use¶
The client code can initialize the service with SDKInitializer
, for example:
val services = listOf(
PrimaryUserService(defaultEffectiveMultiMode = false)
)
SDKInitializer.start(
application = this,
apiKey = "7aef4e34-83a3-4e5f-92b3-65caa47c1ce1",
services = services.toTypedArray()
)
Once PrimaryUserService
is initialized with SDKInitializer
, the onboarding flow will use it during the onboarding process. To switch to the runtime multiple-user mode, the following sample code can be used:
SDKInitializer.getService(PrimaryUserService::class)?.switchMultipleUserMode()