expo-fitbit

1.0.0 • Public • Published

@beaverfy/expo-fitbit (image)

@beaverfy/expo-fitbit

Add fitbit authentication to your expo managed react native apps

Getting Started

Installation

Using yarn

yarn add @beaverfy/expo-fitbit

Using NPM

npm install @beaverfy/expo-fitbit

Getting Credentials

Register an app on dev.fitbit.com, fill out your app details and select client, since we'll be using the credentials in our app

Once you've created your app, edit your app to have the redirect url: scheme://fitbit (replacing scheme with your app's scheme)

Intergrating into your project

We're still working on this section

Wrap your app in FitbitProvider:

import { FitbitProvider } from "@beaverfy/expo-fitbit";
import Constants from "expo-constants";
import { MMKV } from 'react-native-mmkv';
export const storage = new MMKV({
    id: `authentication`,
    encryptionKey: 'random-password'
});

<FitbitProvider configuration={{
    clientId: "CLIENT_ID",
    clientSecret: "CLIENT_SECRET",
    appScheme: Constants.expoConfig.scheme,
    scopes: ["profile"],
    storage: {
        get: (key) => storage.getString(key),
        set: (key, value) => storage.set(key, value)
    },
    onLogin(user) => console.log("User logged in:", user);
}}>
    {/* app code... */}
</FitbitProvider>

Get the user's profile data with the useFitbit hook:

const {
    userData,
    isLoading,
    isLoggedIn
} = useFitbit();

return <Text>Logged in as: {userData?.name}</Text>

Readme

Keywords

none

Package Sidebar

Install

npm i expo-fitbit

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

301 kB

Total Files

19

Last publish

Collaborators

  • turtlepaw