Search Unity

NatShare - Free Sharing API

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

  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I recommend upgrading NatShare to the payload-api code. It's still in development, but is fully functional on iOS.
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    There's an open issue for this. I'll get this fixed on iOS this weekend.
     
  3. Deleted User

    Deleted User

    Guest

    Great, thanks.

    I've bought NatCorder and NatMic to go along with NatCam, but I can't get the webcam quality to be anything other than very low. Whatever size and setting we put in, it records it at 1280, and pixelated. This is just through Unity preview, and not iOS tested though.

    I've altered the NatMicCorder example you gave.

    Unity 2019.2.9f1
    macOS 10.15
    NatCorder 1.6.3
    NatMic 1.3.1
     

    Attached Files:

  4. sucko

    sucko

    Joined:
    Jun 17, 2016
    Posts:
    5
    Thanks a lot, that did the trick.

    However, when we use #49 together with NatCorder to share the recorded video (with the path that NatCorder returns) we get following exception:
    ArgumentException: Value does not fall within the expected range
    (at SharePayload.cs:29)

    the sharing did work before.

    this is the code we use (from your readme):
    using (var payload = new SharePayload()){
    payload.AddMedia(videoPath);
    }


    videoPath looks like this:
    /storage/emulated/0/Android/data/com.RabbitEye.RabbitEye/files/recording_2019_10etc.mp4
     
  5. Deleted User

    Deleted User

    Guest

    Seems to be working. I went down to Unity 2019.1.14 and exported to iPad Pro. It recorded at UHD without changing the settings
     
    Lanre likes this.
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Can you post the full exception? Never seen this one before.
     
  7. cubemap

    cubemap

    Joined:
    May 13, 2016
    Posts:
    5
    hello lanre!

    i am in a team with "sucko", allow me to post the exception (for timesaving purposes):


    AndroidPlayer(samsung_SM-G950F@192.168.0.192) ArgumentException: Value does not fall within the expected range.
    at NatShare.SharePayload..ctor (System.String subject, System.Action completionHandler) [0x0001c] in E:\Users\cubemap\UNITY PROJECTS\Project Name\Assets\NatShare\Plugins\Managed\SharePayload.cs:29


    thank you for replying. :)
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Ah I know why. It's cos the completion handler argument is `null`. I'll fix this.
     
  9. cubemap

    cubemap

    Joined:
    May 13, 2016
    Posts:
    5
    fantastic! :)
     
  10. sucko

    sucko

    Joined:
    Jun 17, 2016
    Posts:
    5
    we're almost there, now with your latest fix (completion handler argument is null) a folder is created with the name of our project, but they payload (mp4) does not appear in that directory. we didn't try with images yet, just wondering if the mp4 is the problem?
     
  11. andrewdSuper77

    andrewdSuper77

    Joined:
    Jul 12, 2019
    Posts:
    15
    Certainly, here is the XCode Logs and the full window view
     

    Attached Files:

    Last edited: Oct 22, 2019
  12. cubemap

    cubemap

    Joined:
    May 13, 2016
    Posts:
    5
    dear lanre,

    heads up; unfortunately SavePayload does not work (latest version from your payload branch, on android 9). not with AddMedia (mp4), or with AddImage.
     
  13. andrewdSuper77

    andrewdSuper77

    Joined:
    Jul 12, 2019
    Posts:
    15
    @Lanre Has there been any progress on this sharing issue? or an update I can look for?
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    The Android backend isn't complete just yet.
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Are you passing in a completion handler when creating the payload? If not, then it's an issue I've fixed so grab the updated code from GitHub.
     
  16. jedai747

    jedai747

    Joined:
    Oct 31, 2018
    Posts:
    77
    i want to share png on ios and i have crash. Help pls, ios 13.1.13, iphone 7, after i clicked on allow permision have crash. Android - fine
     

    Attached Files:

    • log.txt
      File size:
      80.6 KB
      Views:
      712
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    This bug has been fixed in #49. The iOS backend is complete, so you can copy the NatShare folder from that branch into your project.
     
  18. NaijaNY82

    NaijaNY82

    Joined:
    Mar 7, 2017
    Posts:
    19
    I commented out the old Natshare code used to create/save an mp4 to an album on the camera roll. It worked fine when I tested it on Android a few months ago with the ReplayCam example. Tried updating the latest Natshare payload api to use with Natcorder. Is this the correct way to go about adding it. I haven't been able to get it working.

    Code (CSharp):
    1.      
    2.  
    3.  private void OnReplay (string path) {
    4.             Debug.Log("Saved recording to: "+path);
    5.             // Playback the video
    6.             #if UNITY_EDITOR
    7.             EditorUtility.OpenWithDefaultApp(path);
    8.             #elif UNITY_IOS
    9.             Handheld.PlayFullScreenMovie("file://" + path);
    10.             #elif UNITY_ANDROID
    11.             Handheld.PlayFullScreenMovie(path);
    12.         //NatShare.SaveToCameraRoll(path, "TestAlbum", false);
    13.         using (var payload = new SavePayload()) {
    14.             payload.AddMedia(path);
    15.             }
    16.  
    17.             #endif
    18.         }
    19.  
    20.  
     
    Last edited: Nov 6, 2019
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Your code is correct. The Android backend of the new payload API is not complete.
     
  20. NaijaNY82

    NaijaNY82

    Joined:
    Mar 7, 2017
    Posts:
    19
    Ok. Do you have an idea on when you'll be rolling out the completed payload api?
     
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Not just yet. I recommend monitoring the GitHub repo.
     
  22. ElliotCurtis

    ElliotCurtis

    Joined:
    Nov 26, 2018
    Posts:
    20
    So, I'm trying to wait until permissions are granted before saving to camera roll (gallery).
    I have written the following but it now doesn't save at all!
    If anyone can tell me what is wrong with this code I will be very grateful!
    Thanks,



    public void OnGalleryButtonPressed()
    {
    #if UNITY_ANDROID
    if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
    {
    Permission.RequestUserPermission(Permission.ExternalStorageWrite);
    }
    if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
    {
    Permission.RequestUserPermission(Permission.ExternalStorageRead);
    }
    #endif

    ShareTheGif();
    }
    private IEnumerator ShareTheGif() {
    yield return new WaitUntil(() => Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead) == true);

    Debug.Log("Gallery sharing selected.");
    string path = getPath(ProGifManager.Instance.GifName + ".gif");
    NatShare.SaveToCameraRoll(path);
    hide();
    }
     
  23. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Check the logs.
     
  24. ElliotCurtis

    ElliotCurtis

    Joined:
    Nov 26, 2018
    Posts:
    20
    Checking the logs only confirms that my code doesn't work!
    I'm pretty sure I've just not written the co-routine properly- I'm a very inexperienced coder and it's he first time I've tried something like this...
     
  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Can you upload the logs from logcat in a .txt file?
     
  26. ElliotCurtis

    ElliotCurtis

    Joined:
    Nov 26, 2018
    Posts:
    20
    Hi Lanre- I don't even know what that means!
    Whatever logcat is, I am not using it...
     
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
  28. Deleted User

    Deleted User

    Guest

    @Lanre

    I am trying to share a Texture2D on iOS but I get a crash on Ipad pro iOS 12.1

    Code (CSharp):
    1. using (var payload = new SharePayload("", () => { OnImageShareComplete(); })) { payload.AddImage(screenshotImage); }
    Can you please help?
     
  29. Deleted User

    Deleted User

    Guest

    I am unable to share my texture2D @Lanre
    Help needed.
    If I capture the screenshot and save it as a texture2d. I am unable to share it.. it causes a crash
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Can you share information about the crash? Can you post a screenshot of Xcode when the crash occurs, and can you share the logs?
     
  31. Deleted User

    Deleted User

    Guest

    It was because Natshare payload api now only supports RGBA32 texture format.
    I changed the format and now it is working fine
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I have updated the code to fix this. Now it will work with any format Texture2D.
     
  33. marcipw

    marcipw

    Joined:
    Apr 18, 2013
    Posts:
    239
    I am currently using this too but unable to share the video or see it in my gallery.
    I am exporting to iOS with this version and using the 'old' NatShare for the Android version. The video appears to record OK, shows the playback and then disappears.
     
  34. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I haven't had time to complete the Android backend. iOS however is complete.
     
  35. kkiruk

    kkiruk

    Joined:
    Sep 7, 2015
    Posts:
    8
    Hi, Lanre.
    I've got this error message in Android Studio. (using latest payload api)

    ERROR: Manifest merger failed : uses-sdk:minSdkVersion 18 cannot be smaller than version 22 declared in library [:NatShare:]

    Did you change the minimum SDK version at Android?
     
  36. LeeLorenzSr

    LeeLorenzSr

    Joined:
    May 3, 2015
    Posts:
    50
    OK, so I'm using the payload-api branch on Android, seems that it works fine to share to messages or twitter... but I can't seem to get it working to share a video (mp4 - recorded with NatCorder) with TikTok or Instagram. Also, I added a text payload, and that doesn't seem to be shared along with the video on messaging or Twitter. Anybody else have this experience? Any ideas?
     
  37. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    34
    Has the payload branch removed GetThumbnail() for video?
     
    wintermuute likes this.
  38. wintermuute

    wintermuute

    Joined:
    May 12, 2017
    Posts:
    16
    I was using GetThumbnail() as well, but had to update NatShare to the Payload branch to work with iOS 13. Is there any news about this function getting added back in?
     
  39. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    34
    Hmm, using the latest in the payload branch and getting this when sharing to instagram:

    Code (CSharp):
    1. 2019-12-05 23:52:40.611291-0800 mir[95659:17827923] Unable to setup extension context - error: Couldn’t communicate with a helper application.
    2. 2019-12-05 23:52:40.612669-0800 mir[95659:17828089] [lifecycle  ] [u 8F717E15-C3CE-49C9-82F2-2E0115FD5E84:m (null)] [com.burbn.instagram.shareextension(112.0)] Connection to plugin interrupted while in use.
    3. 2019-12-05 23:52:40.612669-0800 mir[95659:17827799] [core] HOST: Failed to load remote view controller with error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.burbn.instagram.shareextension.apple-extension-service" UserInfo={NSDebugDescription=connection to service on pid 0 named com.burbn.instagram.shareextension.apple-extension-service}
    4. 2019-12-05 23:52:40.612898-0800 mir[95659:17827799] [core] Sheet not being presented, calling premature completion
    5. 2019-12-05 23:52:40.613330-0800 mir[95659:17828089] [lifecycle  ] [u 8F717E15-C3CE-49C9-82F2-2E0115FD5E84:m (null)] [com.burbn.instagram.shareextension(112.0)] Connection to plugin invalidated while in use.
    6. 2019-12-05 23:52:40.949859-0800 mir[95659:17827799] [Assert] Trying to dismiss the presentation controller while transitioning already. (<_UIOverFullscreenPresentationController: 0x155f82260>)
    7. 2019-12-05 23:52:40.952376-0800 mir[95659:17827799] Null transitionViewForCurrentTransition block, aborting _scheduleTransition:
    8. 2019-12-05 23:52:41.472617-0800 mir[95659:17828090] [ShareSheet] connection invalidated
    IG doesn't pop up, it just returns to my app
    Edit: Fixed by updating IG to latest. Odd!
     
    Last edited: Dec 6, 2019
    Lanre likes this.
  40. mtalbott

    mtalbott

    Joined:
    Dec 21, 2011
    Posts:
    125
    @Lanre I've been using the payload api branch on our last couple builds and we just noticed that when sharing an image on iOS to Google Drive, the uploaded texture is flipped vertically. I have replicated this in your provided test scene. This was not the case in earlier versions of NatShare. I would continue to use the previous version but my assumption is that the Payload API branch is needed on iOS 13. Is that correct?
     
    Last edited: Dec 11, 2019
  41. dryraa

    dryraa

    Joined:
    Apr 10, 2017
    Posts:
    8
    Hello @Lanre ,
    Using the payload-api version for iOS, on first install when the saving to library permission is not granted yet, on saving an image or a video to the camera roll, the app asks for library permission,and when allowed, the image or video does not get saved, but return a success callback and not error logs, only the next time when you click on save again and the permission is already granted.
    iOS Version: 13.2.3
     
  42. kkiruk

    kkiruk

    Joined:
    Sep 7, 2015
    Posts:
    8
    Hi @Lanre,
    I'm visiting the git everyday for the news of android bug update.
    Is it on going? I wish you could give me a rough schedule of the update.
    I've been doing nothing for a while because of NatShare Android problem. :(
     
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Yup. Unfortunately we've had to update the Android minimum to API level 22 because Android doesn't offer good options to get a callback once sharing has happened (and we can't deprecate the callback feature for parity with iOS as developers use this a lot).
     
  44. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Can you share the logs? When an app doesn't accept a items in a sharing payload, it's usually entirely up to the app and not our code.
     
  45. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    The function was removed as it was out of scope for NatShare. Instead, I've been working on an open source API called NatReader that handles all things video decoding. Check it out.
     
    edee1337 likes this.
  46. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I recommend opening an issue for this. It sounds like this only affects GDrive as I can't reproduce it on other apps.
     
  47. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Ah I'll check this out. In the mean time I recommend opening an issue.
     
    dryraa likes this.
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    NatShare 1.2.0 update has been submitted for review. Sorry it took so long.
     
    kkiruk likes this.
  49. Leeong

    Leeong

    Joined:
    Sep 10, 2018
    Posts:
    11
    [ATTACH = full] 530874 [/ ATTACH]Hi @Lanre,After updating to NatShare 1.2.0, errors will appear in the package. Removing core-1.0.0-rc02.aar can be packaged, but it will crash when saving the video. How to avoid mistakes?
     

    Attached Files:

    Last edited: Dec 17, 2019
  50. jedai747

    jedai747

    Joined:
    Oct 31, 2018
    Posts:
    77
    upload_2019-12-17_12-27-48.png upload_2019-12-17_12-27-54.png
    i have some problems. Unity 2019.2.19