-
Notifications
You must be signed in to change notification settings - Fork 68
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
requestPermissions always return true [iOS] #50
Comments
TLDR: Unfortunately this is the default behaviour from iOS, check workaround. Apple restricts basically every permission authorization in a similar way. The first time you call the method you will receive Basically every iOS app developer (no matter Swift/ObjC or React Native) faces that issue, but it's Apple's way to restrict this popup screen you have on the screenshot. WorkaroundI'm currently using this flow and it's basically what everyone does in a way.
const hasBeenAsked = await Fitness.isAuthorized(permissions)
if (! hasBeenAsked) {
await Fitness.requestPermissions(permissions)
}
const stepsYesterday = await Fitness.getSteps({
startDate: moment().subtract(1, 'day').format(),
endDate: moment().format(),
}) If you couldn't get dataif (stepsYesterday.length === 0) {
...
} This implicates some issue, it might be user has no data for that period, or has not shared permissions with your app. At this point, most apps show a popup alert or a styled modal window instructing the user what to do. Which is:
Side note: For me this doesn't work on a simulator, getting constant spinning loader in Apps screen. If you could get dataAll is good, no need to worry. Closing thoughtsDealing with this is a small pain for the developer, but big pain for the user. Unfortunately I didn't find a better workaround and I'm not sure there is another one. What can I suggest is that you perform that check on every app start and/or state change (when app goes to background and then active again), because the users can disable this the same way you told them to enable it. Also, you can take a look and inspiration from other fitness apps and how they handle this kind of situation. Hope this helps! |
@dmitov Thanks for your help! I think that is the only way to check permission on iOS! |
When I'm tried using
![Screen Shot 2020-04-12 at 4 20 06 PM](https://user-images.githubusercontent.com/20647079/79065299-80456380-7cd9-11ea-8ffd-a71d156492a4.png)
requestPermissions
on iOS I'm getting issue it's always return true. When the user clickDon't Allow
it shows up an alert like this and then returntrue
. After that, I tried using functionisAuthorized
and it always returnstrue
.Anyone can help me resolve this issue?
The text was updated successfully, but these errors were encountered: