Extra: Data sources
Show a connections page for other data sources inside the app.
Introduction
This feature included in rook_sdk_apple_health allows developers to retrieve a list of available API data sources to build a custom connections page.
Xcode
Go to the main Xcode section to see the IDE configuration.
Getting started
Ios configuration
Go to the main Ios configuration section to see the basic configuration.
Logging
Go to the main Logging section to configure logs.
Usage
Initialize
Go to the main Initialize and Update userID sections to initialize.
Get data source authorizer
To get the authorization url for a specific data source call getDataSourceAuthorizer
:
- If the user is not authorized, an
authorizationUrl
is provided, otherwiseauthorizationUrl
will be null.
Allowed values: Garmin, Oura, Polar, Fitbit, Withings, Whoop, Dexcom.
void getDataSourceAuthorizer() async {
try {
final authorizer = await AHRookDataSources.getDataSourceAuthorizer(
dataSource,
redirectUrl: null,
);
final url = authorizer.authorizationUrl;
// Open url in a web view or web browser
} catch (error) {
// Handle error
}
}
Get authorized data sources
To get all authorized data sources for the current user getAuthorizedDataSources
:
Please note that this only represents the user connection status, and not whether the data source is currently active (sending data) or has granted permissions.
For SDK-based data sources (such as Apple Health and Health Connect), this endpoint will return true if the user was created by SDK with the corresponding updateUserId function, means that the user is linked with ROOK via SDK, but not indicates if the user granted permissions or not.
For API-based data sources (such as Fitbit, Garmin, and Withings), true indicates that the user has authorized ROOK to retrieve data through the respective third-party platform.
void getAuthorized() async {
try {
final authorizedDataSources = await AHRookDataSources.getAuthorizedDataSources();
// Success
} catch (error) {
// Handle error
}
}
The properties of the AuthorizedDataSources
are nullable to differentiate between available and unavailable data
sources.
Get authorized data sources V2
getAuthorizedDataSourcesV2
is an improved version of getAuthorizedDataSources
that returns a list of
AuthorizedDataSourceV2
with the name, authorization status and image URL of each data source.
Please note that this only represents the user connection status, and not whether the data source is currently active (sending data) or has granted permissions.
For SDK-based data sources (such as Apple Health and Health Connect), this endpoint will return true if the user was created by SDK with the corresponding updateUserId function, means that the user is linked with ROOK via SDK, but not indicates if the user granted permissions or not.
For API-based data sources (such as Fitbit, Garmin, and Withings), true indicates that the user has authorized ROOK to retrieve data through the respective third-party platform.
void getAuthorized() async {
try {
final authorizedDataSources = await AHRookDataSources.getAuthorizedDataSourcesV2();
// Success
} catch (error) {
// Handle error
}
}
Unlink from a data source
To unlink (revoke authorization) from a data source call revokeDataSource
:
Allowed values: Garmin, Oura, Polar, Fitbit, Withings, Whoop, Dexcom.
void revoke() async {
try {
await AHRookDataSources.revokeDataSource("Fitbit");
// Success
} catch (error) {
// Handle error
}
}
Pre-built connections page
If you don't want to create your own connections page, you can use our pre-built screen by
calling presentDataSourceView
:
- redirectUrl (Optional) - After the user successfully connects to a data source, the user will be redirected to this URL.
void showDataSources() {
AHRookDataSources.presentDataSourceView();
}