I am trying to reference the Fitness.SENSOR_API as documented (https://developers.google.com/android/reference/com/google/android/gms/fitness/Fitness.html#SENSORS_API).
In java I import
import com.google.android.gms.fitness.Fitness;
and reference it like
Fitness.SENSORS_API
but this doesn't seem to work in nativescript (referencing it as com.google.android.gms.fitness.Fitness.SENSORS_API
).
I've logged the value :
console.log('fitness native module:',
com.google.android.gms.fitness.Fitness); //Fitness is undefined
The same is true for other classes in the com.google.android.gms.fitness
package for example com.google.android.gms.fitness.FitnessOptions
as referenced here: https://developers.google.com/android/reference/com/google/android/gms/fitness/FitnessOptions.Builder
Overall, Here is what I'm trying to do:
googleApiClient = new com.google.android.gms.common.api.GoogleApiClient.Builder(activity)
.addApi(com.google.android.gms.fitness.Fitness.SENSORS_API)
.addApi(com.google.android.gms.fitness.Fitness.HISTORY_API)
.addApi(com.google.android.gms.fitness.Fitness.RECORDING_API)
.addScope('https://www.googleapis.com/auth/fitness.activity.read')
.addScope('https://www.googleapis.com/auth/fitness.activity.write')
.addScope('https://www.googleapis.com/auth/fitness.location.read')
.build();
I do have
dependencies {
implementation 'com.google.android.gms:play-services-fitness:16.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
}
in my App_Resources/Android/app.gradle file.
Am I missing something? Do I need to extend or implement some class? Why is Fitness undefined?
My overall goal is to follow these docs (https://developers.google.com/fit/android/get-started) and connect to google fitness API
Try a clean build to make sure the dependencies are installed properly, accessing the package might return undefined only in such cases.
tns platform clean android