Native Share for Android & iOS [Open Source]

Try adding the following line to ProGuard filters: -keep class com.yasirkula.unity.* { *; }

1 Like

It works perfectly for me on iOS, but when I test it on the Android version of my app, the content provider does not show up… I think I setup the AndroidManifest correctly but I included it. Is there something I need to add in the New NativeShare object?

3622030–294862–AndroidManifest.txt (4.08 KB)

I am using your assets and simple text and links are working totally fine but when I am sharing image using native share dialog it says “can’t find content provider, share is not possible”

This is code I am using to take screenshot and share
please help me with this

private IEnumerator TakeSSAndShare ()
    {
        yield return new WaitForEndOfFrame ();

        Texture2D ss = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
        ss.ReadPixels (new Rect (0, 0, Screen.width, Screen.height), 0, 0);
        ss.Apply ();

        string filePath = Path.Combine (Application.temporaryCachePath, "shared img.png");
        print ("File path is Asad: " + filePath);
        File.WriteAllBytes (filePath, ss.EncodeToPNG ());

        // To avoid memory leaks
        Destroy (ss);

        new NativeShare ().AddFile (filePath).SetSubject ("Subject goes here").SetText ("Hello world!").Share ();

        // Share on WhatsApp only, if installed (Android only)
        if (NativeShare.TargetExists ("com.whatsapp"))
            new NativeShare ().AddFile (filePath).SetText ("Hello world!").SetTarget ("com.whatsapp").Share ();
    }

My manifest is attached below

3626272–295288–AndroidManifest.txt (1.53 KB)

@Fynxx @Shumail make sure that AndroidManifest is located exactly at Assets/Plugins/Android/AndroidManifest.xml, i.e. it should have xml extension and it should be located inside Plugins/Android and not Plugins/NativeShare/Android. Also make sure that <provider ... /> is inside <application>...</application>, not <activity>...</activity>.

I am not sure but when I tried to use yasikula’s Native Camera + Native Gallery at the same time, this exception occurred.
after removing native camera(and adjusted android manifest), I could use native gallery without error.

I have used your plugin. It is superb… I have shared my image in fb, twitter. when i post my image in skype.only text message is displaying. Not my image is sharing… What i have to do…

Another Doublt… I have paint option. and i want record how they users are painting. Did this plugin helps to record. and to share…

is there any want to convert into gif and upload to fb, or skype or anything…

My Image is sharing in fb and twitter. But Skype my image is not posted… Only text message is displaying. What i have to do…

Not working in my case give some error like :

NativeShare' does not contain a definition for AddFile’ and no extension method AddFile' of type NativeShare’ could be found. Are you missing an assembly reference?

@tjPark If you use NativeShare+NativeCamera together, you need to have at least two <provider ... />s in your AndroidManifest (one for each plugin). Maybe you replaced one with the other?

@Alexander21 Some apps (like Facebook and apparently Skype) may not support image+text combination. NativeShare doesn’t have any app-specific logic, so if an app doesn’t support image+text sharing, it is not possible to alter that behaviour :confused: For consistency, you may prefer to share only text or only image.

@chandu1994 Are there any other NativeShare classes in your project? If so, try renaming mine to NativeShare2 and use NativeShare2 in your code.

@yasirkula Thanks For Your Reply… Yas i have removed the text and i have shared the image in Skype. It is sharing the image. But Another one thing

When i share the image in fb… it takes time. When i post the image. The black screen is displaying.round symbol comes to start to end point . after it says the image is posted…

but twitter is posting immediately… Skype it says the uploading time that is (20 % to 100% ) and it send to receipent.

Fb is displaying black screen after it says posted. What is the reason . How can i avoid it…

I honestly don’t know. NativeShare just creates an Intent and the Intent launches the Facebook activity. There is no intentional black screen in the process.

@ yasirkula Actually When i click the share button the image is posting in facebook. After i click post button.A black screen is displaying and file upload and it says

connection is taking longer than normal to upload facebook and it says posted…

is there any solution… or anything wrong in my side…

I don’t think there is anything wrong on your side. You can try the app on another device to see if the issue is persistent there. But regardless, I don’t know any solutions for this behaviour.

@ysirkula

I’ve tried out your plugin and it was really easy to integrate and use. One thing that I noticed is that for Android 7.1 devices that I tested with, the chooser popup that shows all the apps that can handle the share intent doesn’t show in fullscreen. The status and navigation bars show up and the navigation bar obscures the bottom of the chooser popup (which also obscures any apps displayed on that row). Do you have any thoughts on how I might go about correcting this issue? Either hiding the status/navigation bars or moving the popup so that nothing is obscured. Thanks in advance.

That’s interesting. Does the navigation bar not become invisible after a few seconds? Is the status bar also visible while navigation bar is visible? Is it possible that the navigation bar appears due to a finger swipe near the bottom of the screen? Can I see a screenshot?

No. The navigation bar remains until I dismiss the chooser popup.

Yes. The status bar and soft navigation bar are made visible when the chooser popup is displayed.

No. I’ve been careful to avoid touching the screen after triggering the chooser popup to display.

Attached.

1 Like

Hii i am a little new to this so can you pls help me, i want to share the screenshot of my game with a link to go to download the game (link depends on ios or android) and a text saying the highscore
Thank you for the answer in advance :slight_smile:

@Meepo0_1 Please see the example code that shares screenshot with “Hello world!” text, which you can replace with your own text: GitHub - yasirkula/UnityNativeShare: A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS. I’d recommend you to remove the SetSubject function from the chain, though.

@yasirkula Hey Thanks for the help but after putting the code it shows the error on the line :

new NativeShare().AddFile(filePath).SetSubject(“Subject goes here”).SetText(“Hello world!”).Share();

says that namespace NativeShare could not be found i also added the using NatShareU; on top but still show the error

thanks for help :slight_smile:

Are you sure that you’ve imported the correct NativeShare plugin? Because mine doesn’t use NatShareU namespace. Maybe you are looking for this thread: NatShare - Free Sharing API