Im using Google fit to track user steps with react-native-google-fit. After getting user permission to track Activity and Body im getting an error that I need to request permission from user of Activity Recognition.
This is the xml I added (also tried to add LOCATION):
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<!-- <uses-permission android:name="com.google.android.gms.permission.LOCATION"/> --> <---- tried with this as well
This is the sdk versions in the gradle.build:
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 29
Also added (in gradle.build):
implementation 'com.google.android.gms:play-services-fitness:20.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
This is where the code (Google Fit) execute (HomePage.js - just after user logs in):
useEffect(() => {
const options = {
scopes: [
Scopes.FITNESS_ACTIVITY_READ,
Scopes.FITNESS_ACTIVITY_WRITE,
Scopes.FITNESS_BODY_READ,
Scopes.FITNESS_BODY_WRITE,
Scopes.FITNESS_LOCATION_READ, <---- also tried without
Scopes.FITNESS_LOCATION_WRITE, <---- also tried without
],
};
GoogleFit.authorize(options)
.then(authResult => {
if (authResult.success) {
alert('AUTH_SUCCESS'); <------ alert success
GoogleFit.startRecording((callback) => { <----- application crash (see attached image)
});
} else {
alert('AUTH_DENIED', authResult.message);
}
})
.catch(() => {
alert('AUTH_ERROR');
});
}, []);
It doesnt crash on the simulator, only on physical device. The physical device im using is android with android 10. Tho I need to accommodate version >= 8.
Any help will be greatly appreciated!