Skip to main content

Quick Start

Get started with the basic implementation

1. Overview

Features

  • Get authorization.
  • Register users.
  • Sync Samsung Health summaries and events.
  • Schedule automatic Samsung Health data syncs in background.

Restrictions

  • Samsung Health Data SDK requires Samsung Health v6.29 or later version installation.
  • Samsung Health runs on devices with Android 10 (API level 29) or above. It is available on all Samsung smartphones and also non-Samsung Android smartphones.
  • The SDK doesn’t support an emulator.

Android Studio

Android Studio Narwhal 4 Feature Drop | 2025.1.4 or higher is recommended.

Dart and Flutter

This package was developed with the following sdk constraints:

  • dart: >=3.10.4 <4.0.0
  • flutter: >=3.0.0

2. Installation

In your build.gradle (app) set your min and target sdk version like below:

minSdk 29
targetSdk 36
  • rook_sdk_samsung_health
    • Latest version: Samsung Version
    • Latest stable version: 4.0.0
    • LTS version (supported until September 27, 2026): 1.1.0
  • rook_sdk_core
    • Latest version: Core Version
    • Latest stable version: 4.0.0
    • LTS version (supported until September 27, 2026): 1.2.0
flutter pub add rook_sdk_core
flutter pub add rook_sdk_samsung_health

In your build.gradle (app module) copy the samsung-health-data.aar file to your project libs directory and include it as a dependency:

dependencies {
implementation(files("$rootDir/libs/samsung-health-data-api-1.0.0.aar"))
}

Enable developer mode on your device.

3. Initialize SDK

void initialize() {
final configuration = RookConfiguration(
clientUUID: clientUUID,
secret: secret,
environment: environment,
// If true background sync will start when the SDK is initialized
enableBackgroundSync: true,
);

// Enable logging only on debug builds
if (isDebug) {
RookSamsung.enableNativeLogs();
}

RookSamsung.initRook(configuration).then((_) {
// Success
}).catchError((error) {
// Handle error
});
}
tip

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.

tip

You should only initialize the SDK once per app launch.

Critical Requirement

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.

4. Update userID

Update the userID:

void updateUserID() {
RookSamsung.updateUserID(userID).then((_) {
// Success
}).catchError((exception) {
// Handle error
});
}
info

Any call to updateUserID with a different userID will override the previous userID and reset the sync status, so if you are using Automatic Sync all health data will synchronize again.

5. Request permissions

Check availability

Before requesting permissions check that Samsung Health is installed and ready to be used:

void checkAvailability() {
RookSamsung.checkSamsungHealthAvailability().then((availability) {
// Success
}).catchError((exception) {
// Handle error
});
}

Once you have confirmed that availability == SamsungHealthAvailability.installed, ask permissions:

void requestPermissions() {
final samsungPermissions = [
SamsungHealthPermission.activitySummary,
SamsungHealthPermission.bloodGlucose,
SamsungHealthPermission.bloodOxygen,
SamsungHealthPermission.bloodPressure,
SamsungHealthPermission.bodyComposition,
SamsungHealthPermission.exercise,
SamsungHealthPermission.exerciseLocation,
SamsungHealthPermission.floorsClimbed,
SamsungHealthPermission.heartRate,
SamsungHealthPermission.nutrition,
SamsungHealthPermission.sleep,
SamsungHealthPermission.steps,
SamsungHealthPermission.waterIntake,
];

RookSamsung.requestSamsungHealthPermissions(samsungPermissions).then((requestPermissionsStatus) {
if (requestPermissionsStatus == RequestPermissionsStatus.alreadyGranted) {
// Permissions already granted, update your UI
} else {
// Permissions dialog has been displayed
}
}).catchError((error) {
// Handle error
});
}

6. Schedule a background sync

void enableBackgroundSync() async {
try {
await RookSamsung.enableBackground(enableNativeLogs: isDebug);

// Background sync enabled
} catch (error) {
// Handle error
}
}
tip

We recommend adding an extra call to enableBackground in the main method:

void main() {
// Ensure that the plugin is ready
WidgetsFlutterBinding.ensureInitialized();

if (Platform.isAndroid) {
enableAndroidBackgroundSync();
} else {
enableIOSBackgroundSync();
}

runApp(App());
}

void enableAndroidBackgroundSync() async {
try {
final userAllowedBackgroundSync = await AppPreferences().getUserAllowedBackgroundSync();

if (userAllowedBackgroundSync) {
await RookSamsung.enableBackground(enableNativeLogs: isDebug);
}
} catch (error) {
// Log
}
}

void enableIOSBackgroundSync() async {
// Go to IOS documentation to learn how to enable background sync
}

Continue learning

Next steps

Prepare for release

Additional resources