nativescript-community / perms

An unified permissions API for NativeScript on iOS and Android.
https://nativescript-community.github.io/perms/
Apache License 2.0
12 stars 9 forks source link

refusing motion perm on iOS causes error #17

Open jeremykanso opened 1 year ago

jeremykanso commented 1 year ago

Hello @farfromrefug

If you refuse a motion permission on iOS, you'll get an error from iOS: "Domain=CMErrorDomain Code=105"

Plus, you never return the status for requested motion perm on rejected.

Related code in the repo:

                    activityManager.queryActivityStartingFromDateToDateToQueueWithHandler(NSDate.distantPast, new Date(), motionActivityQueue, (activities, error) => {
                        if (error) {
                            reject(error);
                        }
                        ...
                        return getStatus();
farfromrefug commented 1 year ago

@jeremykanso thanks a lot for this! Will fix this as soon as I can

farfromrefug commented 1 year ago

@jeremykanso actually the whole code is correct. There was just an issue with a else missing. But it is correct to not return the status on error. We reject with the error, not with the status. It works the same with all permissions

jeremykanso commented 1 year ago

But you agree that we shouldn't get an error on refusing, right?

farfromrefug commented 1 year ago

@jeremykanso it depends on what the native behavior is. If you get that error it means the native side threw that error. Also depends on the flow