NOTICE: This asset is no longer maintained! Consider using alternative sharing solutions that are actively being maintained. While using this package, expect issues when sharing a file/image/video with a text (see FAQ).
Hello there,
Native Share, as the name implies, is a plugin to natively share file(s) and/or text from within your app on Android and iOS. It supports sharing multiple files and adding subject/text to the shared content. It uses a ContentProvider on Android to support the latest versions of Android, as well.
Asset Store: Native Share for Android & iOS | Integration | Unity Asset Store
Also available at: GitHub - yasirkula/UnityNativeShare: A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
Discord: yasirkula Unity Assets
Support the developer
FAQ
- Can I share on a specific app?
- I canât share image with text on X app
It is just not possible to share an image/file with text/subject on some apps (e.g. Facebook), they intentionally omit either the image or the text from the shared content. These apps require you to use their own SDKs for complex share actions. For best compatibility, Iâd recommend you to share either only image or only text.
- I canât build the project to Android, it says âAndroid resource linking failed: unexpected element found in â in the error message
NativeShare adds <queries>
element to AndroidManifest.xml due to the new package visibility change. The build error can be fixed by following these steps: ŰŻŰčÙ
ŰŰČÙ
Ű© ARCore ÙÙ
Ű·ÙÙŰ±Ù Unity | Google for Developers (in my tests, changing âGradle installed with Unityâ wasnât necessary). In the worst case, if you are OK with NativeShare not working on some of the affected devices, then you can open NativeShare.aar with WinRAR or 7-Zip and then remove the <queries>...</queries>
element from AndroidManifest.xml.
- When using Unity as a Library on Android, the app crashes when sharing a file
If youâre running the Unity activity in a separate process, then modify AndroidManifest.xml inside NativeShare.aar so that both NativeShareCustomShareDialogActivity
and NativeShareBroadcastListener
also run on the same process, e.g:
<activity android:name=".NativeShareCustomShareDialogActivity" ... android:process=":YourProcess" />
<receiver android:name=".NativeShareBroadcastListener" ... android:process=":YourProcess" />
- Canât share, it says âjava.lang.ClassNotFoundException: com.yasirkula.unity.NativeShareâ in Logcat
If you are sure that your plugin is up-to-date, then enable Custom Proguard File option from Player Settings and add the following line to that file: -keep class com.yasirkula.unity.* { *; }
Enjoy!