Home Kwiksher Forums Kwik4 A way to check Photo Library access?
Tagged: canvas, Photo Library
-
Yamamoto
KeymasterMarch 30, 2020 at 10:22 pm #85999An external code with media.hasSource() will work. I have not used it yet. Let’s see how it is. I will test it tomorrow.
https://docs.coronalabs.com/api/library/media/hasSource.html
Yamamoto
KeymasterApril 1, 2020 at 2:48 am #86003I added a permission check in components/pageXXX/page_screenshot.lua. You can download the following files from the github
https://github.com/kwiksher/kwik4tmplt/blob/master/components/pageXXX/page_screenshot.lua
https://github.com/kwiksher/kwik4tmplt/blob/master/commands/pageXXX/actionX_.luaPlease replace the files in tmplt folder.
otterslidestudio@aol.com
ParticipantApril 1, 2020 at 2:36 pm #86004I downloaded these files, but now my app is crashing with errors in random action files and cannot start.
-
This reply was modified 6 years, 6 months ago by
otterslidestudio@aol.com.
otterslidestudio@aol.com
ParticipantApril 1, 2020 at 3:21 pm #86006Nevermind. I was downloading from the links when I needed to go to github and copy the code.
otterslidestudio@aol.com
ParticipantApril 1, 2020 at 6:17 pm #86008I tested this and it works on the Windows simulator, but does not work on the Mac simulator or on the device. Both my Mac and my Ipad return the same “Saved” message instead of the customized “No permission”.
-
This reply was modified 6 years, 6 months ago by
otterslidestudio@aol.com.
Yamamoto
KeymasterApril 2, 2020 at 3:41 am #86011I debugged for an hour and you are right. the permission check is not working. In iOS/Mac does not return false with media.hasSource, even user denied the access.
https://docs.coronalabs.com/api/library/media/hasSource.html
Maybe I am missing something, I will try tomorrow again. It is an issue of media.hasSource()
Yamamoto
KeymasterApril 2, 2020 at 6:50 am #86012The first time you run an app after a fresh install, media.hasSource( media.PhotoLibrary ) would always return true. This is by design as iOS permissions have a “not determined” state that they’re initialized to when an app is run the first time.
By returning true that first time, your Lua app could continue to whatever behavior needs permission, and the OS can request that permission when necessary.
Yamamoto
KeymasterApril 2, 2020 at 7:39 am #86013page_screenshot.lua is updated
Wrong: media.photoLibrary
Correct: media.PhotoLibraryI tested it with iPad but the result is not changed. media.hasSource(media.PhotoLibrary) always return true. There is no way to check user rejected the permission request. Nor no method to know the screenshot file is saved or not.
I will look into Corona’s runtime source codes.
otterslidestudio@aol.com
ParticipantApril 3, 2020 at 12:28 am #86016I found that after I installed the the page_screenshot.lua and actionX_lua files above, I had an error with the screenshot where elements I had hidden suddenly became unhidden after the screen shot. I think the problem is something in the actionX.lua, but I decide to just restore the version of both files from the last template update. That fixed things.
I further decided to just comment out the nativeShowAlert from the page_screenshot_.lua so that no alert will pop up about the saved image. I already have a dialogue box within the app that asks if the user wants to save the screenshot, so I will just leave it like that for now.
Yamamoto
KeymasterApril 3, 2020 at 3:01 am #86019>comment out the nativeShowAlert from the page_screenshot_.lua so that no alert will pop up
That’s good workaround. I will revise actionX.lua in gitHub. It is not yet migrated into Kwik.
I found it in Corona source code not handle an error when saving an image to PhotosAlbum
UIImageWriteToSavedPhotosAlbum( image, nil, nil, nil )Also the following discussion about a plugin to use UIImageWriteToSavedPhotosAlbum. The plugin code looks good.
https://forums.coronalabs.com/topic/58195-uiimagewritetosavedphotosalbum-unable-to-callback-to-lua/
I could use to make a saving screenshot plugin for Kwik or modify directory Corona source. Either way, it takes some time.
-
This reply was modified 6 years, 6 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.