Miro
Miro

Reputation: 5337

HealthKit requestAuthorizationToShareTypes once per day?

I was attempting to use apple's HealthKit authorization modal in my App's settings, to allow a user to toggle their info on/off for sharing. It automatically pops up the authorization screen. However it seems to only do it once and then never again. At least until 24 hours later maybe, where it will prompt again if needed.

Is this meant to be used similarly to PushMessage requests, where a user is prompted once and then not ever prompted again from the same request?

I'm skeptical to add this modal prompt in the App's initial load as it is quite intrusive as a full screen modal; even if called only once ever.

Upvotes: 0

Views: 1321

Answers (2)

mskw
mskw

Reputation: 10358

A trick to use is to modify the Share/write types in your authorization, this will require the user to look at it again, thus pop it up every time.

Upvotes: 1

goldengil
goldengil

Reputation: 1037

Basically the user suppose to see it once (as when asking to grant push notification permissions, or access to contacts).

I have found out that for each datatype you want to share with Health app (or read), you got one shot with the modal prompt. This prompt might be a bit tedious to the user as it shows the entire types your app ask for permissions (both read and write), and I assume this is why Apple said a best practice of HealthKit is to ask the entire permissions your app need at the same time (though some might argue with that in a matter of UX).

If you wish to ignore Apple suggestions of this best practice, you can ask for read/write permissions for each datatype separately - Doing so will result prompting that modal sheet each time you ask the permissions to a different type.

In the bottom line, this permissions sheet is meant (by Apple) to be shown to the user once. You can find a way to pass that limitation (yet for a limit amount of times - depends on the amount of datatypes available), but I won't recommend bypassing Apple's guidelines (it is never a good idea).

Upvotes: 4

Related Questions