videokit-ai / natshare

Cross-platform social sharing for Unity Engine.
https://github.com/natmlx/videokit
Apache License 2.0
134 stars 28 forks source link

Where is the source code for iOS and Android? #133

Closed TCROC closed 2 years ago

TCROC commented 2 years ago

Where is the source code for natively sharing and saving files on iOS and Android? There's a few changes I'd like to make regarding permissions, but all I could find were precompiled libraries.

olokobayusuf commented 2 years ago

Hey @TCROC , we currently don't publish native sources for NatShare. What changes are you looking to make?

TCROC commented 2 years ago

Saving videos and images on iOS doesn't work with "add only" permissions. We have to give all access to the photo library in order to save photos or videos. Why is this? We thought it might make some of our users uncomfortable since the only thing our application does is save videos. Requesting "all access" might come across strange.

And question 2, can you publish the native sources? The internet is a scary place and full of spyware. I really appreciate the work you are putting into this plugin and making it intuitive to use. Being able to review the source code creates some piece of mind for us as developers as well (or at least my team it does).

Thanks again!

TCROC commented 2 years ago

This is the error we get on iOS if users give "add only" permissions:

2022-07-24 10:35:39.128167-0400 BlockyBall[69901:10579545] [PhotoKit] Attempted fetch within change block can trigger deadlock, returning unauthorized fetch result Save on mobile failed! BlockyBall.<Save>d__8:MoveNext() System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) System.Runtime.CompilerServices.MoveNextRunner:Run() UnityEngine.WorkRequest:Invoke() UnityEngine.UnitySynchronizationContext:Exec()

olokobayusuf commented 2 years ago

Saving videos and images on iOS doesn't work with "add only" permissions. We have to give all access to the photo library in order to save photos or videos. Why is this?

This is how iOS works, for some reason. And you don't actually have to grant full permissions to the photo library. Selecting "Select Photos" without picking a single image will still successfully save the payload to the camera roll.

We thought it might make some of our users uncomfortable since the only thing our application does is save videos. Requesting "all access" might come across strange.

The iOS docs are a bit misleading. You could request PHAccessLevelAddOnly permissions, but this is actually insufficient to save media to the camera roll, so iOS would automatically request PHAccessLevelReadWrite, provided that the user hasn't previously denied the permission.

And question 2, can you publish the native sources? The internet is a scary place and full of spyware. I really appreciate the work you are putting into this plugin and making it intuitive to use. Being able to review the source code creates some piece of mind for us as developers as well (or at least my team it does).

We offer access to source code as part of our enterprise-tier offering. The overwhelming majority of devs will never need to see our source code.

In the latest version, NatShare 1.3, we've added a SavePayload.RequestPermissions method that requests the same ReadWrite permissions that iOS does when saving to the camera roll.