{ "id": "166679", "key": "AC-4864", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-03-27T18:39:16.000+0000", "created": "2017-03-20T14:24:41.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2018-03-06T07:47:55.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "Hello,\r\n\r\nWhen I use Ti.Geolocation.requestLocationPermissions the callback is not called at all on Android. I tried to put Ti.API.error or alert in it but nothing happened.\r\n\r\n{code:javascript}\r\nTi.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(e) {\r\n Ti.API.error('hello');\r\n Ti.API.error(JSON.stringify(e));\r\n });\r\n}}\r\n{code}\r\n\r\nI'm using SDK 6.0.2 and building on Android.", "attachment": [], "flagged": false, "summary": "Callback not called in requestLocationPermissions on Android", "creator": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "413671", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, AUTHORIZATION_ALWAYS is only for iOS and windows app. Not supported for Android. I can get the logs by the below code.\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n theme : \"Theme.AppCompat.Fullscreen\",\r\n backgroundColor : '#fff'\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n title : 'Pick',\r\n top : 50,\r\n});\r\nbtn.addEventListener('click', function() {\r\n Ti.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(e) {\r\n Ti.API.error('hello');\r\n Ti.API.error(JSON.stringify(e));\r\n });\r\n});\r\nwin.add(btn);\r\n\r\nwin.open();\r\n{code}\r\n\r\nLocation permissinon popup opens and allowing that gives this response.\r\n{code}\r\n[ERROR] : hello\r\n[ERROR] : {\"code\":0,\"success\":true}\r\n{code}\r\n\r\nOnce the permission is granted later try would not show the permission popup and the log for click on the button. You need to remove the permission from settings. There seems to be no issue here. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-03-20T15:49:19.000+0000", "updated": "2017-03-20T15:49:19.000+0000" }, { "id": "414180", "author": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "body": "In the docs I saw requestLocationPermissions was for Android too but didn't check the authorization type.\r\n\r\nSo I tried this: \r\n\r\n{noformat}\r\nTi.Android.requestPermissions([\"android.permission.ACCESS_FINE_LOCATION\"], function(e) {\r\nalert('hey');\r\nTi.API.error(JSON.stringify(e));\r\n});\r\n{noformat}\r\n\r\nAnd put into the manifest in the tiapp.xml. but still the callback is never called.\r\n\r\nAny idea why this isn't working ?", "updateAuthor": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T08:50:36.000+0000", "updated": "2017-03-21T08:51:52.000+0000" }, { "id": "414202", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Try this sample code as a workaround.\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\nvar locationPermission = \"android.permission.ACCESS_FINE_LOCATION\";\r\nvar hasLocationPermission = Ti.Android.hasPermission(locationPermission);\r\nvar permissionsToRequest = [];\r\n\r\nif (!hasLocationPermission) {\r\n permissionsToRequest.push(locationPermission);\r\n}\r\nif (permissionsToRequest.length > 0) {\r\n Ti.Android.requestPermissions(permissionsToRequest, function(e) {\r\n if (e.success) {\r\n Ti.API.info(\"SUCCESS\");\r\n win.open();\r\n } else {\r\n Ti.API.info(\"ERROR: \" + e.error);\r\n }\r\n });\r\n}\r\nif (hasLocationPermission) {\r\n win.open();\r\n}\r\n\r\n{code}\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-03-21T16:45:41.000+0000", "updated": "2017-03-21T16:45:41.000+0000" }, { "id": "414722", "author": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello,\r\n\r\nI tried that workaround but the callback isn't called.", "updateAuthor": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T10:56:52.000+0000", "updated": "2017-03-22T10:56:52.000+0000" }, { "id": "414732", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Send the full code you are testing. The code I sent is working perfectly. It shows the success log. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-03-22T13:09:17.000+0000", "updated": "2017-03-22T13:09:17.000+0000" }, { "id": "415258", "author": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I tried it in a new project.", "updateAuthor": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-23T08:23:20.000+0000", "updated": "2017-03-23T08:23:20.000+0000" }, { "id": "415347", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Are you using my code? use the below code\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n theme : \"Theme.AppCompat.Fullscreen\",\r\n backgroundColor : '#fff'\r\n});\r\n\r\nvar locationPermission = \"android.permission.ACCESS_FINE_LOCATION\";\r\nvar hasLocationPermission = Ti.Android.hasPermission(locationPermission);\r\n\r\nTi.Android.requestPermissions([\"android.permission.ACCESS_FINE_LOCATION\"], function(e) {\r\n\r\n if (e.success) {\r\n Ti.API.info(\"SUCCESS\");\r\n win.open();\r\n alert(\"SUCCESS\");\r\n\r\n } else {\r\n Ti.API.info(\"ERROR: \" + e.error);\r\n }\r\n});\r\nif (hasLocationPermission) {\r\n win.open();\r\n}\r\n{code}\r\n\r\nCallback only calls on first run on device. After you grant the access the callback calls and window opens. If you remove the permission from setting it should call again.\r\n\r\nMake sure you set \r\n{code}\r\n \r\n{code} in tiapp.xml. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-03-23T19:31:08.000+0000", "updated": "2017-03-23T19:53:26.000+0000" }, { "id": "415534", "author": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello,\r\n\r\nThis code works for me ! Thanks !", "updateAuthor": { "name": "debuisson.eugene", "key": "debuisson.eugene", "displayName": "Debuisson Eugène", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T13:35:19.000+0000", "updated": "2017-03-24T13:35:19.000+0000" }, { "id": "435227", "author": { "name": "mitulbhalia", "key": "mitulbhalia", "displayName": "Mitul Bhalia", "active": true, "timeZone": "Asia/Kolkata" }, "body": "The above code does not work for me with 6.0.2 and with 6.3.1 too.\r\n\r\nIt does not call success or error callback.\r\n\r\nCan somebody help me to sort this out?", "updateAuthor": { "name": "mitulbhalia", "key": "mitulbhalia", "displayName": "Mitul Bhalia", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2018-03-06T07:47:55.000+0000", "updated": "2018-03-06T07:47:55.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }