pgforward / ios_fitbit_applehealth

iOS fitbit oAuth2.0 login and apple-health sync

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Let's Nurture

Let's Nurture

www.letsnurture.com

Let's Nurture is a registered company in UK & India providing Mobile , Web & Digital Marketing Consulting And Development Services.

iPhone App Development

iPhone App Development

Twitter Facebook

Fitbit-OAuth-Swift

Hey guys! Here's a project I was working on for iOS that connects with the Fitbit API. Becuase of some limitations set by Apple, I can't program a native app with the functionality I wanted.

#Fitbit OAuth Swift Boot Demo

This app deals with the boilerplate code of using the Fitbit API with iOS Swift, authenticating via OAuth and making a simple API call. It is meant as a starting point for more robust applications and a demonstration of some of the basic concepts of the API. Swift 4.2 with Xcode 10.1 is preferred, though

Install Xcode 10.1

Read More About the Fitbit API

##Prerequisites This document assumes you have Xcode 10.1 and Swift 4.2 installed. A tutorial for installing these is out of scope for this project, but there are many resources to instruct you on how to do so.

Developing Your Own App

First fork this repo

Then create a Fitbit App Config.

This is the config I used while developing. Your app may not need read/write access.

This is the config I used

Once you have setup your app you need to put the client ID and client secret into the application config. You should be able to find both of these on the manage apps page. These values should be placed in FitBitPOC/FitBitClass/AppConstant.swift.

Apple-Health-Swift

There's a sync button that will request Authorization for permition and allow you to access HealthKit data and then step count will be populated with current date.

HealthKit is not supported on all iOS devices. Using HKHealthStore APIs on devices which are not supported will result in errors with the HKErrorHealthDataUnavailable code. Call isHealthDataAvailable before attempting to use other parts of the framework.

Add permition in info.plist

<key>NSHealthShareUsageDescription</key>
<string>This app share your helth data.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>This app requires to access your helth data.</string>

Add permition in info.plist

Enable switch on in XCode Capabilities

Enable switch

About

iOS fitbit oAuth2.0 login and apple-health sync


Languages

Language:Swift 100.0%