Could any of you tell me what is wrong with my code?
When users first start the App it shows the “Ask For Permission” - working okay…
If they allow the permission and are connected, it downloads some resources - working okay…
If they deny, it shows a message saying they should restart the App and allow the “Write External Storage” permission in order to download the resources.
But when they do so it shows my “Denying Message” once again, telling them to restart the app…
When they restart the App once again it finally downloads the resources. I don’t want them to restart the app once again…
It is because you have directly set the blocks for download even if the permission is denied, so according to your blocks even if permission is denied it will try to download and since permission is denied and still it is trying to download it asks to restart, so you néed to change your code, use the when permission granted event and under it place the blocks to download whatever you want
I was doing this way at first and it works almost fine, but if the users allow the permission when disconnected, they won’t be able to download it again when they restart the App connected. (I was not having this specific problem when my blocks were the other way around…)
Use a tinydb component, when screen permission granted store a value 1 in any of the tag of tinydb, and in screen initialize add a logic if network is connected and tinydb tag value = 1, download
What am I doing wrong this time, since nothing happens after granting the permission?
I tested clicking on “Deny Permission”, it starts downloading and stays downloading forever…
I closed the App and restarted it, I chose “Allow Permission” and it shows my Deny Message but starts Downloading…
I guess I’ll have to create a button in my sidebar for users to click and download the resources… That should be an easier solution, but I woudn’t be learning nothing from it all…
@Daniel_Miranda
You are doing just one thing wrong that is you have put your blocks that checks tinydb value is granted/true in screen initializing while you have to move all blocks from screen initializing to if permission granted except ask permission block then it will work definitely
But download still does not start after allowing the permission… When I restart the App another problem comes up: My AdMob and my Get Column stop working, my images from Airtable does not load… So I noticed that I can’t put those blocks on “When permission granted” event… and if I put the download blocks in the “When permission granted” event and users allow permission with no Internet, they won’t be able to download even if they restart the app as well…
Ok now do one more thing in your screen initializing use a if then condition check if tinydb value = “GRANTED” then copy all blocks from permission granted except tinydb store Value and paste inside it and else ask for permission then it should work try it and don’t remove the blocks from if permission granted
When I allow permission it does nothing at first, it does not start my Download.
When I restart the App the Download starts normally…
If I deny the permission, the custom choose dialog does not show.
I restarted the App to see what happens: It asks for permission once again, but if I choose to allow it, the Download still does not start at first, it starts only when I restart the App for a second time.
If I allow permission when not connected and return to the App when connected, it works pretty fine. Download starts normally and get completed…
What should I do?
I’ll try to use an “if else” condition to show a message that they must be connected next time they start the App, so download may start.
If it works I’ll mark @hammerhai answer as a solution.
Edit: Everything is working fine now. Thank you so much, @hammerhai and all the others who tried to help me somehow. I’m really pleased for your help guys.