-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
requestAndCheckMotionAuthorization doesn't respond on second use #197
Comments
In short: yes I can reproduce it but I think there's nothing that can be done about it. It's a limitation due to the way iOS handles the motion permission (which is differently than all the other permissions). There is no direct iOS API to request/check for this permission, so it must be done indirectly: motion permission is requested by requesting activity updates and the current motion authorization status is queried by querying pedometer data. Like many iOS permissions, if the user denies permission when the dialog is shown, the app cannot request that permission again - subsequent calls will have no effect. This is intended behaviour by Apple, the rationale being that the user intended to deny permission and therefore the app shouldn't be allowed to bother the user again with more requests for a permission they chose to deny. The permission request fails silently so it's not even possible for the plugin to tell if the dialog was successfully displayed or not - it can only tell that the dialog was successfully requested. If you press deny in the permission dialog, the next time that In the case of motion permission, this is compounded by the fact that both requesting and checking are carried out in one operation, therefore if the user denies permission, not only will the permission dialog not be shown again when requested, but plugin is also unable to check the current status. |
@HuaHub Do you have access to an iPhone 6/6s/7 to test on? I have a problem testing the checking of the pedometer API because it requires a specific chipset only present on the iPhone 6 or above. It cannot be tested in the Simulator and I have only an iPhone 5C and an iPad Air 2 (which do not have the required chipset). If so, I will create a branch which contains version of the plugin which exposes the check for motion authorization (using pedometer API) without first requesting motion permission (using motion manager API), i.e. This won't directly solve your problem - |
Yes, I understand that Apple won't allow you to ask for the permission twice if the user has denied the request. As you mentioned, I would only like to check the current status of what the user has replied. I do not currently have an iPhone 6 to test on, maybe someone else does? |
I've done some more looking into this: Firstly, just to clarify. the motion tracking authorization status is available to any iOS device which supports Pedometer Event Tracking: that is iPhone 5s or above (but not any iPad). I've created a new version of the plugin (3.6.0) on the dev branch which separates requesting and checking of motion tracking authorization. This version adds a new getMotionAuthorizationStatus() to explicitly check the status without requesting it. There's a corresponding dev branch of the example project which supports the new plugin API. Note that I'm still unable to fully test this as I have an iPhone 5C, but an iPhone 5S or above is required to test the functionality which requires Pedometer Event Tracking, so if anyone has such as device, I'd appreciate if you could checkout the dev branch of the example project and build it: to do this, once you've cloned the project, add the iOS platform ( What I'd specifically like to test is if the first time you request motion access you press "Deny", that the plugin is able to detect this: the motion authorization status should be displayed as "DENIED". And subsequent calls to |
Hi again Dave, Thank you for the great work with seperating getMotionAuthorizationStatus() and requesting permission for it. Do you still need to test it on an iPhone 6? I have one available now. If not, can you make a release, or is it possible to use the dev version as plugin (if yes, how?). By the way: |
Thanks for the info, no that's not the result I was expecting. I'm trying to get my hands on an iPhone 6 for testing this myself - ideally what I need to do is connect it up to XCode and run through the Objective-C with the step-through debugger to see exactly what's going on.
In the meantime, you can install the dev version directly from the git repo:
|
Thanks, please let me now when you have tested it! |
I just installed the plugin from the dev branch, the new function getMotionAuthorizationStatus() returns that "Pedometer tracking not available on this device", even though I have an iPhone 6. Is this a bug or do I have to allow Pedometer usage or something? |
I still haven't managed to get hold of an iPhone 6 to test this. getMotionAuthorizationStatus() calls checkMotionAuthorization() which in turn calls isMotionAuthorizationStatusAvailable() which returns true if the iOS API indicates pedometer tracking is available. The message that you're getting is motionAuthorizationStatusUnavailableMessage, which is returned if isMotionAuthorizationStatusAvailable returns false. What this suggest to me is that the pedometer event tracking API cannot be queried until motion tracking authorization has been granted. Could you confirm this for me by doing the following:
|
Hi guys, Just hit the same issue as @HuaHub, and I have an iPhone 6S and 5c available for tests :-) I just installed dev branch locally (more precisely, commit 96326ae) and made some iPhone 6S tests (see test scenario below) on a completely fresh app (I mean, without having provided any permission at the beginning of the test scenario). As far as I understood :
Here are the detailed scenario. I tried to provide as much informations as possible ... but tell me if you're missing something and I'll try to help as best as I can. Scenario 1 : calling getMotionAuthorizationStatus() first and multiple times after REFUSAL
XCode console output :
Scenario 2 : calling requestMotionAuthorization() first and multiple times after REFUSAL
XCode console output :
Scenario 3 : calling getMotionAuthorizationStatus() first and multiple times after ACCEPTANCE
XCode console output :
Scenario 4 : calling requestMotionAuthorization() first and multiple times after ACCEPTANCE
XCode console output :
Regards, |
Any luck? |
Note the commits related to separation of checking and requesting motion tracking authorization have been moved from the |
@fcamblor Apologies in delay in replying and thanks for the comprehensive feedback.
Yes, looks like you are correct. Since I haven't had an iPhone 6+ to actually test with, I hadn't noticed, but it seems I accidentally passed the string "status" instead of the variable status as the return value here. I'll push a commit to fix this. Will also review your other feedback ASAP. |
Do you mean by "user request" that calling Just to recap, on the master branch of this plugin, requestAndCheckMotionAuthorization() both requests and checks motion authorization at the same time. The motion_rework branch attempts to separate the requesting and checking, however if calling |
+1 |
Yep that's what I noted, see start of Scenario 1 :
I tried to integrate your latest commit (506f670) on my project and I noted that compared to 96326ae, calling |
Executed same scenario as before again, with the new 506f670 commit Scenario 1 : calling getMotionAuthorizationStatus() first and multiple times after REFUSAL
Some conclusions after this scenario :
Scenario 2 : calling requestMotionAuthorization() first and multiple times after REFUSAL
No new conclusions than previously here :
Scenario 3 : calling getMotionAuthorizationStatus() first and multiple times after ACCEPTANCE
Everything sounds OK here Scenario 4 : calling requestMotionAuthorization() first and multiple times after ACCEPTANCE
Here again, everything sounds OK |
@fcamblor Really appreciate your testing this and being so detailed in your results.
This is the deal breaker: it means that calling queryPedometerDataFromDate prompts for authorization the same as calling startActivityUpdatesToQueue. It means there's no native way (at least that I know of) to query the authorization status without first requesting authorization (i.e. you cannot check if NOT_REQUESTED vs GRANTED/DENIED). It is of course possible to detect GRANTED vs DENIED after authorization has been intially requested (e.g. the user changes permission to DENIED in Settings or denies in permission request dialog). This is what requestAndCheckMotionAuthorization() on the master branch is currently doing. One possibility would be for the plugin to store its own internal persistent flag which indicates whether
Does that make sense? |
Yep, at least the "least worst option" to my POV :-) I'd maybe change your snippet to
BTW, another important issue in my tests are the returned status doesn't seem accurate (today, |
Moreover, I'm not sure if this is the topic here (or if I should file a dedicated issue for this), but on version
The only workaround would be to put a timeout to effectively resolve (or reject) a promise wrapper around |
A bit premature... |
@fcamblor I think I've finally sorted this out. Please try the version on the dev branch:
I've updated the dev branch of the example project to test/validate the plugin implementation and it's looking good to me:
|
Cool ! Will have a look at it today, will give you my feedback :) |
Just made my tests... it seems OK to me, this is a nice work @dpa99c 👍 Scenario 1 : calling getMotionAuthorizationStatus/requestMotionAuthorization() first and multiple times after REFUSAL
Which completly OK for me :) Scenario 2 : calling getMotionAuthorizationStatus/requestMotionAuthorization() first and multiple times after ACCEPTANCE
Here again, sounds OK. To me, actual |
@fcamblor Thanks for getting back so quickly. OK, I'm going to move ahead and publish it as v3.7.0 to npm. If any bugs do should up, let me know and I'll push out a 3.7.1 patch release. |
OK, published as |
Thanks for the quick release (and the hard work) :-) |
@dpa99c Just hit an edge case we didn't discussed earlier I guess. In the In my previous scenario, I always covered the "per app" permission case (when I was "denying" the permission, it was impacted on the "per app" level) Now, if I take a "globally DENIED" Motion & Fitness permission, I mean : Then, in that case :
It seems legit, however, no prompt has been shown to the user at any step of code above, while My concern is : I'm wondering if there shouldn't be a dedicated
However, this code will encourage calling not sure if I'm 100% clear here, don't hesitate to ask for precisions |
The problem here is that Apple has not given us sufficient tools to do the job. There's no way to tell if, after calling
I'm also not sure how much of an edge case this is, i.e. how many iOS users actually keep the global Fitness Tracking switch off. Anyway, the solution will be to allow an extra parameter to be passed to
I'll publish a patch version with this shortly. However, I also recommend if permission is
|
Hi, requestAndCheckMotionAuthorization doesn't seem to give any response the second time it is called. Are you able to reproduce?
Cordova 6.5.0
Platform iOS 4.3.1
iOS 10.3
The text was updated successfully, but these errors were encountered: