Thanks for the reply Rob… but I’m still struggling with this. I can’t get my device to recognize the native.showPopup function for “Storage” at all. It simply acts as though that code isn’t even there.
I’m getting a popup message that looks like it is Android reacting to my build.settings permissions (see attached image). What I need to do is control this message by editing it or placing my own popup message prior to this one.
Below is the latest iteration of my code… I threw in some Alert Popups for testing to tell me on the device what is happening. In the simulator, it works fine as if permissions had already been granted in the past… this includes the Alert. I can’t get this behavior on my device, however, even after clicking Allow on the attached image. Also, closing the app and opening again only gives me a black screen… not even an Alert comes on screen.
I truly appreciate any help…
local function canUseStorage() -- Ensure that we have permission to use external storage. local grantedPermissions = system.getInfo("grantedAppPermissions") if ( grantedPermissions ) then if ( not isValueInTable( grantedPermissions, "Storage" ) ) then print( "Lacking storage permission!" ) return false end end return true end local function permissionsListener( event ) -- Print out granted/denied permissions. print( "permissionsListener( " .. json.prettify( event or {} ) .. " )" ) -- Check again for storage access. -- Note that we use our helper function, canUseStorage(), as the -- permissions listed in the event are ONLY for what has been just denied -- or granted. if ( canUseStorage() ) then --Permission has been granted local function onComplete(event) goToGame() end local alert = native.showAlert( "Zantics Racing", "Permission Granted to Storage, Activate Game.", { "OK" }, onComplete ) else -- The user hasn't given us the required permissions. native.showAlert( "Corona", "Required permissions not granted... give user chance to accept again.", { "OK" } ) end end -- We can't assume that the user has given us permission to use storage. -- Get access to Storage! if ( canUseStorage() ) then -- If we have access to the storage, activate game. print( "Calling to activate game!" ) local function onComplete(event) goToGame() end local alert = native.showAlert( "Zantics Racing", "We have access to Storage, Activate Game.", { "OK" }, onComplete ) else -- If we don't have access to storage, request permission to use it, if we can. if ( native.canShowPopup( "requestAppPermission" ) ) then local permissionsToRequest = { "Storage" } local rationaleTitleMessage = "Zantics Racing needs permissions!" local rationaleMessage = "Zantics Racing needs Storage permission to save data and progress through the game." -- Make the actual request from the user. native.showPopup( "requestAppPermission", { appPermission = permissionsToRequest, urgency = "Normal", rationaleTitle = rationaleTitleMessage, rationaleDescription = rationaleMessage, listener = permissionsListener, } ) else -- We can't ask for permission to use storage. -- Tell the user to enable it in Settings. native.showAlert( "Zantics Racing", "Permission to use your Device Storage cannot be requested. Please go to Settings and grant this app access.", { "OK" } ) end end