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
- First i check if i have already the permission
- If not i request it
- if the request is successfull i do the work normaly
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); }