-
Notifications
You must be signed in to change notification settings - Fork 130
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
Cannot reconnect after disconnect on Android #141
Comments
the mysterious Google APIs.... I have no idea why you have this issue, maybe try giving it some time between disconnect and reconnect. |
I did gave it a moment between health.requestAuthorization() and health.disconnect().
This is log shown when I tried to connect the 2nd time. |
!!Update!! Is it supposed to prompt user for OAuth "Allow" or "Deny" every time when I've disconnect and reconnecting? "Application needs OAuth consent from the user". |
the process is simple: once you've disconnected, you need to re-connect, exactly as the first time you connect. So, the user needs to select the account he wants to use and then allow the app to access the data. I have had a quick look at the code (see this part) and I can't see anything wrong with it. |
Hmm... once I've disconnected. I need to use health.requestAuthorization(dataType) right? After selecting an account. There would be a popup asking about the Deny Allow oAuth right? that oAuth popup has no callback. -Edit- On a fresh install, it has no problem. But after a second attempt, the process in-between the "Google Account Selection" and "oAuth Popup". these two process it's in "health.requestAuthorization(dataType)" right? the "oAuth Popup" does not return a callback on any selection that I've made. |
the answer is "yes" to all your "right?". When you call
and when you request authorization again, it rebuilds the client from the scratch:
One reason could be that you are running the re-connection from a different activity, but that's a very uncommon case for a cordova app. I'm afraid that this needs proper debugging, with Android Studio. I am not able to work on this now, and won't be able for about a month. If you can do it and you find the solution, please send a pull request and I will be happy to merge it. If you're not familiar with Android programming, I would suggest you:
|
I've tried to debug it with Android Studio with a clean new ionic project with using the plugin only.
|
the key is clearly the message that says:
I'm puzzled because the request code 1, is actually taken care of by the overridden function onActivityResult(). It's exactly the same code that works when executing the requestAuthorization the first time. I really don't know, I would like to test it myself, but I won't be able for a month or so. |
has this problem been fixed? I don't think it's related to the plugin, but I'd be happy to be contradicted. |
Good day to you Dario,
I'm quite confused on this matter because whenever I've successfully used "health.disconnect()" a account. I can't seem to get data on 2nd attempt on "health.requestAuthorization()" after selecting an account. I'll provide you a simple step by step scenario.
Selecting a Google Account. (health.requestAuthorization())
Grabbing data from the Google Account. (health.query())
Disconnecting from the Google Account. (health.disconnect())
Selecting a Google Account again. (health.requestAuthorization()).
Problem Occurs
On the 2nd attempt, the onActivityResult returns requestCode of "0" and resultCode is "0". I noticed it's supposed to return requestCode of "1" and resultCode is "-1".
The text was updated successfully, but these errors were encountered: