yasirkula / UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
MIT License
890 stars 131 forks source link

ios permission denied when using persistentPath for Sharing VideoFile #164

Closed choigawoon closed 1 year ago

choigawoon commented 1 year ago

Description of the bug

A clear and concise description of what the bug is. Before reporting a bug, please do a quick search in Issues to see if it is already reported. If the documentation has a FAQ (Frequently Asked Questions), please also check out the entries there.

i got error message on ios device. should i use temporary path for sharing?

exam1, from persistentPath

Share Error: file does not exist at path or permission denied: /var/mobile/Containers/Data/Application/F85DC649-998B-46CD-8E9C-8EAA5C8F6DED/Documents/MSW/MSW 4.mp4
NativeShare:AddFile(String, String)
MODNativeShare:ShareFile(Boolean, String, String, String, String, String)
MOD.UnityService.ClientUnityEngineService:ProcessRequest(UnityRequestBase)
MOD.UnityService.ClientUnityEngineService:Update()

exam2, from photolibrary

Share Error: file does not exist at path or permission denied: avpmc-photolibrary:///MSW.mp4
NativeShare:AddFile(String, String)
MODNativeShare:ShareFile(Boolean, String, String, String, String, String)
MOD.UnityService.ClientUnityEngineService:ProcessRequest(UnityRequestBase)
MOD.UnityService.ClientUnityEngineService:Update()

Reproduction steps

If possible, providing reproduction steps would be very helpful while pinpointing the issue. You can also post screenshots if you think they would be helpful.

Platform specs

Please provide the following info if this is a Unity 3D repository.

Additional info

Please check Logcat (Android) or Xcode console (iOS) for any meaningful error messages and include them here.

yasirkula commented 1 year ago

Plugin simply uses System.IO.File.Exists to check if the destination file exists: https://github.com/yasirkula/UnityNativeShare/blob/a23ce3ea293ceebf4a78ddcbefdcd9591d6e164d/Plugins/NativeShare/NativeShare.cs#L144-L150

I'm not sure why this function returns false for the first path (maybe the file isn't generated yet?) but this isn't related to NativeShare, this is related to System.IO.File.Exists returning false for that path. The second path isn't a raw file path so it isn't supported.

choigawoon commented 1 year ago

thank you- it's solved now