[TIMOB-20320] Android: Provide generic requestPermission(s) method
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-04-19T02:39:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.4.0, Release 5.3.2 |
Components | Android |
Labels | permissions |
Reporter | Fokke Zandbergen |
Assignee | Hieu Pham |
Created | 2016-02-03T17:22:12.000+0000 |
Updated | 2016-07-04T08:33:29.000+0000 |
Description
We need a generic method to request permissions that our own APIs do not use.
I know we've discussed this and thought this was best to leave this to the modules that require them, but there are multiple reasons for having a generic one instead:
* So that module doesn't come up with different ways (method name, method arguments, callback/event response and payload)
* So that developers don't need to rely on maintainers of 3rd party modules to update their modules to support Android 6.0 runtime permissions
Also see the discussion in TIMOB-20144
/cc [~titanium@webmasterei-hamburg.de]
+1 (for i.e. titutorial.audiorecorder)
I think the best way is to make a PR for TiBaseActivity for extending perfmissions.
We could integrate this module: https://github.com/stgrosshh/tipermissions
@fokke Currently we (Stefan and me) test and improve the module. Though the coder needs a special titanium.jar in his SDK5.2.0.GA. This jar contains the PR and can find here: https://github.com/AppWerft/Tierstimmenarchiv/blob/master/modules/android/titanium.jar screenshot: !http://i.imgur.com/LUPmlPN.jpg!
So it requires a change in the Titanium SDK. Could you open up the source for that change as well?
https://github.com/appcelerator/titanium_mobile/pull/7778
Hi We are working to support permissions in our Android 6.0 support for our client as we speak, do you know when this will be available in the nightly builds? It seems you are working actively on it right now? And it is so much easier for us to use your nightly build than to patch the SDK our selves.. Thanks
[~buder], the PR is not merged,but the Android team is currently reviewing it. As there are many other features and issues to take care about, we cannot provide a concrete timeline for now, but will keep this ticket updated.
@jörgen for quick solution I can send you the new android.jar for copying into android folder of your 5.2.0.GA folder.
or maybe you need better transfer ? Drop box?
You find it here: https://github.com/AppWerft/Tierstimmenarchiv/tree/master/modules/android You email doesn't work.
Thank you so much..
[~morahman] just came up with another important use case for such a generic method. On Android, it would allow developers to ask for all permissions the app needs at once.
With the new module you can requests all permissions in one dialog. First parameter is array of permissions. Android6.0 has a bug: although permissions are confirmed the dialog appears. In Android 6.0.1 it is fixed. As workaround we suggest a JS-module ti.permissions: https://github.com/AppWerft/Tierstimmenarchiv/blob/master/Resources/vendor/permissions.js
refactored PR: https://github.com/appcelerator/titanium_mobile/pull/7948
[~hpham] could you add a sample of how this would work for the developer?
Yes, in most cases (compatibility with iOS and bug in A6.0.0) you need this JS-wrapper:
Now you can use in app:
The formatter makes trouble or I don't know how.
[~titanium@webmasterei-hamburg.de] thanks but I meant how the builtin support [~hpham] is adding will be used.
Link to PR again: https://github.com/appcelerator/titanium_mobile/pull/7948 Implemented 2 new methods hasPermission() and requestPermissions(). (please read documentation in the PR for usage). Sample usage code:
We could also use this library: https://github.com/00ec454/Ask
I'm generally not in favour of adding in an external library if possible to reduce the complexity of dependencies if this can be done without an external library.
Agree
Verified the implementation of the 2 methods
hasPermission()
&requestPermissions()
. According to docs in the PR, permissions should be included in the android manifest for the successful granting of the required permissions. Closing. Environment: Appc Studio : 4.6.0.201605201934 Ti SDK : 5.4.0.v20160608165242 Ti CLI : 5.0.8 Alloy : 1.8.7 MAC El Capitan : 10.11.4 Appc NPM : 4.2.7-2 Appc CLI : 5.4.0-15 Node: 4.4.4 Nexus 6 - Android 6.0.0Environment: Titanium SDK 5.4.0.v20160703211246 OSX Nexus 7 2013 - Android 6.0.1
[~ptquang86] What do you mean by being unable to click the Allow Button? Do you have a screenshot?
I mean the button Allow is freeze, not click able https://goo.gl/photos/vpsDg7HagD4KGNZKA It works on Genymotion
Thanks for the photo. Based on the information, I do not think there is any bug or fault in the Titanium SDK. What's being done is simply calling the native Android method to bring up that requestPermission dialog. Nothing special is being done. Could it be that the device has some issues? Do other apps that require permission also have that button frozen? This seems very odd.
@ashraf You are right. This is not in relation to Titanium. The module only opens a "native" system dialog. Maybe a problem with Genymotion. I'm only work on devices and never seen this issue.
yes, this is an issue of my device. I tested with facebook and this happened. thank you :)
[~ptquang86] (y) Thanks [~titanium@webmasterei-hamburg.de]