Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

NatShare - Free Sharing API

Discussion in 'Assets and Asset Store' started by Lanre, Apr 17, 2018.

  1. PotatoMasha

    PotatoMasha

    Joined:
    Jun 13, 2015
    Posts:
    2
    This worked thank you! I forgot I also tried both the github and unity assetstore version and left it on github. Thanks for a quick response!
     
    Lanre likes this.
  2. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    364
    Nice plugin, but I had some problems with callback running imidiately after game starts, got to make extracheck with boolean...
     
    Last edited: Oct 19, 2018
  3. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    364
    Also I have a problem with screenshot sharing, after sharing first time, it will share same image everytime. I'm making a screenshot with ScreenCapture.CaptureScreenshot("name"); and override it every time when player got a new record...
    -------------
    NWM, it was a bug with image previews in app I was sharing with...
     
    Last edited: Oct 19, 2018
    Lanre likes this.
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    Sounds good.
     
  5. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    831
    GIF record from NatCorder does not seem to save to the Animated folder on iOS using the save to album method
     
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    We don't make any special provisions for GIF files (all media files are treated the same). I would expect iOS to figure to add the GIF to an Animated folder.
     
  7. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    831
    The gif created from NatCorder does not seem to get saved to the Animated folder using saveToAlbum - iOS 12
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    I reviewed the code and found a potential solution for this. Check out this issue.
     
  9. MikkoHaapoja

    MikkoHaapoja

    Joined:
    Dec 2, 2016
    Posts:
    6
    I know that callbacks were added to all the share functions. Ideally this would also be added to
    SaveToCameraRoll
    also.

    If you do this:
    Code (CSharp):
    1.  
    2. NatShare.SaveToCameraRoll(path);
    3. System.IO.File.Delete(path);
    4.  
    The file will never save to the camera roll.

    Amazing job with NatCorder, NatMic, and NatShare. Super ambitious! Nice API and the code is implemented very cleanly.
     
    Lanre likes this.
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    We'll be adding a `copy` parameter in `SaveToCameraRoll`. If `copy` is set to false, NatShare will move the file to the camera roll instead of copying it. Here's the issue on GitHub for everyone to keep an eye on.
     
  11. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    i just started using natcorder together with natshare.
    When i record a video and then bring up the sharesheet on iOS (12.0.1 on iPhone X) via ShareMedia call and then try to share to FB that works fine (the post shows up on FB with the video) but when i press the button to share to Instagram it fails (seems to do nothing) and in the xcode console i can see:

    2018-10-27 22:48:57.507423+0200 natcorder[1184:423014] [default] [ERROR] Failed to determine whether URL /var/mobile/Containers/Data/Application/34D600AF-6507-4E3B-8794-C99F3BFD2BDE/Documents/recording_2018_10_27_22_48_46_935.mov (n) is managed by a file provider
    2018-10-27 22:48:57.796747+0200 natcorder[1184:422964] [core] SLRemoteComposeViewController: (this may be harmless) viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
    2018-10-27 22:48:57.796872+0200 natcorder[1184:422964] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
    User shared recording!
    RecordTexture:OnShare()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)


    Do you have an idea what this could be about?
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    There is an issue open for this. Are you passing a sharing string? It doesn't look like there's a solution for this. I'll keep searching.

    EDIT: Apparently, the fix is to specify the `UISupportsDocumentBrowser` key in Info.plist as YES.
     
  13. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    Hello there and thanks for the quick reply =)
    I didn't provide a sharing string (should i or shouldn't i?)
    I did add UISupportsDocumentBrowser in the info.plist but i still get an error when pressing the button to share to instagram

    2018-10-28 11:33:07.985787+0100 natcorder[1293:458500] [core] SLRemoteComposeViewController: (this may be harmless) viewServiceDidTerminateWithError: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
    User shared recording!
    RecordTexture:OnShare()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)


    I use Xcode 10.0 and deploy to iOS 12.0.1 device in case that makes a difference.
    Do i need to do specific settings in build settings/iOS/other settings in the player settings or something?
    With which settings did it work for you?
    Or does one have to add some frameworks in the xcode project for it to work?

    To me it looks like the instagram panel comes up but is then closed right away
     
    Last edited: Oct 28, 2018
  14. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    831
    Just curious if you have tested your gif creation and save to work on iOS?
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    Don't, because then Instagram won't show up as a sharing option.
    The Info.plist change seems to fix the permissions error, but I'm not sure what this new error is. I can't seem to find anything useful on it.
    Nope.
    I haven't tested it myself. That's why I said "apparently, the fix is ...". I'll do some testing today.
    This is consistent with the error that gets logged. I just can't find anything on it.
     
  16. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    I'm still working on updates to NatShare. Once it is ready, I will post a new build on GitHub and the Asset Store.
     
  17. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    ok, thanks for the reply and looking further into the instagram issue on iOS =)
    Just as feedback: The recording part with Natcorder works very well on both iOS and Android and on Android i could also share to Instagram (and various others) fine via NatShare, too =)
    So "only" gotta figure out that instagram issue on iOS now, then all good =)
     
    Lanre likes this.
  18. RobertGillespie

    RobertGillespie

    Joined:
    Dec 21, 2017
    Posts:
    1
    Hi everyone,

    Firstly I wanted to say thanks for making this plugin, both NatCorder and NatShare are indispensable products.

    At present, I'm having a little trouble saving a video to the camera roll on iOS. I don't know if this is a technical issue or if I'm just misunderstanding how to use NatShare.

    I'm just testing it right now, so I've created a scene where I've attached the following script to an empty game object, along with the 'Replay Cam' script:

    upload_2018-10-29_9-19-46.png

    When I build it out in xCode, install it on my iPad, then run it, the app after about 15-20 seconds replays a video of the scene, and even asks me "Would you like this app to be able to save files to your camera roll?" (to which I say yes); however, when I go to my camera roll I don't see the video anywhere.

    Tried turning the iPad off and on, and deleting and reinstalling the app.

    Is there something wrong with the way I'm using it here? Any help would be greatly appreciated.

    Edit: just updated the iPad to the latest version of iOS last week, on 10/24/18, in case that's important
     
    JcFractal likes this.
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    You need to get the path to the recorded video (from the RecordingCallback, see ReplayCam's OnReplay function), and pass that path in to NatShare.SaveToCameraRoll. I strongly recommend against dragging and dropping ReplayCam and using it as a black box. Instead, write a minimal MonoBehaviour component to use NatCorder's start- and stop-recording functions directly, and add sharing functionality with NatShare. Check out NatCorder's README and some articles on Medium for more info on how the API works.
     
  20. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    @Lanre : somehow now the sharing to instagram works fine on iOS, too for me (when not supplying a default text)
    The only thing i changed (i'm aware of) compared to when it was not working is that i now crop the video to be 4:3 dimensions. (so not sure if video dimensions or filesize or memory usage was the culprit or something else i'm not aware of)
    Now when i select instagram in the sharesheet the instagram share panel doesn't go away by itself anymore and i can share fine =)
    We'll test it on a few more devices some more but yeah, works well so far.
     
    Last edited: Nov 2, 2018
  21. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
  23. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    ok, makes sense.
    So i've done some testing across both iOS and Android for sharing video, these are my testing results so far when testing sharing to twitter, FB and Instagram:

    *sharing just video

    works for me on both iOS and Android for twittter, fb and instagram chosen in the sharesheet

    *trying to share video with default text provided:
    on iOS and Android only works for twitter: Both the video and text appear in the post editor for twitter.

    When trying to share to FB the video shows up in the FB post editor, the default text does not.
    But one can still share the video then

    When trying to share to Instagram (again, with default text), then on iOS Instagram does not appear in the sharesheet as one of the options anymore, so one can't share to it. On Android Instagram still appears in the share options when supplying a default text but the default text does not show up in the post editor.

    Does anyone know an option how to have sharing a video with default text work for FB and Instagram, too?

    Because after these test runs it seems to me like to still support sharing to all the networks unless there is a way to get it working with default text, it is only safe to provide no default text as else some networks may not even show up as option to share to.
    If that is the case then i think it would also be good if you'd add an option to share only to twitter (without bringing up the sharesheet then) and recommend to users to only supply a default text when sharing video when sharing to twitter using that sharing option instead of the general sharesheet using sharemedia call as supplying a default text there may cut away some of the sharing options in the sharesheet and the default text doesn't seem to show up in most of the remaining options selectable in the sharesheet anyway.
     
  24. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    This is up to the receiving app, not the sender (in this case, NatShare). A number of apps don't receive text payloads.
    I agree with this. I'll be removing the text parameter from the share functions. We already have a dedicated ShareText function for sharing plain text.
    I'd rather not add sharing functions for specific apps. It has the potential to really bloat up the API, something I do my best to prevent.
     
  25. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    681
    hm, dunno how i feel about removing the text parameter in general from the sharemedia function. I haven't tested it yet for when sharing a static image (one of the things i'll do next week), but if that works well it may be a loss to cut it. In that case i'd just add a warning in the docs that one shouldn't do it when sharing video (and explain why).
    just my two cents on it =)
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    It should have the exact same behaviour as sharing media at a file path.
     
  27. ArrowT

    ArrowT

    Joined:
    May 18, 2013
    Posts:
    27
    Hello!
    I have a problem with sharing a video file.

    If I use the output path from NatCorder, I get a crash:

    Code (CSharp):
    1. NatShare.Share(RecordVideo.Instance.ResultPath);

    If I use the output path from NatCorder with the concat "file://", then I get an error:

    NatShare Error: Failed to share media because no file was found at path 'file://var/mobile/Containers/Data/Application/64086501-02FB-48F3-A53D-B103D9021E7E/Documents/recording_2018_11_08_02_45_12_268.mov'

    Code (CSharp):
    1. NatShare.Share("file:/" + RecordVideo.Instance.ResultPath);

    NatCorder ver. 1.3f2
    NatShare ver. 1.1f3

    Unity 2018.2.14f1
    XCode 10.0 (10A255)

    Devices:
    iPhone 5S, iOS 12
    iPhone 6, iOS 11.4.1

    P.S. When using "SaveToCameraRoll" everything works fine.
     
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    How are you setting `RecordVideo.Instance.ResultPath`? The path NatCorder returns should start with '/', so that adding the "file://" protocol will result in the path starting with three forward slashes: "file:///var/....". Make sure you aren't modifying the path that NatCorder returns.
     
  29. ArrowT

    ArrowT

    Joined:
    May 18, 2013
    Posts:
    27
    Thanks for the quick reply!

    `RecordVideo.Instance.ResultPath` gets the same value as the NatCorder output.
    I tried to do a "file://" or "file:/" prefix to the path, but got a similar error with different amount of slashes.
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    That's weird. Explicitly prepend three slashes (the path should be "file:///var/...").
     
  31. ArrowT

    ArrowT

    Joined:
    May 18, 2013
    Posts:
    27

    NatShare Error: Failed to share media because no file was found at path 'file:///var/mobile/Containers/Data/Application/F3972AF0-F395-44C1-84B8-2D54A00D7859/Documents/recording_2018_11_08_03_33_48_189.mov'
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    I'll look into this and get back to you.
     
    ArrowT likes this.
  33. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6
    Hi, in Iphone 6, when Run from Xcode in DevelopmentBuild I got a error and close app, how can I repair this

    yield return new WaitForEndOfFrame();
    image = ScreenCapture.CaptureScreenshotAsTexture();
    NatShare.Share(image);

    error Xcode:

    2018-11-08 07:54:16.261983-0300 sosmujer[303:9718] Error: DebugHierarchyRequest - Failed to unarchive request data with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

    (lldb). <------------

    using asset from asst store unity.
     
  34. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    This error doesn't look anything related to NatShare (NatShare doesn't do anything with JSON). Can you share the full logs from Xcode in a .txt file? Does the share sheet show?
     
  35. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6
    UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String: AppControllerClassName]);

    at point the app break... thanks for help


    now all code include this line break:

    #include "RegisterMonoModules.h"

    #include "RegisterFeatures.h"

    #include <csignal>

    // Hack to work around iOS SDK 4.3 linker problem

    // we need at least one __TEXT, __const section entry in main application .o files

    // to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation

    static const int constsection = 0;

    void UnityInitTrampoline();

    // WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)

    const char* AppControllerClassName = "UnityAppController";

    int main(int argc, char* argv[])

    {

    UnityInitStartupTime();

    @autoreleasepool

    {

    UnityInitTrampoline();

    UnityInitRuntime(argc, argv);

    RegisterMonoModules();

    NSLog(@"-> registered mono modules %p\n", &constsection);

    RegisterFeatures();

    // iOS terminates open sockets when an application enters background mode.

    // The next write to any of such socket causes SIGPIPE signal being raised,

    // even if the request has been done from scripting side. This disables the

    // signal and allows Mono to throw a proper C# exception.

    std::signal(SIGPIPE, SIG_IGN);

    UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String: AppControllerClassName]);

    }

    return 0;
    }

    #if TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR

    #include <pthread.h>

    extern "C" int pthread_cond_init$UNIX2003(pthread_cond_t *cond, const pthread_condattr_t *attr)

    { return pthread_cond_init(cond, attr); }

    extern "C" int pthread_cond_destroy$UNIX2003(pthread_cond_t *cond)

    { return pthread_cond_destroy(cond); }

    extern "C" int pthread_cond_wait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex)

    { return pthread_cond_wait(cond, mutex); }

    extern "C" int pthread_cond_timedwait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex,

    const struct timespec *abstime)

    { return pthread_cond_timedwait(cond, mutex, abstime); }

    #endif // TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR


    in Unity it works great, send me a msg according about this plataform don't suported.... but in my iPhone not working =( yet =)
     
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    This is all Unity boilerplate code; nothing related to NatShare.
     
    luchopops76 likes this.
  37. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6
    where can I find a log to this error, in unity I just call NatShare in a button and whem press this button show me this error in Xcode, and app now freeze.
     
  38. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    Can you post a screenshot of the Xcode window when the crash happens?
     
  39. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6

    Attached Files:

  40. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6
    (

    0 CoreFoundation 0x00000001863bbeb8 <redacted> + 252

    1 libobjc.A.dylib 0x000000018558da40 objc_exception_throw + 56

    2 CoreFoundation 0x00000001862c2674 <redacted> + 0

    3 Foundation 0x0000000186d354f4 <redacted> + 92

    4 sosmujer 0x00000001017a68b4 NSShareImage + 172

    5 sosmujer 0x00000001017c76cc NatShareiOS_NatShareU_INatShare_Share_m1524717533 + 52

    6 sosmujer 0x0000000101879dc8 U3CRecordFrameU3Ec__Iterator3_MoveNext_m3225434185 + 604

    7 sosmujer 0x00000001019c6218 SetupCoroutine_InvokeMoveNext_m3199342729 + 140

    8 sosmujer 0x0000000100a53aac _Z54RuntimeInvoker_Void_t1185182177_RuntimeObject_IntPtr_tPFvvEPK10MethodInfoPvPS4_ + 40

    9 sosmujer 0x0000000101672890 _ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException + 108

    10 sosmujer 0x0000000100edfb58 _Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb + 100

    11 sosmujer 0x0000000100ee7698 _ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb + 60

    12 sosmujer 0x0000000100eeaa38 _ZN9Coroutine14InvokeMoveNextEP21ScriptingExceptionPtr + 176

    13 sosmujer 0x0000000100eea60c _ZN9Coroutine3RunEPb + 52

    14 sosmujer 0x0000000100d4756c _ZN18DelayedCallManager6UpdateEi + 636

    15 sosmujer 0x0000000100e17e24 _Z23PlayerSendFrameCompleteb + 36

    16 sosmujer 0x0000000100e18c90 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 88

    17 sosmujer 0x0000000100e18cb8 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 128

    18 sosmujer 0x0000000100e18e14 _Z10PlayerLoopv + 220

    19 sosmujer 0x0000000100c03430 _ZL19UnityPlayerLoopImplb + 272

    20 sosmujer 0x00000001009d1dac UnityRepaint + 140

    21 sosmujer 0x00000001009d1c98 -[UnityAppController(Rendering) repaintDisplayLink] + 88

    22 GPUToolsCore 0x000000010955964c -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 176

    23 QuartzCore 0x000000018a87f854 <redacted> + 828

    24 IOKit 0x000000018661bb94 IODispatchCalloutFromCFMessage + 488

    25 CoreFoundation 0x0000000186324ff8 <redacted> + 188

    26 CoreFoundation 0x000000018634c844 <redacted> + 56

    27 CoreFoundation 0x000000018634bf90 <redacted> + 440

    28 CoreFoundation 0x0000000186346d48 <redacted> + 2140

    29 CoreFoundation 0x00000001863461cc CFRunLoopRunSpecific + 436

    30 GraphicsServices 0x00000001885bd584 GSEventRunModal + 100

    31 UIKitCore 0x00000001b3441054 UIApplicationMain + 212

    32 sosmujer 0x00000001009cace0 main + 160

    33 libdyld.dylib 0x0000000185e06bb4 <redacted> + 4

    )

    2018-11-08 14:05:10.977032-0300 sosmujer[696:76793] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'

    *** First throw call stack:

    (0x1863bbea0 0x18558da40 0x1862c2674 0x186d354f4 0x1017a68b4 0x1017c76cc 0x101879dc8 0x1019c6218 0x100a53aac 0x101672890 0x100edfb58 0x100ee7698 0x100eeaa38 0x100eea60c 0x100d4756c 0x100e17e24 0x100e18c90 0x100e18cb8 0x100e18e14 0x100c03430 0x1009d1dac 0x1009d1c98 0x10955964c 0x18a87f854 0x18661bb94 0x186324ff8 0x18634c844 0x18634bf90 0x186346d48 0x1863461cc 0x1885bd584 0x1b3441054 0x1009cace0 0x185e06bb4)

    libc++abi.dylib: terminating with uncaught exception of type NSException

    (lldb)
     
  41. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    Okay I just caught this. Head over to the Releases page on GitHub and download NatShare 1.1f3. Delete NatShare in your project before importing this one.
     
    luchopops76 likes this.
  42. luchopops76

    luchopops76

    Joined:
    Jun 14, 2017
    Posts:
    6
    WORKS FANTASTIC!!!!! GRACIAS really thank you!!!
     
    Lanre likes this.
  43. CreepyInpu

    CreepyInpu

    Joined:
    Oct 9, 2014
    Posts:
    11
    Hi,

    Using Netshare.share(), my app (Android) is freezing for a few second before showing the native Sharing UI. Is there a workaround for that ?

    My code is pretty simple :

    Code (CSharp):
    1.     IEnumerator StartSharingStuff()
    2.     {
    3.         yield return new WaitForEndOfFrame();
    4.         Texture2D texture = ScreenCapture.CaptureScreenshotAsTexture();
    5.         // do something with texture
    6.         NatShare.Share(texture);
    7.  
    8.         // cleanup
    9.         Object.Destroy(texture);
    10.     }
    Thanks !
     
  44. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    This usually happens when the texture being shared is large. NatShare must encode the image to a PNG, and Unity's Texture2D.EncodeToPNG gets really slow for bigger textures.
     
  45. ArrowT

    ArrowT

    Joined:
    May 18, 2013
    Posts:
    27
    I fixed this in the source code of the iOS library. However, the video sharing menu appears with a delay of 1 second, while the sharing photo menu is instantly displayed.

    Before:
    Code (CSharp):
    1. bool NSShareMedia (const char* mediaPath) {
    2.     NSString* path = [NSString stringWithUTF8String:mediaPath];
    3.     if (![NSFileManager.defaultManager fileExistsAtPath:path]) {
    4.         NSLog(@"NatShare Error: Failed to share media because no file was found at path '%@'", path);
    5.         return false;
    6.     }
    After:
    Code (CSharp):
    1. bool NSShareMedia (const char* mediaPath) {
    2.     NSURL* path = [NSURL fileURLWithPath:[NSString stringWithUTF8String:mediaPath]];
    3.     if (![NSFileManager.defaultManager fileExistsAtPath:path.path]) {
    4.         NSLog(@"NatShare Error: Failed to share media because no file was found at path '%@'", path.path);
    5.         return false;
    6.     }
     
    wagnerps and Lanre like this.
  46. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    This is dependent on iOS's sharing activity UI. There is nothing you can do in NatShare's sources to remove this delay as far as I can tell.
     
    ArrowT likes this.
  47. dustin_red

    dustin_red

    Joined:
    Feb 7, 2018
    Posts:
    46
    @Lanre I'm not sure how I ended up reproducing this issue, but I'm not able to save to the camera folder on an Android device. I think I've narrowed it down to not having a "DCIM/Camera/" folder. Which makes it so when you call NatShare.SaveToCameraRoll(), the image does not save. Maybe new devices do not have the "DCIM/Camera/" folder until after you take your first picture. Quick fix for now, I'm just going to check for that folder before saving, but I wanted to make you aware.
     
    Last edited: Nov 15, 2018
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    That's weird, because NatShare will first ensure the directory is created before copying or moving the video file there. Let me know what you find.
     
  49. dustin_red

    dustin_red

    Joined:
    Feb 7, 2018
    Posts:
    46
    Yup, I see that, also that you are refreshing the media list, which is what I thought it was at first. But I just reproduce it again. Delete the "DCIM/Camera/" folder, save a photo with NatShare.SaveToCameraRoll(), nothing there. Then create the "Camera" folder, save a photo again, its there.

    From LogCat:
    11-14 16:46:16.809: E/Unity(3519): NatShare Error: Failed to save image to camera roll

    I'm testing on an older device:
    Samsung Galaxy S5 - SM-G900A
    Android 4.4.2

    Also I should mention that I am prompting for android.permission.WRITE_EXTERNAL_STORAGE before.
     
    Last edited: Nov 14, 2018
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,653
    Can you upload the full logs in a .txt file? That error message should print with an full exception.