Fitness Data
Accessing and Syncing Fitness Data with the VitalEarth SDK
Last updated
Accessing and Syncing Fitness Data with the VitalEarth SDK
Last updated
The VitalEarth SDK empowers you to access and synchronize fitness data for users across your ecosystem of applications. This ensures that fitness-related information, such as steps and activities, is seamlessly shared and accessible among all applications utilizing the SDK.
Before you can work with fitness data, ensure you have completed the installation and initialization of the VitalEarth SDK, as explained in the previous steps.
To retrieve a user's fitness activity based on their address, use the following code:
Explanation of the code:
Import the fitnessClient
module from the VitalEarth SDK.
Initialize the client
object for fitness data management.
Specify the user's address in the userAddress
variable. Replace "0x123456789abcdef"
with the actual user's Ethereum address.
Use await client.getFitnessActivity(userAddress);
to fetch the user's fitness activity based on their address.
Check if fitness data exists, and if it does, you can access and utilize the user's fitness activity information.
To sync fitness activity for a user, use the following code:
Explanation of the code:
Import the fitnessClient
module from the VitalEarth SDK.
Initialize the client
object for fitness data management.
Specify the user's address in the userAddress
variable. Replace "0x123456789abcdef"
with the actual user's Ethereum address.
Use await client.syncFitnessActivity(userAddress);
to synchronize the user's fitness activity. This ensures that the most up-to-date fitness data is available for all applications using the VitalEarth SDK.
By implementing these fitness data management functions in your application, you can provide users with a unified and consistent fitness experience across your ecosystem of sustainability-focused apps. This allows users to track their progress and engage in eco-conscious activities seamlessly.