Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5216] Ti.Android.requestPermissions callback not firing when first requesting permissions

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2017-10-25T22:50:00.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
Reportereric harms
AssigneeYordan Banev
Created2017-09-20T22:00:38.000+0000
Updated2018-07-18T07:34:55.000+0000

Description

Hi, Having a strange issue requesting permissions with Android. Running the following code on first run will not show the SUCCESS log, the callback does not fire. But once the permissions are set and the app is closed and re-opened, the code runs as expected.
var permissions = ['android.permission.CAMERA', 'android.permission.READ_EXTERNAL_STORAGE'];
Ti.Android.requestPermissions(permissions, function(e) {
    if (e.success) {
        Ti.API.info("SUCCESS");
    } else {
        Ti.API.info("ERROR: " + e.error);
    }
});
This is right out of the documentation here http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android Please advise if I am doing something wrong here. Thanks

Comments

  1. Yordan Banev 2017-09-21

    Make sure you have:
       <android xmlns:android="http://schemas.android.com/apk/res/android">
           <manifest>
               <uses-permission android:name="android.permission.CAMERA" />
               <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />	
           </manifest>
       </android>
       
    in your tiapp.xml file. I was not able to reproduce the issue on any version from 6.0.1.GA to 6.2.0.GA on Android 7 device, having these lines added.
  2. Sharif AbuDarda 2017-10-22

    Hello [~eric.harms@gmail.com], did you tried [~ybanev], guide?
  3. Jordan Silva 2018-07-17

    Hi @Sharif AbuDarda and @Yordan Banev, I'm facing a similar problem. When I'm trying to requestCalendarPermissions and the user on Android haven't given the permission, the callback is not being fired. Steps: a. The user doesn't have allowed the access to the calendar for the app. (i.e., calendar permission); b. The Calendar Permission is requested through the Ti.Calendar.requestCalendarPermission(callback); c. The user accepts or denies the permission. d. The event callback is not fired to inform if the user has accepted or not. :(
  4. Jordan Silva 2018-07-18

    Please ignore my previous comment. I found the bug, was something related to the showing a window (like a dialog) before requesting the permissions, so the request dialog was not being fired.

JSON Source