Usage: SDK initialization
Set your credentials and get authorization of usage.
Initialize
Initialize with a configuration. The RookConfiguration requires the following parameters:
- clientUUID
- secret
- environment
- enableBackgroundSync: If true background sync will start when initRook is called.
- appId (optional): The bundle identifier of your app. If omitted, the SDK reads it from
Context.packageName.
void initialize() async {
final configuration = RookConfiguration(
clientUUID: clientUUID,
secret: secret,
environment: environment,
// If true background sync will start when the SDK is initialized
enableBackgroundSync: false,
);
if (kDebugMode) {
RookSamsung.enableNativeLogs();
}
try {
await RookSamsung.initRook(configuration);
// Success
} catch (error) {
// Handle error
}
}
You should only initialize the SDK once per app launch.
We recommend you to ask your users if they want to enable the automatic sync and steps tracking, then save their
preference in local storage and set enableBackgroundSync conditionally.
You must register your applicationId (package name) and its corresponding secret in the ROOK Portal before
attempting to initialize the SDK. Failure to register these credentials will cause the initialization to fail with an
SDKNotAuthorizedException.
The ROOK Portal supports independent configurations for Sandbox and Production environments. Each environment requires its own unique pair of Package Name and secret.
If you come from a previous version you MUST re-initialize the SDK with the new authentication flow.