Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Native Share for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Mar 1, 2018.

  1. blackhawk_001

    blackhawk_001

    Joined:
    Jan 25, 2019
    Posts:
    11
    i new in develop phone app. after doing some research, i just can't seem to wrap my head around exactly how it works, or what it's doing, which is making it really difficult to understand why the other code works. It appears I have reached some kind of logic gap and could really use some help understanding. can you explain more detail about it?
     
    Last edited: Jul 31, 2019
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    These are native Java (Android) and Objective-C (iOS) things. I've posted them here to show you which native calls NativeShare makes on each platform. You just have to try sharing something with NativeShare and see if bluetooth printer appears in the target apps list. If it doesn't, unfortunately there's nothing I can do.
     
  3. rtalerico

    rtalerico

    Joined:
    Oct 27, 2016
    Posts:
    7
    Running into the lovely "Can't find ContentProvider, share not possible!" issue. This happened after accidentally rewriting my manifest, losing the provider tag. I have made sure the provider is re-added, and have moved it throughout the entire manifest for new builds. It's getting to the point where I'm just wasting way too much time trying to get sharing to work again.

    I verified in both AndroidManifest-main.xml, as well as AndroidManifest.xml in Temp>StagingArea...

    Running out of ideas here. Any help would be greatly appreciated!
     
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    Is the provider located inside the
    <application>...</application>
    tags in AndroidManifest as shown in the image below? Can I see your Temp/StagingArea/AndroidManifest.xml file? If possible, please send it to me via private message.

     
  5. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    303
    In my case, I need to embed (pin) deeplink to share the message, but unfortunately, the user can remove the text accidentally. Is the any option to attach the link to any message after user enter his text and clicked post?
     
  6. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    It is not possible with NativeShare.
     
  7. blackhawk_001

    blackhawk_001

    Joined:
    Jan 25, 2019
    Posts:
    11
    thank you man, i can detech my printer. and i more question. how do i take video and share on social media?
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    There are different ways of taking a video:

    Recording gameplay: you can use Everyplay or NatCorder
    Picking video from Gallery: you can use NativeGallery
    Recording a video with the camera: you can use NativeCamera
     
  9. blackhawk_001

    blackhawk_001

    Joined:
    Jan 25, 2019
    Posts:
    11
    hi, i cant find everplay on asset store and what i read from review that 2019 kinda problem when using natcorder. i want record video in my app and share it at social media. i cant use native camera because it will open camera app
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
  11. eagle9401

    eagle9401

    Joined:
    Aug 7, 2019
    Posts:
    1
    any good news????
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    I didn't receive an answer to this, so there is no progress.
     
  13. roshan_unity825

    roshan_unity825

    Joined:
    Jun 14, 2019
    Posts:
    4
    hi, thanks for the plugin. for some reason I'm not able to share multiple files using it in android devices. [single file sharing works] .but the same code works like a charm for ios multiple sharing . i dont know where I'm missing out .any help will be highly appreciated
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    Can you try sharing on different applications and on different devices to see if this issue is persistent?
     
  15. affinixy

    affinixy

    Joined:
    Nov 2, 2017
    Posts:
    10
    Hi, I want to share a pre-defined image instead of sharing a screenshot, and I tried changing the path but it seems that none seems to work.

    I tried using Application.persistentDataPath

    I tried putting my images in Resources folder.

    I tried to sharing jpg, uncompressed png and until now, only the share text will be shown.

    Is there a specific way I can get the correct path?
    Please assist.
    Thanks!
     
  16. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    Application.persistentDataPath should work. But make sure that System.IO.File.Exists(filePath) returns true before calling AddFile. It probably returns false right now.
     
  17. thomas_triplefun

    thomas_triplefun

    Joined:
    Sep 24, 2014
    Posts:
    22
    Hello,
    Thank you for your plugin, it's working well on Android, but I have a problem on iOS, the dialog system open,
    and I got these logs:
    [MC] Filtering mail sheet accounts for bundle ID: [My Bundle ID], source account management: 1
    [MC] Result: NO

    And the dialog system look like:



    Thanks,
    Thomas.
     
  18. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    I might have to see your share script.
     
  19. tesan

    tesan

    Joined:
    Oct 1, 2014
    Posts:
    7
    Hello,
    The share script is really easy:

    Code (CSharp):
    1.  
    2. if( this.m_nativeShare == null )
    3.             this.m_nativeShare = new NativeShare();
    4.      
    5.         this.m_nativeShare.SetSubject( Gem.Localise.Get( LocaliseConstants.SHARE_INVITE_TITLE ) );
    6.         this.m_nativeShare.SetText( Gem.Localise.Get( LocaliseConstants.SHARE_INVITE_TEXT ) + "\n" + Constants.SHARE_LINK );
    7.         this.m_nativeShare.SetTitle( Gem.Localise.Get( LocaliseConstants.SHARE_INVITE_TITLE ) );
    8.         this.m_nativeShare.Share();
     
  20. thomas_triplefun

    thomas_triplefun

    Joined:
    Sep 24, 2014
    Posts:
    22
    Hello,
    Sorry for the double posts,
    It's working fine now, I guest the problem was about the SetText, it was empty before.
    Thanks again for your plugin,
    Thomas.
     
    yasirkula likes this.
  21. geri_vori

    geri_vori

    Joined:
    Jan 20, 2017
    Posts:
    1
    Hi, Thank you for amazing asset!
    I wish to send email with this asset (and it works great) from iOS.

    How can I add mailing addresses (recipients) from code (so I dont need to fill email adresses when the email sending window opens) ?
     
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
  23. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    117
    Hi, can/should I use this plugin to share saved games from the DEMO version of my game with the FULL version?
    And is it going to work on both platforms?

    Thanks :)
     
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    This plugin is used for sharing files with other people via Facebook, WhatsApp and etc. So I don't think it'd be suitable for this use-case. But I'm unsure about how else you could share the saved game between two different apps, especially on iOS. One unusual way would be to save the save file to Photos/Gallery as a PNG file? I don't know, lol.
     
    Gooren likes this.
  25. squad_games

    squad_games

    Joined:
    Mar 15, 2019
    Posts:
    2
    Hello. I only need to share part of the screen. How to do it?
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
  27. WelchCompositions

    WelchCompositions

    Joined:
    Sep 30, 2013
    Posts:
    27
    Would there be anyway to know if the share dialog is open? While the dialog is open I want to halt another looping function and turn it back on when the dialog is closed but I don't see a way to do this currently.

    A second issue Im noticing is the iOS native share dialog pops up on the middle of the screen and looks sort of odd as apposed to popping up and the bottom like if I was sharing a photo on the OS's photo app for example.
     
    Last edited: Sep 16, 2019
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    A callback is unfortunately not possible, please see: https://github.com/yasirkula/UnityNativeShare/issues/5

    If it is possible to change the position of the popup on iPads, it should be achieved by modifying this line: https://github.com/yasirkula/UnityN...dd/Plugins/NativeShare/iOS/NativeShare.mm#L39

    I'm not good at Objective-C so I can't give you an exact code but you can try something like this:
    [popup presentPopoverFromRect:CGRectMake( rootViewController.view.frame.size.width / 2, 0, 0, 0 ) inView:rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
     
  29. Voloda2

    Voloda2

    Joined:
    Jan 7, 2017
    Posts:
    4
    NativeShare() not found. What header should I import in my script?
    Code (CSharp):
    1. using NativeShare;
    My problem was that I use
    Code (CSharp):
    1.  NativeShare().SetText("http://somesite.com").Share();
    instead of
    Code (CSharp):
    1. new NativeShare().SetText("http://somesite.com").Share();
     
    Last edited: Sep 17, 2019
    yasirkula likes this.
  30. jhpark3

    jhpark3

    Joined:
    Dec 18, 2018
    Posts:
    2
    When I use this plugin, I found bug.
    It's my source codes bellow, only shared the "File" without the text and the subject.
    Code (CSharp):
    1. new NativeShare().AddFile(filePath).SetSubject(subject).SetText(text).Share();
    Thank you that your plugin is very helpful for me.
     
  31. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    It is not possible to share a file with a text on some apps like Facebook without using their dedicated SDKs. NativeShare doesn't use any app-specific SDKs.

    P.S. For maximum compatibility, I'd recommend you to share only the file because some apps may decide to omit the file instead of omitting the text/subject.
     
    jhpark3 likes this.
  32. jhpark3

    jhpark3

    Joined:
    Dec 18, 2018
    Posts:
    2
    Thank you :)
     
  33. EXP_Dev

    EXP_Dev

    Joined:
    Jun 9, 2016
    Posts:
    3
    Hi, I'm trying to share an image in nativeshare and getting the can't find content provider error in logcat. When i look at my temp\stagingarea\androidmanifest.xml there is no provider node in there at all.

    I don't have any custom android manifests that need to be merged causing drama either, just using Unity 2019.2.7.
     
  34. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    You can try using the newest version on GitHub, it modifies the AndroidManifest automatically. Otherwise, please check out README.txt for the necessary AndroidManifest modifications.
     
  35. timuz

    timuz

    Joined:
    Nov 6, 2013
    Posts:
    2
    it is causing Unity to add Read_Phone_State permission why..?
     
  36. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,087
    Just fixed it with the latest release.