Setup

https://assetstore.unity.com/packages/tools/integration/facebook-story-kit-for-android-163340

Share

Sharing content using Facebook Share helper is easier than anything else, but before that there are a few things that needs to be done.

  • Open your main AndroidManifest.xml file in Assets/Plugins/Android/ folder and add this code inside tag:

<provider
     android:name="androidx.core.content.FileProvider"
     android:authorities="com.package.name.fileprovider"
     android:exported="false"
     android:grantUriPermissions="true">
     <meta-data
           android:name="android.support.FILE_PROVIDER_PATHS"
           android:resource="@xml/file_paths"/>
</provider>

Where com.package.name is the package name of your application.

  • Add this permission if it's not already included in your AndroidManifest.xml file:

 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  • Last but not least add <queries> tag inside your manifest file:

<queries>
   <package android:name="com.facebook.katana" />
</queries>

Here is a sample AndroidManifest.xml file:

And after the setup is complete you can use the helper class as:

Build Errors

If you encounter an issue: unexpected element <queries> found in <manifest>

There is an easy fix for that: go to File -> Build Settings -> Player Settings -> Publishing Settings and select Custom Base Gradle Template. After that open the generated file baseProjectTemplate.gradle under Assets/Plugins/Android folder and change com.android.tools.build:gradle:*** to

Unity 2019.4+ -> com.android.tools.build:gradle:3.4.3

Unity 2021.3+ -> com.android.tools.build:gradle:4.0.1

Last updated