romatroskin / social_share_plugin

Social Share to Facebook and Instagram Flutter plugin.
BSD 2-Clause "Simplified" License
41 stars 86 forks source link

Share to instragram feed not working #9

Closed alebuffoli closed 4 years ago

alebuffoli commented 4 years ago

hello, I'm having issues using

    await SocialSharePlugin.shareToFeedInstagram('image/*', dirFile.path);

instead

    await SocialSharePlugin.shareToFeedFacebook(typePost, dirFile.path);

works perfectly.

When I try to share the post on Instagram I'm getting this error:

Failed to handle method call
E/MethodChannel#social_share_plugin( 7151): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.fobu.repost_lab.social.share.fileprovider
E/MethodChannel#social_share_plugin( 7151):     at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
E/MethodChannel#social_share_plugin( 7151):     at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
E/MethodChannel#social_share_plugin( 7151):     at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
E/MethodChannel#social_share_plugin( 7151):     at com.cygnati.social_share_plugin.SocialSharePlugin.instagramShare(SocialSharePlugin.java:204)
E/MethodChannel#social_share_plugin( 7151):     at com.cygnati.social_share_plugin.SocialSharePlugin.onMethodCall(SocialSharePlugin.java:134)
E/MethodChannel#social_share_plugin( 7151):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#social_share_plugin( 7151):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#social_share_plugin( 7151):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#social_share_plugin( 7151):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#social_share_plugin( 7151):     at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#social_share_plugin( 7151):     at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#social_share_plugin( 7151):     at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#social_share_plugin( 7151):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#social_share_plugin( 7151):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#social_share_plugin( 7151):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter ( 7151): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Couldn't find meta-data for provider with authority com.fobu.repost_lab.social.share.fileprovider, null)
E/flutter ( 7151): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 7151): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter ( 7151): <asynchronous suspension>
E/flutter ( 7151): #2      SocialSharePlugin.shareToFeedInstagram (package:social_share_plugin/social_share_plugin.dart:18:21)
E/flutter ( 7151): <asynchronous suspension>

Thankyou

alebuffoli commented 4 years ago

I've found a solution.

You should write in the installing section to add this code into the AndroidManifest.xml

<provider android:name="androidx.core.content.FileProvider"
            android:authorities="{YOUR.APPLICATIOND.ID}.social.share.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

and edit the android:authorities="{YOUR.APPLICATIOND.ID}.social.share.fileprovider" with the current application id

romatroskin commented 4 years ago

it was written in README section and also have an example in example folder :)