Email Us

Getting Started

Install

npm install react-native-point-sdk

⚠️ Only iOS devices are supported currently.

Setting Up Point SDK

Before any feature can be used, you must initialize the SDK providing your credentials. It is recommended to do it at the start of your application.

import { AppRegistry } from 'react-native'
import PointSdkRn from 'react-native-point-sdk'

AppRegistry.registerComponent(appName, () => {
  PointSdkRn.setup('clientID', 'clientSecret', 'development', true, () =>
    console.log('Setup completed!'),
  )

  return App
})

⚠️ Using verbose: true will make the SDK print logs in the debug console about internal operations, filters, dates, errors, warnings and much more. This is helpful during development/integration phase, but we recommend turning it off before releasing your app into production.

Setting a User Token

A user token is necessary to use any of the SDK features, as it's used to identify and authenticate your user against Point API. The easiest method of handling authentication is setting a refresh token, which will allow Point SDK to automatically handle everything for you, including creating an Access Token and refreshing it when needed, automatically.

⚠️ If you have set up Healthkit integration, the setUserToken function automatically trigger a group of queries fetching past user's data, only if it's the first setUserToken usage in the current session. Because of this, we suggest evoking this function after HealthKitManager/requestAuthorizationsIfPossible() otherwise this automatic sync will fail. Refer to Point Health Kit for more information.

Set a Refresh Token

📝 This section assumes you already have a refresh token. Refer to Registering Users for more details.

Use Point/setRefreshToken(refreshToken:for:shouldSyncHistoricalData:) to set the user's refresh token.

    try {
      await PointSdkRn.setRefreshToken(
        'yourRefreshToken',
        'yourUserId'
      );
    } catch (error) {
      console.error(error);
    }

When you set the refresh token, the SDK will get a valid access token internally and will handle its expiration automatically, this way you won't need to handle the access token by yourself. If the SDK fails to get an access token with the given refresh token and exception will be thrown.

💡 You just need to call this function once, when you login your user, as the SDK stores the token and is able to user it even if the user closes your app.

Set Access Token manually

📝 This section assumes you already have an access token. Refer to Registering Users for more details.

You can also manually handle your Access Token. Call Point/setAccessToken(accessToken:shouldSyncHistoricalData:) to set an access token. Note that you will need to call this function every time the access token expires (tipically in 24 hours).

import PointSdkRn from 'react-native-point-sdk'

try {
  await PointSdkRn.setAccessToken('yourAccessToken')
} catch (error) {
  console.error(error)
}

⚠️ You don't need to call this function if you have already set a Refresh Token.

Collecting and uploading samples

Use one or more of our integrations to collect and upload health samples and basic user data to Point Database.

  • Check HealthKit Integration to know how to support Apple Watch and Health app. This is only available in iPhone devices.

  • Check Fitbit Integration to know how to support Fitbit devices. This is available regardless of device.

Retrieving user data and generated metrics

Use the Point Health Service functions to retrieve user data and generated metrics such as recommendations, trends, workouts, health metrics and more.

Next Steps

Learn more about the Health Kit integration.

Download our App

Connect with Us

Terms & Conditions | Privacy Policy © 2023 Point® (Key Point Technologies, Inc.)