[TIMOB-20144] Android 6.0: allow native modules to get notified about runtime permission granting results
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2016-04-21T04:33:14.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | android |
Reporter | Olivier Morandi |
Assignee | Eric Merriman |
Created | 2015-12-14T15:26:42.000+0000 |
Updated | 2017-03-22T20:49:40.000+0000 |
Description
With the new Android 6 permissions mechanism, native modules should be able to request runtime permissions outside of the ones exposed by the Ti API (camera, calendar, location and contacts). For example, a native module for sending SMS messages would need to request the SEND_SMS permission at runtime, however it would have no means to get notified about the result of the operation.
I would propose to extend the TiBaseActivity class with a mechanism allowing native modules to register a listener, in order to be notified when the onRequestPermissionsResult method of the current activity is called (see https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java#L447)
Maybe we can think of a way which would also allow us to dump the
createActivityWorker()
we currently [require for our Android FB module](https://github.com/appcelerator-modules/ti.facebook#proxy-required-per-android-activity) as well? Since I think both our related to being able to hook into the current activity?[~cng] related to TIMOB-20235, I thought we also had a ticket requesting a generic method (
Ti.Android.requestPermission
) to request any permission that we resolved as _Invalid_ / _Won't Fix_ because we thought any module that needed additional permission should provide ways to request this via the module, which is what this ticket is about. Anyway, I think it might be better to have that generic method after all. That way, modules only need to list what permission you should request and we won't end up with modules that have different method names/ways to request these. Also, you would prevent situations where 2 modules overlap in the permissions they need and if they don't properly handle the case where only some of the permissions were already granted (which we had ourselves with camera on android) it can get ugly. What do you think?I've created TIMOB-20320 to request a generic method.
I resolved this as duplicate as TIMOB-20320 has addressed this.
Closing ticket as duplicate of the ticket that is mentioned above and has since been closed.