0

i have a probleme in android.permission.READ_PHONE_STATE i deploy my project to samsung galaxy S6 i use this code to request the READ_PHONE_STATE permission but it's not working ,i use the ti.permissions module .

in my tiapp.xml i added

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

but it's not working because im using an android 6.0

  1. First i check if i have already the permission
  2. If not i request it
  3. if the request is successfull i do the work normaly
  4. if not i just alert an error (for now )

        var imeimodule=require("com.imei");
                var imei;
             var permissions = require("ti.permissions");
    
    try {
    
              if (  !permissions.hasPermission('android.permission.READ_PHONE_STATE'))
              {
                    alert('here');
    
        permissions.requestPermissions(['android.permission.READ_PHONE_STATE'],function(e) { 
            if (e.success != 0)
            {    
                 Ti.API.debug("Permissions OK");
                 imei = imeimodule.example(); 
                 Ti.App.Properties.setString('EMEI',imei);
             }
            else
            {
                Ti.API.warn("Permissions denied"); 
            }
        });
    
             }
              else alert ('ok cool');
    

    }

    catch (e){ alert(e.message); }

ouqas mohamed
  • 41
  • 1
  • 9
  • Really need to provide more details. 'Not working' isn't helpful enough. Are you getting an error, what is the error, is it simply failing with no error? – Ray Jul 19 '16 at 20:34
  • as you can see the 'here' alert is shown , and in the 'if e.seccess !=0' i wrote an alert and in 'else' i did another alert but neither are shown , so imei = imeimodule.example(); is not executed and my app depends on this 'imei' – ouqas mohamed Jul 20 '16 at 08:52

1 Answers1

0

you can try this module https://github.com/gimdongwoo/Ti-Android-RequestStoragePermission use it after window open

  • I dont have a probleme with the Storage permission , i have a problème with the " READ_PHONE_STATE " , are they the same ? – ouqas mohamed Jul 22 '16 at 08:56