Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Native Share for Android & iOS [Open Source]

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

Thread Status:
Not open for further replies.
  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:
    2,783
    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:
    10
    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:
    2,783
    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:
    491
    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:
    2,783
    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:
    2,783
    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:
    2,783
  11. eagle9401

    eagle9401

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

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
    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:
    2,783
    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:
    13
    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:
    2,783
    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:
    25
    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:
    2,783
    I might have to see your share script.
     
  19. tesan

    tesan

    Joined:
    Oct 1, 2014
    Posts:
    8
    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:
    25
    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:
    2,783
  23. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    324
    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:
    2,783
    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:
    2,783
  27. WelchCompositions

    WelchCompositions

    Joined:
    Sep 30, 2013
    Posts:
    29
    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:
    2,783
    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:
    5
    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:
    2,783
    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:
    6
    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:
    2,783
    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:
    2,783
    Just fixed it with the latest release.
     
  37. Nyarlukhotep

    Nyarlukhotep

    Joined:
    Jun 12, 2017
    Posts:
    3
    Hi. Tell me please how can I send a file to a specific application? As an example, I need to open a presentation in Keynote app (iOS), is it possible to do this without additional steps?
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
    You can only narrow down the options in the share sheet (example), you can't share on an app directly on iOS using NativeShare. For apps like Facebook, it requires using their own Unity SDKs but for Keynote I don't know how it can be accomplished.
     
  39. Nyarlukhotep

    Nyarlukhotep

    Joined:
    Jun 12, 2017
    Posts:
    3
    Thanks!
     
  40. biigweerakorn

    biigweerakorn

    Joined:
    Dec 14, 2017
    Posts:
    1
    how to know sharing success or fail, thank you
     
  41. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
  42. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    280
    Hi, i am trying to print a document.
    I print it correctly if i share the image from the gallery, but when i use unity:

    new NativeShare().AddFile(urlBuono).SetTarget("it.custom.printservice.customprintservice")/*.SetSubject("Subject goes here").SetText("Hello world!")*/.Share();


    it let me select the printer trought the plugin, it give me NO ERROR OR WARNING AT ALL.

    anyone can help?
     
  43. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
    This part confused me.
    • Does calling the Share function of the NativeShare plugin let you select the printer?
      • if so, is this issue about the document not getting printed out after selecting a printer? I don't think I can do much about that.
    • Or, are you talking about the gallery app's share dialog?
      • if so, does the printer show up in the share dialog if you remove the SetTarget function? If it does, then probably the target it.custom.printservice.customprintservice package name is somehow wrong. Please double check it. Use NativeShare.FindTarget if you have to. And make sure that you are using logcat to check error or warning messages.
     
  44. nemesiscy

    nemesiscy

    Joined:
    Aug 6, 2014
    Posts:
    7
    Hi, I am trying to only share something via specific platforms (facebook, email, linkedin) and don't want other apps to be shown. Is this possible with the plugin?
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
  46. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    @yasirkula Hello please help after add in manifest

    <provider
    android:name="com.yasirkula.unity.NativeShareContentProvider"
    android:authorities="MY_UNIQUE_AUTHORITY"
    android:exported="false"
    android:grantUriPermissions="true" />

    and build game to android after install it i got this
    Unfortunately, Game has stopped
     
  47. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,783
    You should no longer add that provider manually, it is added automatically.
     
  48. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    Thank you for your response ok i will remove it and test it again
     
  49. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    After removed it from Manifest the share button not working
     
  50. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    How can i fix it please ?
     
Thread Status:
Not open for further replies.