Vivanta Connect for Flutter
Plugin to integrate Vivanta Connect in Flutter Projects
How to implement Vivanta Connect Flow
- Add the import of Vivanta Connect
import 'package:vivanta_connect_flutter/views/start_vivanta_connect.dart';
- Create a route to open Vivanta Connect. For example:
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => VivantaConnectFlutter(
apiKey: apiKey, // Required
customerId: customerId, // Required
externalUserId: externalUserId, // Required
companyId: companyId, // Optional
),
),
);
Optional use with a JWT Token obtained by the /users/auth
endpoint:
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => VivantaConnectFlutter(
token: token, // Required
),
),
);
- Vivanta Connect will start and automatically set the language based on the configuration of the device.
Note: Vivanta Connect requires a valid API Key and the associated Customer ID to fully function.
How to implement Embedded Graphs
- Create a route to open an Embedded Graph
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => EmbeddedGraph(
apiKey: apiKey, // Required
customerId: customerId, // Required
externalUserId: externalUserId, // Required
graphType: graphType, // Required (Sleep, Active Time, Activity)
brandId: brandId, // Optional, only for users with more than 1 brand connected
),
),
);
Only for Apple Health integrations (iOS)
- Add this code at the start of your user's session for obtaining and syncing Apple Health data.
import 'package:vivanta_connect_flutter/helpers/vivanta_sync.dart';
final vivantaSyncData = VivantaSync(
apiKey: apiKey, // Required
customerId: customerId, // Required
externalUserId: externalUserId, // Required
);
vivantaSyncData.executeAll(); // This process gets data from HealthKit and uploads to Vivanta
);
Optional use with a JWT Token obtained by the /users/auth
endpoint:
import 'package:vivanta_connect_flutter/helpers/vivanta_sync.dart';
final vivantaSyncData = VivantaSync(
token: token, // Required
);
vivantaSyncData.executeAll(); // This process gets data from HealthKit and uploads to Vivanta
);
- Add the following elements in the Info.plist file.
<key>NSHealthShareUsageDescription</key>
<string>[Add here the purpose for reading from Apple Health]</string>
<key>NSHealthUpdateUsageDescription</key>
<string>[Add here the purpose for writing to Apple Health]</string>
Only for Google Health Connect integrations (Android)
- Add the following code in your AndroidManifest.xml, inside the root node:
<queries>
<package android:name="com.google.android.apps.healthdata" />
<package android:name="com.google.android.apps.fitness" />
</queries>
- Add the following code in your main
<activity>
node:
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
- Add at least one of the permissions that your app will have access, in your AndroidManifest.xml inside the root node. The complete list of permissions is in this link: developer.android.com/health-and-fitness/guides/health-connect/plan/data-types#alpha10. For example:
<uses-permission android:name="android.permission.health.READ_STEPS"/>
- In your
gradle.properties
file, replace this values:
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
- Add this code at the start of your user's session for obtaining and syncing Google Health Connect data.
import 'package:vivanta_connect_flutter/helpers/vivanta_sync.dart';
final vivantaSyncData = VivantaSync(
apiKey: apiKey, // Required
customerId: customerId, // Required
externalUserId: externalUserId, // Required
);
vivantaSyncData.executeAll(); // This process gets data from HealthKit and uploads to Vivanta
);
Optional use with a JWT Token obtained by the /users/auth
endpoint:
import 'package:vivanta_connect_flutter/helpers/vivanta_sync.dart';
final vivantaSyncData = VivantaSync(
token: token, // Required
);
vivantaSyncData.executeAll(); // This process gets data from HealthKit and uploads to Vivanta
);
Libraries
- config/config
- data/apple_category_type
- data/apple_category_type_client
- data/apple_quantity_type
- data/apple_quantity_type_client
- data/brand
- data/client
- data/credential
- data/google_parameter_type
- data/google_parameter_type_client
- data/user
- enums/apple_health_activity_type
- enums/apple_health_parameter_type
- enums/google_health_activity_type
- enums/google_health_parameter_type
- enums/meal_types
- helpers/helpers
- helpers/vivanta_sync
- main
- models/apple_health_element
- models/google_health_connect_element
- screen_arguments
- services/apple_health
- services/database
- services/google_health_connect
- services/http
- services/preferences
- styles/colors
- styles/fonts
- views/brands
- views/close_vivanta_connect
- views/embedded_graph
- views/loading
- views/privacy
- views/start_vivanta_connect
- views/start_vivanta_connect_with_token
- views/webview
- vivanta_connect_flutter
- widgets/brand_item
- widgets/error_screen