728x90
- 인증 요청
const options = {
scopes: [
Scopes.FITNESS_ACTIVITY_READ,
Scopes.FITNESS_HEART_RATE_READ,
// Scopes.FITNESS_STEP_READ,
// Scopes.FITNESS_BODY_READ,
// Scopes.FITNESS_SLEEP_READ,
// Scopes.FITNESS_LOCATION_READ,
// Scopes.FITNESS_NUTRITION_READ
]
};
GoogleFit.authorize(options)
.then(authResult => {
if(authResult.success) {
console.log("AUTH SUCCESS");
}
else console.log("AUTH ERROR!");
})
.catch( () => {
console.log("AUTH EXCEPTION!");
});
console.log("#");
GoogleFit.checkIsAuthorized().then(() => {
console.log("Auth="+GoogleFit.isAuthorized) // Then you can simply refer to `GoogleFit.isAuthorized` boolean.
setQuote(GoogleFit.isAuthorized ? "GoogleFit.Authorized": " FAILED!")
})
}, [])
- 스텝 개수 구하기
async function fetchGoogleApiCall_STEP() {
const opt = {
startDate: "2021-08-10T00:00:17.971Z", // required ISO8601Timestamp
endDate: new Date().toISOString(), // required ISO8601Timestamp
bucketUnit: "DAY", // optional - default "DAY". Valid values: "NANOSECOND" | "MICROSECOND" | "MILLISECOND" | "SECOND" | "MINUTE" | "HOUR" | "DAY"
bucketInterval: 1, // optional - default 1.
};
const res = await GoogleFit.getDailyStepCountSamples(opt)
{
if(res !== null)
{
{
for(let i = 0; i < res.length; i++)
{
console.log(res[i]);
}
setSource(""+res[2].rawSteps[0].steps+","+
res[2].rawSteps[1].steps);
}
}
};
// .catch((err) => {console.warn(err)});
}
'M64 > react-native' 카테고리의 다른 글
REST API 연결 (0) | 2021.08.13 |
---|