Native Share for Android & iOS [Open Source]

Does removing SetText(“”) change anything? If not, could you please check logcat for any error messages?

I have your plugin all setup, AndroidManifest changes made setup the call from a script just like in your example but when I click the share it comes up saying “All apps associated with this action have been turned off, blocked, or are not installed”

This is strange because I can share just fine from other apps.

Unity: 2017.4.5f1
Min API: 16
Target API: 25

Ideas? Thanks!

This is the first time I see this error message. What kind of file(s) are you trying to share? Does it work when you try to share text only? Or when you use the example code?

I am just doing a screenshot and then calling:

“new NativeShare().AddFile( filePath ).SetSubject( “Beat My Beep Beep Blitz Score!” ).SetText( “Get Beep Beep Blitz at: https://play.google.com/store/apps/details?id=com.CSA.beepbeepblitz” ).SetTarget(“com.CSA.beepbeepblitz”).Share();”

I recompiled to just do a Text Only call: “new NativeShare().SetText( “http://google.com” ).Share();” and I got a screen that shows the apps to share from so this looks good.

I have attached a text file with both the AndroidManifest and Share script in it.

Duh!!! It was my use of SetTarget. I thought it was to put my app bundle ID but it is to call a specific app for sharing.

Everything works great once I removed that.

Thanks for a great asset!

1 Like

I was about to write the same thing. Glad it works now.

Thanks! I left a 5 star review on your plugin!

I appreciate it, thanks :slight_smile:

1 Like

Can I also load the files back into the app on iOS? I would like to share a config text file, edit it/replace it and load it again when the app starts the next time.

Only sharing functionality is provided with NativeShare. If you don’t want to let the user select the text file but rather load it from a predefined location like Application.persistentDataPath, you can simply use File.WriteAllText and File.ReadAllText functions.

Hi, why when i use
new NativeShare().AddFile(screenShotPath).SetSubject(“Subject goes here”).SetText(“Hello world!”).Share();
in Telegram,Twiter i can see text “Hello world!” but in facebook and instagram is empty

its better plugin,sorry from my english

1 Like

While sharing content via native share dialog, Facebook only accepts an image or a text, not both. If both are provided, then Facebook omits the text automatically. The only way to share image+text on Facebook is via their Facebook SDK, which this plugin doesn’t use. I’m guessing that Instagram also fails for a similar reason.

1 Like

@yasirkula not woking android 7 and above. i found this exception

AndroidJavaException: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.wiz.weed.game.editor_sharev5/files/screenshot.jpg exposed beyond app through ClipData.Item.getUri()
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.wiz.weed.game.editor_sharev5/files/screenshot.jpg exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1975)
at android.net.Uri.checkFileUriExposed(Uri.java:2363)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:941)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9944)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9950)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9929)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1622)
at android.app.Activity.startActivityForResult(Activity.java:4751)
at android.app.Activity.startActivityForResult(Activity.java:4691)
at android.app.Activity.startActivit

I didn’t expect to see this error here because NativeShare uses a FileProvider to not expose file uris. Can you test your code on another device and try to share on another app to see if this issue is consistent across all devices? Please also make sure that you are using NativeShare and not another sharing solution by mistake (it happened once ^^). It may also be helpful to see a short snippet from your share code.

Hi Yasirkula! Thank you so much for share your plugin! it’s amazing :wink:

After add ManifestContainer.aar to my /Plugins/NativeShare/Android directory, my phone start asking me for make Calls permission.

Is that strictly necessary?

1 Like

NativeShare doesn’t use any .aar files. You may be using a different share plugin.

EDIT: Wait, that’s the custom aar that I’ve posted previously. Let me see what can be done.

EDIT2: You can try adding <uses-sdk android:minSdkVersion="4" /> or <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4" /> before the tag. However, I’d really suggest you to edit the main AndroidManifest file as suggested in the documentation, rather than using an aar file.

Thank you for your answer :wink:

If a remove the .arr file, I get an “Can’t file ContentProvider, share not possible!” error. Only this file resolved the issue, but maybe I have something wrong in my Manifest… :expressionless:

3573374–288369–AndroidManifest.txt (1.38 KB)

I don’t think you need <meta-data … /> inside the provider. Other than that, assuming that your manifest is located exactly at Assets/Plugins/Android (and not at e.g. Assets/Plugins/NativeShare/Android) with .xml extension, everything seems OK.

You are totally right!! :wink:

Now the puglin is working perfectly for me, thank you so much!

1 Like

Hey yasirkula, a few questions:

  1. what is the target for Twitter? I can’t seem to figure that out
  2. settarget only works for android yes? is there something similar we can do for ios?

thanks!