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

Add copy argument to SaveToCameraRoll #38

Closed olokobayusuf closed 6 years ago

olokobayusuf commented 6 years ago

When copy is false, the media file will be deleted from the app's private documents directory once it has been added to the camera roll. The default will be copy = true

mikkoh commented 6 years ago

So this is definitely cool. However if someone wants to do something like the following sequence:

  1. SaveToCameraRoll
  2. Share*
  3. Delete the file that was saved to camera roll and shared

If I do copy = false during Step #1 then I won't be able to share. I still think the right fix is to add a callback for when SaveToCameraRoll completes.

This is why in iOS they have completionHandler. I really wish Unity just added something beside SendMessage to specifically handle callbacks. It's such bad api design not to. Although I guess 3ps can create a lib thats like a messaging bridge.

olokobayusuf commented 6 years ago

However if someone wants to do something like the following sequence: ... If I do copy = false during Step #1 then I won't be able to share. I still think the right fix is to add a callback for when SaveToCameraRoll completes.

This would be fine, since you can use the ShareCallback when calling Share to delete the file.

This is why in iOS they have completionHandler. I really wish Unity just added something beside SendMessage to specifically handle callbacks. It's such bad api design not to.

I agree with this. We never use UnitySendMessage because it is very sloppy (you are limited to one string argument). So instead we use C# delegates invoked directly from C++/C/Obj-C. It's much much more flexible, but we have to manually handle threading concerns (because most of the time, the thread that calls back into C# isn't UnityMain, and we all know how Unity hates its API's being called on non-main threads).

olokobayusuf commented 6 years ago

Implemented in 230a472027765bb1702ffe53b304560443ab410d