new-react-native-samsung-health
v1.0.0
Published
React Native bridge for Samsung Health — read steps, step history, and exercise data on Android
Maintainers
Readme
react-native-samsung-health
React Native bridge for Samsung Health (Android only). Read steps, step history, and exercise data.
Requirements
- React Native ≥ 0.60
- Android only (Samsung device with Samsung Health app installed)
- Android minSdk ≥ 29 (Android 10)
Installation
npm install react-native-samsung-healthThen rebuild your Android app:
npx react-native run-androidAuto-linking handles everything else — no need to touch MainApplication.kt.
Android Setup
Two things to configure in your project (everything else is handled by the plugin automatically).
1. Disable New Architecture
This package uses the Old Bridge architecture and is not compatible with TurboModules. Add this to android/gradle.properties:
newArchEnabled=false2. minSdkVersion
The Samsung Health SDK requires Android 10 minimum. Make sure your android/build.gradle has:
// android/build.gradle
ext {
minSdkVersion = 29 // required by Samsung Health SDK
// ...
}That's it
Everything below is handled automatically by the plugin — no action required:
| What | How |
|---|---|
| ACTIVITY_RECOGNITION permission | Auto-merged from plugin's AndroidManifest.xml |
| <queries> for Samsung Health package | Auto-merged from plugin's AndroidManifest.xml |
| Samsung Health SDK (AAR) | Bundled inside the plugin |
| kotlin-parcelize-runtime | Declared as plugin dependency |
| gson | Declared as plugin dependency |
| Module registration | Auto-linking (RN ≥ 0.60) |
Usage
Hook
import { useSamsungHealth } from 'react-native-samsung-health';
function MyScreen() {
const { isConnected, isLoading, login, logout, getSteps, getActivities, checkConnection } = useSamsungHealth();
const handleConnect = async () => {
const connected = await login();
console.log('Connected:', connected);
};
const handleSteps = async () => {
const history = await getSteps();
// [{ date: "2026-03-28", value: 8432 }, ...]
console.log(history);
};
const handleActivities = async () => {
const activities = await getActivities();
// [{ startTime: "...", endTime: "...", type: "RUNNING", distance: "5200.0", duration: "1800000" }, ...]
console.log(activities);
};
return (
// ...
);
}Direct native module access
For advanced use cases you can call the native module directly:
import { SamsungHealthModule } from 'react-native-samsung-health';
// Check if Samsung Health app is installed
const installed = await SamsungHealthModule.isSamsungHealthInstalled();
// Initialize the store
await SamsungHealthModule.initialize();
// Request permissions (shows Samsung Health permission dialog)
await SamsungHealthModule.requestPermissions();
// Check which permissions are granted
const status = await SamsungHealthModule.checkConnection();
// { steps: true, exercise: true, connected: true }
// Read today's total steps
const steps = await SamsungHealthModule.readStepCount();
// Read 14-day step history
const history = await SamsungHealthModule.readStepHistory();
// [{ date: "2026-03-28", value: 8432 }, ...]
// Read 3-week exercise history
const exercises = await SamsungHealthModule.readExercises();
// [{ startTime, endTime, type, distance, duration }, ...]API Reference
useSamsungHealth()
| Property | Type | Description |
|---|---|---|
| isConnected | boolean | Whether permissions are currently granted |
| isLoading | boolean | True during initialization or permission request |
| login() | Promise<boolean> | Initialize + request permissions. Returns true if granted |
| logout() | Promise<void> | Clear local connection state |
| getSteps() | Promise<StepHistoryEntry[]> | 14-day step history |
| getActivities() | Promise<ExerciseEntry[]> | 3-week exercise history |
| checkConnection() | Promise<ConnectionStatus> | Check current permission status without showing any dialog |
Types
interface StepHistoryEntry {
date: string; // "YYYY-MM-DD"
value: number; // total steps for the day
}
interface ExerciseEntry {
startTime: string; // ISO datetime
endTime: string; // ISO datetime
type: string; // e.g. "WALKING", "RUNNING", "CYCLING"
distance: string; // in meters
duration: string; // in milliseconds
}
interface ConnectionStatus {
steps: boolean;
exercise: boolean;
connected: boolean;
}Troubleshooting
App crashes silently when calling step or exercise methods
Rebuild from scratch after installing:
cd android && ./gradlew clean && cd ..
npx react-native run-androidTurboModuleRegistry.getEnforcing error at startup
The new architecture is enabled. Set newArchEnabled=false in android/gradle.properties and do a clean rebuild.
isSamsungHealthInstalled() always returns false
Either Samsung Health is not installed on the device, or the <queries> block is missing from the merged manifest. Check:
android/app/build/intermediates/merged_manifests/debug/AndroidManifest.xmlSamsung Health permission dialog doesn't appear
initialize() must be called before requestPermissions(). The login() hook method handles this automatically.
Build fails with minSdkVersion error
Set minSdkVersion = 29 in the ext block of android/build.gradle.
Steps always return 0 / exercises return empty
This is expected on an emulator — Samsung Health has no data. Test on a real Samsung device with Samsung Health installed and some recorded activity.
