Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using react-native-google-fit with Google Fit SDK #26

Closed
reboss opened this issue Oct 21, 2017 · 9 comments
Closed

Using react-native-google-fit with Google Fit SDK #26

reboss opened this issue Oct 21, 2017 · 9 comments

Comments

@reboss
Copy link
Contributor

reboss commented Oct 21, 2017

Hello again,

I tried to include the Google Fit SDK with my project and now I'm getting some errors when trying to interact with this package:

node_modules\react-native-google-fit\android\src\main\java\com\reactnative\googlefit\GoogleFitManager.java:40: error: GoogleFitManager is not abstract and does not override abstract method 

onActivityResult(int,int,Intent) in ActivityEventListener
public class GoogleFitManager implements
       
node_modules\react-native-googlefit\android\src\main\java\com\reactnative\googlefit\GoogleFitManager.java:197: error: method does not override or implement a method
from a supertype
    @Override
    
node_modules\react-native-google-fit\android\src\main\java\com\reactnative\googlefit\GoogleFitManager.java:212: error: method does not override or implement a method
from a supertype
    @Override
    
3 errors
:react-native-google-fit:compileReleaseJavaWithJavac FAILED

The lines referenced are:

40: public class GoogleFitManager implements
        ActivityEventListener {
...
197: @Override
    public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
...
212:  @Override
    public void onNewIntent(Intent intent) {
    } 

I assume that if react-native-google-fit can communicate with the Google Fit App when I have it installed it should also be able to communicate with the SDK in much the same way. Do you know how I can fix this? If pointed in the right direction I could try to make a PR.

Thanks.

@dozel
Copy link

dozel commented Nov 1, 2017

Can you share some of your code where you use this library?

@StasDoskalenko
Copy link
Owner

@reboss any updates?

@reboss
Copy link
Contributor Author

reboss commented Nov 8, 2017

Hey, sorry for the late reply. Yes, I think the problem described above was due to a conflict in our gradle configs. I was compiling a different version of the Google Fit SDK than this package was. It's all fixed now though.

I did some more research into the Google Fit SDK and have found that in order to get fitness tracking to work without having the app itself installed, you have to initialize the Recording API. Then you can read fitness history without having any third party apps.

I got this working in the app that I'm developing using React's Native Modules, similarly to how this package was built. I'm hoping to make a PR in the next week or two if you guys are willing to look at it?

@StasDoskalenko
Copy link
Owner

@reboss Hey! That would be awesome! Thanks!

@StasDoskalenko
Copy link
Owner

@reboss hey any updates? Maybe I can help you to move this functionality to production? It should be a really big step forward :)

@reboss
Copy link
Contributor Author

reboss commented Nov 16, 2017

Hey @StasDoskalenko, I added the basic Recording API functionality in my fork if you want to take a look. I still need to test it and I wanted to add a little bit more functionality like allowing an array of fitness types to subscribe to to be passed as parameters to startFitnessRecording() and also adding some event handlers similar to how the authorize() function is set up.

@reboss
Copy link
Contributor Author

reboss commented Nov 16, 2017

If you want, I'll make a PR as soon as I get a chance to test it, although I'm going to a Hackathon this weekend so I should be able to complete everything then :)

@StasDoskalenko
Copy link
Owner

@reboss sure thanks!

@StasDoskalenko
Copy link
Owner

@reboss hey! I've just merged your PR and added some changes. For example, I've added listeners directly to the lib. Because many of guys using this lib are using callbacks and it's more easy to them. You did a great job, thanks!

startRecording(callback) {
        googleFit.startFitnessRecording();

            DeviceEventEmitter.addListener(
                'STEP_RECORDING',
                (steps) => callback(steps));

            DeviceEventEmitter.addListener(
                'DISTANCE_RECORDING',
                (distance) => callback(distance));

            // TODO: add mote activity listeners
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants