Hi everybody.
Currently, we are working on an application and facing some critical permissions issues which prevent application to work because some of them are “must have”, due to the application content. To be more precise, we ask user for the permissions in the code below:
usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.VIBRATE", "android.permission.CAMERA", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.ACCESS\_COARSE\_LOCATION", },
Application is 99% done and we are in the beta testing phase and our testers, just as we have, run into next problem:
- popup screen for granting permission fails to show. Let me explain. In some caises, there’s no problem and everything works just fine. On the other hand, app sometimes doesn’t require all permission we want (in most cases, it’s the location permission, or sometimes, the camera permission).
We tried all the things mentioned on Corona web pages, like the ones in the link bellow and it’s doesn’t seem to work at all.
https://coronalabs.com/blog/2016/02/23/breaking-change-android-6-and-device-ids/
We are currently checking if the permission is granted and based on the response trying to get it or continue to use the app and it also sometimes fails to do the job. Even though, for example, the location permission isn’t granted and we check on the app start before doing everything if it is, the permission popup fails to show. Based on the results from our beta testers we assume the problem isn’t affected by the Android version.
function hasLocationPermission() if system.getInfo( "environment" ) == "simulator" then return true else -- Check to see if the user has previouslly granted permissions local grantedPermissions = system.getInfo( "grantedAppPermissions" ) local hasLocationPermissionVar = false -- Check for the "Camera" group permission for i = 1,#grantedPermissions do --print (grantedPermissions[i]) if ( "Location" == grantedPermissions[i] ) then hasLocationPermissionVar = true break end end return hasLocationPermissionVar end end local function hasCameraPermission() -- Check to see if the user has previouslly granted permissions local grantedPermissions = system.getInfo( "grantedAppPermissions" ) local hasCameraPermissionVar = false -- Check for the "Camera" group permission for i = 1,#grantedPermissions do --print (grantedPermissions[i]) if ( "Camera" == grantedPermissions[i] ) then hasCameraPermissionVar = true break end end return hasCameraPermissionVar end function locationCheck() if ( system.getInfo( "platform" ) == "android" ) then print("lokacijalalalal") local locationPermissionGranted = hasLocationPermission() if not locationPermissionGranted then -- If phone permission is not yet granted, prompt for it local permissionMap = native.newMapView( Global.screenWidth + 2\*Global.visakX + 500, Global.screenHeight + 2\*Global.visakY + 500, 20, 20 ) if permissionMap then local currentLocation = permissionMap:getUserLocation() display.remove(permissionMap) permissionMap = nil --cameraCheck() checkForInternetOnStart() end else -- We already have the needed permission --cameraCheck() checkForInternetOnStart() return true end end end function cameraCheck() if ( system.getInfo( "platform" ) == "android" ) then local cameraPermissionGranted = hasCameraPermission() if not cameraPermissionGranted then -- If phone permission is not yet granted, prompt for it media.capturePhoto( { destination = { baseDir = system.DocumentsDirectory, filename = "req.jpg", type = "image" } } ) locationCheck() else locationCheck() -- We already have the needed permission end end end
We would appreciate some help since we’ve made 99% of the app and have no other idea how to solve the issue.
Thank you and best regards,
Luka and Marijan!