Skip to main content

Overview

This guide walks you through the complete integration of the Open Wearables Flutter SDK, from backend setup to production deployment.
1

Set up backend authentication endpoint

2

Configure the SDK in your Flutter app

3

Implement sign-in flow

4

Request health permissions

5

Start background sync

Read the Mobile SDK Integration Guide first. It covers what is the same on every platform: authentication, the backend token endpoint, the SDK lifecycle, and the production checklist. This page shows the Flutter code for each step.

Step 1: Backend Setup

Your backend exchanges your app credentials for user-scoped SDK tokens and forwards them to the app - the app never sees app_id / app_secret. See Backend Endpoint for the setup and example code.

Step 2: SDK Configuration

Configure the SDK once at app startup, typically in your main initialization code.

Configuration Options

Provide only the base host URL, e.g. https://your-domain.com. Do not append /api/v1/ or any other path — the SDK adds the required path prefix automatically.

Session Restoration

The SDK automatically restores the user session from secure storage when configure() is called:

Step 3: Sign In

After getting credentials from your backend, sign in with the SDK:
The userId parameter is the Open Wearables User ID (UUID) — the id returned by the Create User endpoint. Do not pass your own external_user_id here.

API Key Authentication

For simpler setups (e.g. internal tools), you can use API key authentication directly:
API key authentication embeds the key in the app. Only use this for internal or trusted applications. For production apps, always use token-based authentication.

Automatic Token Refresh

When you provide a refreshToken, the SDK automatically handles 401 responses by refreshing the access token and retrying the request. You can also update tokens manually:

Step 4: Request Permissions

Request access to specific health data types:

Android Provider Selection

On Android, you must select a health data provider before requesting authorization:
On iOS, users can grant partial permissions. The SDK will sync whatever data the user allows.
Request only the data types you actually need. Requesting too many types can overwhelm users and reduce acceptance rates.

Step 5: Start Background Sync

Enable background sync to keep data flowing even when your app is in the background:

Controlling Sync History Depth

By default, the SDK syncs all available historical data on the first sync. Use the syncDaysBack parameter to limit how far back the sync goes:

Background Sync Behavior

Background sync frequency is managed by the OS and may vary based on battery level, network conditions, and user behavior.

Log Level

Control SDK log output using setLogLevel. By default, the SDK uses OWLogLevel.debug, which prints logs only in debug builds:
Set OWLogLevel.always during development or when troubleshooting sync issues in production. Switch to OWLogLevel.none if you want to suppress all SDK output.

Complete Integration Example

Here’s a complete service class showing the full integration:

Using the Service

Data Sync Endpoint

The SDK sends health data to:
string
required
Your Open Wearables API base URL (e.g. https://api.example.com).
string
required
The user ID returned when registering the SDK user.
Data is automatically normalized to the Open Wearables unified data model and can be accessed through the standard API endpoints.

Next Steps

Troubleshooting

Common issues and solutions for iOS and Android.

Data Types

Available health metrics and data formats.