Open moazkh60 opened 4 years ago
@moazkh60 Could you give us more details about this one? Where did you encounter any difficulties and did you overcome them?
First of all the documentation should list all the steps to make it work e.g For iOS or Android the first thing that needs to be done is to enable HealthKit in xcode > capabilities > call Fitness.requestPermissions function and then check is authorized. For android @annotation doesn't work now with RN 0.60 and above now you need androidx.annotation imports. Compile is deprecated and now it's implementation. Link Google developer console steps for integrating google-fit in android. Feature request: Need to add subscribeToSteps() for iOS as well.
Hi @moazkh60, Wha it is the problem with Capabilities? Or you point is we need to explain better the Capabilities -> isAuthorized => requestPermission flow? For Android we are planning to move it, for the moment if you have problems you can use justifier, it should be already inside RN for 0.60 and above.
For the feature, thanks to ask it: I don't ha ve a plan to release it, but we can start to work on it
Hi, yes that's what I am saying. One needs to manually figure out that you need to enable capabilities after running into problems and searching separately. A step by step documentation with working example code would be a good way to go.
feel free to open a PR to help on this @moazkh60
@scerelli @dmitov
I also cannot make it run with the current documentation. Here is what I am trying:
(Note, READ with capital, instead of Read
, otherwise it is 'undefined). Fresh new react-native app, registered the ClientID with Google(both the dev and the release key), and enabled Capabilities on the HealthKit store. If you can help me debug what is not working ok when starting it, I can open a PR to improve the documentation.
Below is the entire App.json and under that is the output Running on Android - the screen for choosing account appears, but after that I imagine there should be also a screen to give permissions?
Does the ClientID need to be input somewhere in the app? Should I ask for permissions somewhere else explicitly?
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import Fitness from '@ovalmoney/react-native-fitness';
const App: () => React$Node = () => {
const permissions = [
{kind: Fitness.PermissionKind.Step, access: Fitness.PermissionAccess.READ},
];
console.log('permissions');
console.log(permissions);
Fitness.requestPermissions(permissions)
.then((allowed) => {
console.log(permissions);
// Do something
console.log('Requesting peermissions');
console.log(allowed);
Fitness.subscribeToSteps()
.then((response) => {
console.log('subscribed?');
console.log(response);
})
.catch((error) => {
console.log(error);
// Do something
console.log('Subscribed to steps not ok');
});
})
.catch((error) => {
// Do something
console.log('Permissions not ok');
});
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
And the output:
[Tue Sep 08 2020 11:53:41.340] LOG permissions
[Tue Sep 08 2020 11:53:41.341] LOG [{"access": 0, "kind": 0}]
[Tue Sep 08 2020 11:53:55.513] LOG [{"access": 0, "kind": 0}]
[Tue Sep 08 2020 11:53:55.553] LOG Requesting peermissions
[Tue Sep 08 2020 11:53:55.554] LOG false
[Tue Sep 08 2020 11:53:55.554] LOG subscribed?
[Tue Sep 08 2020 11:53:55.554] LOG false
Hi @PaLaMuNDeR
It still seems to be a problem with OAuth 2.0.
It should appear a second modal with the kind of permissions you would like to asks.
I will search in this direction: f.i. are you running app in debug and register only for release?
@Francesco-Voto I registered both keys, but running in debug mode on physical device (Galaxy Note 8) via cable.
Same on the AVD, running Android 9 and Android 10
Experiencing the same issue where the second modal doesn't show up, any updates?
I think what resolved for me was deleting the app from the phone, and building the project with the Android Studio, after that exporting the app as apk file, transferring it manually to the phone and then it worked, but it was not a very easy or stable solution. Unfortunately I had to do it every time I was making some changes in the library connector
Please update your documentation for iOS and Android and include code snippets for running your code.