This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

react-native-terra-apple
TypeScript icon, indicating that this package has built-in type declarations

1.1.9 • Public • Published

Terra React Native Apple Healthkit

This package bundles a bridge and an interface to interact with Terra's Apple SDK. This enables developers to build a react native application and connect user's Apple Healthkit to the Terra ecosystem.

Setup

First, install the NPM package:

npm install react-native-terra-apple

Then install the pod:

cd ios && pod install && cd ..

Usage

You can refer to /example for an example usage. First import:

import TerraApple from "react-native-terra-apple";

After exposing a widget session to your users, if you determine they'd like to authenticate with apple health, you can call TerraApple.auth which authenticates the user with Terra and returns a promise:

TerraApple.auth("devid", "apikey", "referenceID").then((TerraAuthResponse) => {
  // grab refID, userID, or status from the response
});

Once you have a user ID, you can connect the device SDK instance to Terra by using TerraApple.initTerra:

TerraApple.initTerra("devID", "apiKey", "userID", (autoFetch = true));

initTerra connects the device to Terra. This has to be done everytime the user opens the app (if the SDK is not initialised it has not indication about where to connect to Terra). On the other hand, the auth is only required on the first user connection from your app to map their device to a Terra user ID (after that, any call to auth will return the same user ID that was generated for that device)

If autoFetch is set to true. data is sent every 8 hours to your webhook if the users open the app. The referenceID will be pushed to your webhook in the widget session responses.

Activity data is sent to your webhook whenever the user opens the app. You can also request data from the app to be sent to your webhook using getters:

TerraApple.getBody(
  new Date("Jan 02 2022").toISOString(),
  new Date().toISOString()
);
TerraApple.getDaily(
  new Date("Jan 02 2022").toISOString(),
  new Date().toISOString()
);
TerraApple.getSleep(
  new Date("Jan 02 2022").toISOString(),
  new Date().toISOString()
);
TerraApple.getActivity(
  new Date("Jan 02 2022").toISOString(),
  new Date().toISOString()
);
TerraApple.getNutrition(
  new Date("Jan 02 2022").toISOString(),
  new Date().toISOString()
);

Note that dates are required to be passed in ISOString format.

Finally, you can deauth users using the deauth() function and calling the Terra deauth API

Package Sidebar

Install

npm i react-native-terra-apple

Weekly Downloads

0

Version

1.1.9

License

MIT

Unpacked Size

700 kB

Total Files

12

Last publish

Collaborators

  • danielks
  • terra-jack
  • elliottyu
  • thommo-terra
  • terra_alex
  • jaafarrammal