Usage: SDK initialization
Set your credentials and get authorization of usage.
Initialize
Set a configuration and initialize. The RookConfiguration
requires the following parameters:
- clientUUID
- secretKey
- environment
- enableBackgroundSync: If true background sync will start when initRook is called.
void initialize() {
const environment =
kDebugMode ? RookEnvironment.sandbox : RookEnvironment.production;
final rookConfiguration = RookConfiguration(
clientUUID: clientUUID,
secretKey: secretKey,
environment: environment,
enableBackgroundSync: true,
);
// MUST be called first if you want to enable native logs
if (kDebugMode) {
AHRookConfigurationManager.enableNativeLogs();
}
AHRookConfigurationManager.setConfiguration(rookConfiguration);
AHRookConfigurationManager.initRook().then((_) {
// Success
}).catchError((exception) {
// Hanlde error
});
}
Recommendations
When you initialize with initRook
the SDK an HTTP request is made, so you should only initialize the sdk once.