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

Support multi account operation for Android. #296

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

masahiro-ikemoto
Copy link

Android can deal with multiple google accounts, but the helth plugin only targets the last signed in account. So I extend the plugin to support multiple google accounts, and update example to check following changes.

  • Add requestAuthorizationWithAccount() method. It's the similar purpose with requestAuthorization(), but has optional accountName argument and returns authorized account name. The behaivor of requestAuthorization() is not changed from current version(may be...).
  • Calling requestAuthorizationWithAccount() with no accountName, account selection dialog will be appeared or last signed in account will be used, as requestAuthorization().
  • Else, calling requestAuthorizationWithAccount() with accountName, check the permission of specified account.
  • When authorization was succeed, requestAuthorizationWithAccount() returns authroized account name("" will be returned on iOS) or null(authorization failed). I assume to the app will save the account name in sharedPreference, etc.
  • Add optional accountName argument to getHealthDataFromTypes() (The argument will be simply ignored on iOS.). The plugin uses the specified account to access Google Fit data.

@@ -457,7 +457,7 @@ class HealthPlugin() : MethodCallHandler, ActivityResultListener, Result, Activi
for (typeKey in types) {
if (typeKey !is String) continue
typesBuilder.addDataType(keyToHealthDataType(typeKey), FitnessOptions.ACCESS_READ)
typesBuilder.addDataType(keyToHealthDataType(typeKey), FitnessOptions.ACCESS_WRITE)
//typesBuilder.addDataType(keyToHealthDataType(typeKey), FitnessOptions.ACCESS_WRITE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? Are you commenting out the write permission on purpose?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our project, only the fitness.*.read scope has applied for permission to access sensitive data and to remove the limit on the number of OAuth users.

Therefore, if we enable ACCESS_WRITE, it will be blocked by Google, so we comment it out to use with our app.

In general, I don't think there is a problem with enabling it, but it would be better if we could set whether to use the write function or not when we new HealthFactory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid commenting out the line will have implication on all other users who need the write feature.
But I agree with you that there should be a possibility to opt out the write feature.

By the way, thanks for your quick response :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid commenting out the line will have implication on all other users who need the write feature.

Yes, I understand that, too.

I should have made the changes locally instead of pushing them to the repository, and I did it.

But I agree with you that there should be a possibility to opt out the write feature.

I hope you make it.

Thanks,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your latest commit.

And I've filed an enhancement issue #464

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

Successfully merging this pull request may close these issues.

None yet

2 participants