Native Share for Android & iOS [Open Source]

File must be stored somewhere on local storage; it can be temporary cache path or some other path. But note that you can’t directly share an asset in your project; assets are bundled into APK and first you have to somehow extract that asset to local file system.

Brilliant! Thank you. I spend ages composing emails in the background and writing images to the gallery.

Quick question… Is it possible to share/save to gallery on iOS into a specific album?

NativeGallery can save to a specific album on Android & iOS: Native Gallery for Android & iOS [Open Source]

NativeShare doesn’t support it.

1 Like

Hi,
I understand that to share some text I have to use …SetText(“http://google.com”);
But how do I attach an image to the message?

Thanks in advance!

You can use the AddFile function. See example code for reference.

works like a charm! thank you!

Hi,
I’m using your asset and it’s work very well.
There are any way to set the text or title in the Share Facebook popup when I choose this app??
I see that the SetText() and SetTitle() methods only work in Message or Email options.
If not, the are any other trick to do this?

Thanks in advance!

You’ll have to use Facebook SDK for that. You can then have 2 share buttons: one for Facebook-only share via Facebook SDK and one for general sharing via NativeShare.

hi yasirkula, i just want o share video but how share video is already recorded and it’s already in gallery.
i want to share by using it’s name not browsing it.

If you are using NativeGallery plugin to save the video to Gallery, then on Android, you can get the path of the video by calling NativeGallery.GetSavePath (change its visibility to public) before calling SaveVideoToGallery. On iOS, AFAIK, it is not possible to get the path of a video in Photos. You have to keep a separate copy of the video in e.g. Application.temporaryCachePath and share it, instead.

If you are not using NativeGallery and don’t know the path of the saved video, then the best thing you can do is to, again, keep a separate copy of the video at a specific path and share it, instead.

1 Like

Would there be any reason why instagram doesn’t show in the activity viewer on iOS?

I’m using this component and it works great! – But, I have instagram installed, but don’t see it in the list when I use this.

And, I did try to add it by tapping the ‘… more’ button at the end of the list. ( see attachment )

Instagram is only available while sharing images/videos only: Cannot find instagram app when sharing · Issue #14 · yasirkula/UnityNativeShare · GitHub. Unfortunately, that’s the default behaviour of Instagram app in the native iOS share dialog.

Would this fix it :

NSMutableArray *items = [NSMutableArray new];

if(mText != NULL && mText.length > 0){

//[items addObject:mText];

}

Commenting the mText?

You don’t have to tweak the source code. Just don’t use SetSubject and SetText functions and you should be fine.

Thanks!

Is this what you mean? This breaks the sharing when I comment these out.

   [DllImport("__Internal")] private static extern void showSocialSharing(ref SocialSharingStruct conf);

    public static void CallSocialShare(string title, string message)
    {
        ConfigStruct conf = new ConfigStruct();
        //conf.title = title;
        //conf.message = message;
        showAlertMessage(ref conf);
    }

    public static void CallSocialShareAdvanced(string defaultTxt, string subject, string url, string img)
    {
        SocialSharingStruct conf = new SocialSharingStruct();
        //conf.text = defaultTxt;
        conf.url = url;
        conf.image = img;
        //conf.subject = subject;

        showSocialSharing(ref conf);
    }

This code is from a different sharing plugin. Mine is available here: GitHub - yasirkula/UnityNativeShare: A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS. You can see the SetSubject and SetText functions in the Example Code.

Does it support callbacks? (ex: Is it possible to know wheter or not an user has actually shared the image through a social network or cancelled it before that?)

If it is, is it possible to tell which services he/she used?

I’m aiming for a feature in my app that rewards people based on the amount of content sharing they do in different platforms, so I’d need to know both when sharings actually go through completely, and which services were used.

Callbacks are not supported with this plugin. I believe the only way to support callbacks in a share action would be to use the native SDK of the specific platform, e.g. Facebook SDK.

Hi, i have problems with sharing a video. I pick the path of the video with NativeGallery and then: “new NativeShare().AddFile(_path).SetText(”“).Share();” but the sharing panel doesn’t appear.
I’m running in Unity 2018.1.2 and using an Android 7.0.