-
Notifications
You must be signed in to change notification settings - Fork 622
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
[Health 10.2.0] Health().requestAuthorization(...) always returning false for Android / Health Connect #959
Comments
I have a similar issue. I have one screen that checks for permission. If permission is not granted, I redirect the user to the permission screen. Since the permission request returns null every time the user opens the app, they need to grant permission each time. |
I have the same issue. i have done everything. yet, still always false |
same here |
@AdamBrejcak @Milimeter I found out that we could avoid checking if permission is granted or not. What I have done is to always request authorization blindly if the user hasn't granted permission the plugin request the user to grant permission and if the user already granted permission the plugin skips that step. It works both on Android and iOS. Instead of checking if user has permission simply always just request for the authorization |
@larrytamnjong I think we're talking about different issues. In my case, I'm not troubled by the permissions for now (might be an issue later on) the problem right now is that the Health().requestAuthorization(types, permissions: permissions) call always returns false. If I missunderstood your reply, would you mind adding a code snippet to see how you got it to work a bit more in detail? Thank you very much. |
|
Thank you for your reply @larrytamnjong unfortunately, it seems I understood correctly, haha. It's just that my Health().requestAuthorization(types, permissions: permissions); does not seem to ever return anything except false. I just discovered a few days ago that there is a registration process for Health Connect: https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true&pli=1 (I thought it would be indicated somewhere in the plugin's instructions. Even if it's not strictly about the plugin, if the plugin is meant to connect to Health Connect, I think it's very relevant information...) I just came across this while trying to Google for solutions for the problem I'm having. I'm just hoping that the reason why it doesn't work is that my app has not yet been approved... Although it seems rather strange that they wouldn't allow it to work even for development/testing purposes... |
Its suppose to work in development.. My app works in development then I tried to release but playstore rejected the app I had to remove the permission on the manifest files then re-upload the app without the permissions once its approved then I will be able to apply for the approval then re upload an update with the permissions |
Just what I feared... then, I have absolutely no idea about why it's not working. The setup is pretty straightforward... so I doubt anything is missing... the requestAuthorization shouldn't return false :( |
I can only suggest that you make sure you have setup the right permissions
in you android manifest file.. You can share the relevant snippets of your
code plus the manifest file and we try to debug it..
…On Tue, May 28, 2024, 16:41 CarlosCabarcos ***@***.***> wrote:
Thank you for your reply @larrytamnjong <https://github.com/larrytamnjong>
unfortunately, it seems I understood correctly, haha. It's just that my
Health().requestAuthorization(types, permissions: permissions); does not
seem to ever return anything except false.
I just discovered a few days ago that there is a registration process for
Health Connect:
https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true&pli=1
(I thought it would be indicated somewhere in the plugin's instructions.
Even if it's not strictly about the plugin, if the plugin is meant to
connect to Health Connect, I think it's very relevant information...) I
just came across this while trying to Google for solutions for the problem
I'm having.
I'm just hoping that the reason why it doesn't work is that my app has not
yet been approved... Although it seems rather strange that they wouldn't
allow it to work even for development/testing purposes...
Its suppose to work in development.. My app works in development then I
tried to release but playstore rejected the app I had to remove the
permission on the manifest files then re-upload the app without the
permissions once its approved then I will be able to apply for the approval
then re upload an update with the permissions
Just what I feared... then, I have absolutely no idea about why it's not
working. The setup is pretty straightforward... so I doubt anything is
missing... the requestAuthorization shouldn't return false :(
—
Reply to this email directly, view it on GitHub
<#959 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5DVXR6QP3HDGZ6SZ4AEQZTZESQRZAVCNFSM6AAAAABH2SKEFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGU3DSNZSGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi again @larrytamnjong and thanks a lot for you help. My whole manifest is attached to the opening post and the code I'm using is just the example code provided here: https://pub.dev/packages/health/example I'm just navigating from one of my app's views, through a simple button, to a view that contains the exact code of the example. I wasn't even trying it to customize it yet, for now, just wanted to check if it worked "out of the box", but unfortunately, it seems it didn't. |
Ohh from your image it seems your running the app on an emulator you need
to run it on a real device or have you tested running it on a real device
already?
…On Tue, May 28, 2024, 17:04 CarlosCabarcos ***@***.***> wrote:
Hi again @larrytamnjong <https://github.com/larrytamnjong> and thanks a
lot for you help.
My whole manifest is attached to the opening post and the code I'm using
is just the example code provided here:
https://pub.dev/packages/health/example
I'm just navigating from one of my app's views, through a simple button,
to a view that contains the exact code of the example.
When I press "Authenticate" in the button from the demo. It just doesn't
do it.
I wasn't even try it to customize it yet, for now, just wanted to check if
it worked "out of the box", but unfortunately, it seems it didn't.
—
Reply to this email directly, view it on GitHub
<#959 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5DVXRYRKTPMEZ3EGZ4EYZTZESTHLAVCNFSM6AAAAABH2SKEFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGYYTIOBXHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I've tried both on an emulator and on a physical device (Xiaomi 11 Lite 5G, Android 14). Unfortunately, I'm getting exactly the same result. |
On Android 14 some special steps need to be done.. if you review the
documentation on pub.dev you'll find that
Android 14 #
This plugin uses the new registerForActivityResult when requesting
permissions from Health Connect. In order for that to work, the Main app's
activity should extend FlutterFragmentActivity instead of FlutterActivity.
This adjustment allows casting from Activity to ComponentActivity for
accessing registerForActivityResult.
In your MainActivity.kt file, update the MainActivity class so that it
extends FlutterFragmentActivity instead of the default FlutterActivity:
...
import io.flutter.embedding.android.FlutterFragmentActivity
...
class MainActivity: FlutterFragmentActivity() {
...
}
On Tue, May 28, 2024, 5:20 PM CarlosCabarcos ***@***.***>
wrote:
… Ohh from your image it seems your running the app on an emulator you need
to run it on a real device or have you tested running it on a real device
already?
… <#m_6301888796331116641_>
On Tue, May 28, 2024, 17:04 CarlosCabarcos *@*.*> wrote: Hi again
@larrytamnjong <https://github.com/larrytamnjong>
https://github.com/larrytamnjong <https://github.com/larrytamnjong> and
thanks a lot for you help. My whole manifest is attached to the opening
post and the code I'm using is just the example code provided here:
https://pub.dev/packages/health/example
<https://pub.dev/packages/health/example> I'm just navigating from one of
my app's views, through a simple button, to a view that contains the exact
code of the example. When I press "Authenticate" in the button from the
demo. It just doesn't do it. I wasn't even try it to customize it yet, for
now, just wanted to check if it worked "out of the box", but unfortunately,
it seems it didn't. — Reply to this email directly, view it on GitHub <#959
(comment)
<#959 (comment)>>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/A5DVXRYRKTPMEZ3EGZ4EYZTZESTHLAVCNFSM6AAAAABH2SKEFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGYYTIOBXHA
<https://github.com/notifications/unsubscribe-auth/A5DVXRYRKTPMEZ3EGZ4EYZTZESTHLAVCNFSM6AAAAABH2SKEFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGYYTIOBXHA>
. You are receiving this because you were mentioned.Message ID: @.*>
I've tried both on an emulator and on a physical device (Xiaomi 11 Lite
5G, Android 14). Unfortunately, I'm getting exactly the same result.
—
Reply to this email directly, view it on GitHub
<#959 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5DVXRYMCOLV4XLLBDZ3BYLZESVDNAVCNFSM6AAAAABH2SKEFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGY2TINJSHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi again @larrytamnjong. Yeah, I had done that too. As far as I know, I followed every step mentioned in the instructions. My MainActivity looks like this:
|
Guys for me, it didn't work until i get reply from google about form you mentioned earlierer, i had to follow their instructions (they sent me an email), and comply with everything they asked for, only after that they said that it should work i was able to do -> |
Hi @AdamBrejcak, thanks for the update. Ok, so according to what @larrytamnjong said and what you're saying now, it seems for some unknown reason it's not working the same way for everyone. That's so weird... however, I am hoping it's good news for me and it will start working as soon as Google accepts my request... If I manage to get it to work or I get the reply from Google and later it works, I'll update this post to let everyone know. |
@CarlosCabarcos sure hopefully it will work for you, if you any question or need help feel free to reach out to me :) |
Hi. I was able to get mine to return true but the health data just keeps up coming empty:
|
okay so if your await Health().requestAuthorization(types, permissions: permissions); return true, and you have Google Health Connect installed (for me whole process works fine on emulator), i would suggest to simplify things for testing if everything is okay, try following:
and main logic for my code is like this
of course i got everything in AndroidManifest.xml as describe in package documentation, if you got still issue its good idea to check Google Health Connect and maybe share a screen if your app and google fit is there as allowed apps the code above works for me just fine, hope it will help you |
Remember to specify the plugin name in the title!
Device / Emulator and OS
Please complete the following information for each phone and/or emulator you're experiencing this bug on:
NB: Bugs pertaining to old devices/OS versions will likely not be fixed.
Describe the bug
After doing the setup as indicated in readme at https://pub.dev/packages/health, I have added a new view to my App including the code from the demo. It seems to run just fine, however, when I try to "Authenticate" I am getting: "Access Denied (to Health Connect)!"
The "Health().requestAuthorization" call is always coming back false. I've tried with many types at once or just a single one and with READ or READ/WRITE permissions. The result is always the same: false.
The demo error pre-configured messages suggest I should check the permissions and services added to my manifest file, which I have done many times, but cant' see anything wrong.
To Reproduce
Add plugin to project, add demo scene to a new view, try to Authenticate.
Expected behavior
Should return "true".
Actual behavior
Returns "false".
This is my manifest. I added every single permission just in case.
Screenshots
This is the result of pressing the "Authenticate" button:
Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Versi¢n 10.0.19045.4412], locale es-ES)
! The flutter binary is not on your path. Consider adding C:\Users\myuser\fvm\versions\3.19.2\bin to your path.
! Warning:
dart
on your path resolves to C:\tools\dart-sdk\bin\dart.exe, which is not inside your current Flutter SDK checkout at C:\Users\louen\fvm\versions\3.19.2. Consider adding C:\Users\myuser\fvm\versions\3.19.2\bin to the front of your path.
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2021.3)
[√] Connected device (4 available)
[√] Network resources
Additional information
Add any other info about the problem here.
The text was updated successfully, but these errors were encountered: