social_share
social_share copied to clipboard
Direct Instagram Story Sharing `shareInstagramStory` fails to open Instagram app
When I try to share Instagram Story directly via SocialShare.shareInstagramStory
, it doesn't work for me. No error messages. Instagram app isn't opened. It fails with following log only:
D/ ( 5309): com.example.igb_publishing_poc.MainActivity@c5fdd71
I/flutter ( 5309): error
However, it works only if I try to share via Native options (SocialShare.shareOptions
) first. After I try Native options
->Instagram Stories
, then shareInstagramStory
starts working as expected. It keeps working until emulator is restarted.
Note that sharing a Story via Native Options doesn't work as expected. Instagram app is opened with no image. When options as opened, I get following error logs:
E/DatabaseUtils( 5309): Writing exception to parcel
E/DatabaseUtils( 5309): java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.example.igb_publishing_poc.com.shekarmudaliyar.social_share/image/stickerAsset.png from pid=5577, uid=1000 requires the provider be exported, or grantUriPermission()
E/DatabaseUtils( 5309): at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:820)
E/DatabaseUtils( 5309): at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
E/DatabaseUtils( 5309): at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:674)
E/DatabaseUtils( 5309): at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:548)
E/DatabaseUtils( 5309): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:327)
E/DatabaseUtils( 5309): at android.os.Binder.execTransactInternal(Binder.java:1154)
E/DatabaseUtils( 5309): at android.os.Binder.execTransact(Binder.java:1123)
However, Instagram Direct
& Instagram Feed
sharing work well.
Emulator: Nexus 5, API 30, Android 11.0 x86
Flutter 3.0.2, Dart 2.17.3
Same for me, calling share ig stories prints similar log you provided
D/ ( 5309): com.xxx.xxx.MainActivity@c5fdd71
same issue for me as well with social_share: ^2.2.1
same issue for me. Version of social_share is 2.2.1
After trying to solve this issue for way too long, I found out that since Android 11 there are more restrictions on how other apps on the phone can be queried (https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9).
So adding this to the AndroidManifest.xml
solved the issue for me:
<manifest package="com.example.your_package">
<queries>
<package android:name="com.instagram.android" />
</queries>
...
</manifest>
The example is improved with all the latest Android 11 manifest tags and more features here: https://github.com/ShekarMudaliyar/social_share/issues/116
After trying to solve this issue for way too long, I found out that since Android 11 there are more restrictions on how other apps on the phone can be queried (https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9).
So adding this to the
AndroidManifest.xml
solved the issue for me:<manifest package="com.example.your_package"> <queries> <package android:name="com.instagram.android" /> </queries> ... </manifest>
you should add this for await SocialShare.checkInstalledAppsForShare()
too