social_share_plugin icon indicating copy to clipboard operation
social_share_plugin copied to clipboard

Instagram and Twitter does not work onSuccess callback

Open CarmenLexa opened this issue 4 years ago • 11 comments

Hello and thanks for your help I am having problems with these two functions I can publish without any problem, but when detecting if that publication was successful I cannot get both functions for Twitter or instagram they return me onCancel

SocialSharePlugin.shareToTwitterLink(text: text, url: url, onSuccess: (_) { print('TWITTER SUCCESS'); call(0); return; }, onCancel: () { print('TWIITER CANCELLED'); call(1); return; } );

await SocialSharePlugin.shareToFeedInstagram(path:file.path, onSuccess:(value){ print('INSTAGRAM SUCCESS'); call(0); return; }, onCancel: (){ print('INSTAGRAM CANCELL'); call(1); return; } );

publishing succeeds but returns onCancel does not return onSuccess

CarmenLexa avatar Aug 06 '20 23:08 CarmenLexa

I am having the same problem did you find any solution?

RAIERIN avatar Sep 10 '20 13:09 RAIERIN

Facing the same issue any workaround for this one. For twitter it tweets but the response is tweet cancelled and the instagram does not do a return callback. Any quick fix for this one.

sagar2411 avatar Sep 11 '20 10:09 sagar2411

You have to add provider_path.xml file as mentioned in the document.

Then in androidmanifest.xml please add:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"package="com.example.name"> <meta-data android:name="com.facebook.sdk.ApplicationId"android:value="@string/facebook_app_id" /> <activity android:name="com.facebook.FacebookActivity"android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" /> <provider android:authorities="com.facebook.app.FacebookContentProvider{FACEBOOK_APP_ID}"android:name="com.facebook.FacebookContentProvider" android:exported="true" /> <provider android:name="androidx.core.content.FileProvider"android:authorities="${applicationId}.com.shekarmudaliyar.social_share" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"tools:replace="android:resource" />

Add these code and try. I made it worked finally!

RAIERIN avatar Sep 13 '20 15:09 RAIERIN

Just wast to ask you is that does it work for instagram and what about twitter. are you getting proper response. I have added all the above but getting same thing. Just let me know in this "{applicationId}.com.shekarmudaliyar.social_share" application_id is the package name right. Just let me know specifically that instagram and the twitter as working as per the functionility.

sagar2411 avatar Sep 14 '20 17:09 sagar2411

Yes, applicationId is you app package name. I was trying for facebook and it worked. I don't have any idea about insta and twitter. When I was trying for twitter everytime i get twitter cancelled. Did you add provider_paths.xml file??

RAIERIN avatar Sep 16 '20 09:09 RAIERIN

That's what the problem is you have opened a new issue its the same as above. Did you get any solution for those because i am still getting the same @RAIERIN

sagar2411 avatar Oct 13 '20 10:10 sagar2411

@sagar2411 no it is not working! I have not found any solutions yet!

RAIERIN avatar Oct 13 '20 11:10 RAIERIN

Hey @RAIERIN are you able to share via facebook i am getting some error, it was working fine till 2 days prior now it says api error and not able share it. Are you facing the same its only me who is getting the error.

sagar2411 avatar Oct 16 '20 10:10 sagar2411

Success callback is not working. Sharing is successful, but the result appears as a cancel.

I/ViewRootImpl@aff5d02MainActivity: ViewPostIme pointer 0 I/ViewRootImpl@aff5d02MainActivity: ViewPostIme pointer 1 I/ViewRootImpl@aff5d02MainActivity: MSG_WINDOW_FOCUS_CHANGED 0 1 I/SurfaceControl(11786): nativeRelease nativeObject s[513980740240] I/SurfaceControl(11786): nativeRelease nativeObject e[513980740240] I/SurfaceControl(11786): nativeRelease nativeObject s[513980731840] I/SurfaceControl(11786): nativeRelease nativeObject e[513980731840] I/SurfaceControl(11786): nativeRelease nativeObject s[513980729824] I/SurfaceControl(11786): nativeRelease nativeObject e[513980729824] I/SurfaceView(11786): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] I/SurfaceView(11786): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} W/libEGL (11786): EGLNativeWindowType 0x78cbac77b0 disconnect failed I/SurfaceView(11786): remove() from RT android.view.SurfaceView$2@c97da44 Surface(name=SurfaceView - co.kr.liveshare.liveshare_app/co.kr.liveshare.liveshare_app.MainActivity@fd86249@2)/@0x477767d I/SurfaceControl(11786): nativeRelease nativeObject s[513980592512] I/SurfaceControl(11786): nativeRelease nativeObject e[513980592512] I/SurfaceControl(11786): nativeRelease nativeObject s[513980539200] I/SurfaceControl(11786): nativeRelease nativeObject e[513980539200] W/libEGL (11786): EGLNativeWindowType 0x78cba16c80 disconnect failed I/SurfaceControl(11786): nativeRelease nativeObject s[513980594752] I/SurfaceControl(11786): nativeRelease nativeObject e[513980594752] I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xe798462 / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa8a474e / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/SurfaceControl(11786): nativeRelease nativeObject s[513980713808] I/SurfaceControl(11786): nativeRelease nativeObject e[513980713808] I/SurfaceControl(11786): nativeRelease nativeObject s[513980739792] I/SurfaceControl(11786): nativeRelease nativeObject e[513980739792] I/ViewRootImpl@aff5d02MainActivity: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=2 res=0x5 s={false 0} ch=true fn=2 I/SurfaceView(11786): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] D/InputTransport(11786): Input channel destroyed: 'ClientS', fd=124 I/SurfaceControl(11786): nativeRelease nativeObject s[513980594752] I/SurfaceControl(11786): nativeRelease nativeObject e[513980594752] I/ViewRootImpl@aff5d02MainActivity: stopped(true) old=false I/SurfaceView(11786): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xe798462 / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa8a474e / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/ViewRootImpl@aff5d02MainActivity: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)4 dur=18 res=0x1 s={false 0} ch=false fn=-1 D/SocialSharePlugin(11786): Twitter cancelled. I/flutter (11786): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TWITTER CANCELLED I/ViewRootImpl@aff5d02MainActivity: stopped(false) old=true I/ViewRootImpl@aff5d02MainActivity: stopped(false) old=false

ilyoungkim avatar May 22 '21 13:05 ilyoungkim

Facebook case,

I/SurfaceView(11786): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xe798462 / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa8a474e / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/ViewRootImpl@aff5d02MainActivity: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)4 dur=12 res=0x1 s={false 0} ch=false fn=-1 I/ViewRootImpl@aff5d02MainActivity: stopped(false) old=true I/SurfaceView(11786): onWindowVisibilityChanged(0) false io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] I/SurfaceControl(11786): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa8a474e / android.view.SurfaceControl.readFromParcel:1115 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 I/ViewRootImpl@aff5d02MainActivity: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)0 dur=7 res=0x7 s={true 518813789744} ch=true fn=-1 I/SurfaceView(11786): windowStopped(false) true io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} of ViewRootImpl@aff5d02[MainActivity] I/SurfaceView(11786): surfaceCreated 1 #1 io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} I/SurfaceView(11786): surfaceChanged (1080,2256) 1 #1 io.flutter.embedding.android.FlutterSurfaceView{fd86249 V.E...... ........ 0,0-1080,2256} I/ViewRootImpl@aff5d02MainActivity: [DP] dp(1) 1 android.view.SurfaceView.updateSurface:1311 android.view.SurfaceView.setWindowStopped:343 android.view.SurfaceView.surfaceCreated:1835 I/ViewRootImpl@aff5d02MainActivity: [DP] pdf(0) 1 android.view.SurfaceView.notifyDrawFinished:577 android.view.SurfaceView.performDrawFinished:564 android.view.SurfaceView.lambda$TWz4D2u33ZlAmRtgKzbqqDue3iM:0 I/ViewRootImpl@aff5d02MainActivity: [DP] rdf() I/ViewRootImpl@aff5d02MainActivity: updateBoundsLayer: shouldReparent = true t = android.view.SurfaceControl$Transaction@af836f8 sc = Surface(name=Bounds for - co.kr.liveshare.liveshare_app/co.kr.liveshare.liveshare_app.MainActivity@8)/@0xdd8e1a7 frame = 1 I/ViewRootImpl@aff5d02MainActivity: [DP] dp(1) 1 android.view.ViewRootImpl.reportNextDraw:10957 android.view.ViewRootImpl.performTraversals:3845 android.view.ViewRootImpl.doTraversal:2618 I/ViewRootImpl@aff5d02MainActivity: [DP] pd() Asnyc report I/SurfaceView(11786): setParentSpaceRectangle: useBLAST = false position = Rect(0, 0 - 1080, 2256) frameNumber = 1 t = android.view.SurfaceControl$Transaction@d4417c I/SurfaceView(11786): applySurfaceTransforms: t = android.view.SurfaceControl$Transaction@d4417c surfaceControl = Surface(name=SurfaceView - co.kr.liveshare.liveshare_app/co.kr.liveshare.liveshare_app.MainActivity@fd86249@8)/@0x8432654 frame = 1 I/SurfaceView(11786): applySurfaceTransforms: postScaleX = 1.0 postScaleY = 1.0 I/ViewRootImpl@aff5d02MainActivity: [DP] pdf(0) 1 android.view.ViewRootImpl.lambda$performDraw$1$ViewRootImpl:4668 android.view.-$$Lambda$ViewRootImpl$DJd0VUYJgsebcnSohO6h8zc_ONI.run:6 android.os.Handler.handleCallback:938 I/ViewRootImpl@aff5d02MainActivity: [DP] rdf() D/SocialSharePlugin(11786): Sharing successfully done. I/ViewRootImpl@aff5d02MainActivity: stopped(false) old=false I/flutter (11786): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FACEBOOK SUCCESS

ilyoungkim avatar May 22 '21 13:05 ilyoungkim

External Libraries > Flutter Plugins > social_share_plugin-0.3.1+1 > andorid > src.main > java.com.cygnati.social_share_plugin > SocialSharePlugin file in, Not Implemnets Twitter, and Instagram ... plz. fix it as fast as.

private void instagramShare(String type, String imagePath) {
    final File image = new File(imagePath);
    final Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".social.share.fileprovider",
            image);
    final Intent share = new Intent(Intent.ACTION_SEND);
    share.setType(type);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.setPackage(INSTAGRAM_PACKAGE_NAME);
    share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    final Intent chooser = Intent.createChooser(share, "Share to");
    final List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(chooser,
            PackageManager.MATCH_DEFAULT_ONLY);

    for (ResolveInfo resolveInfo : resInfoList) {
        final String packageName = resolveInfo.activityInfo.packageName;
        activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }

    activity.startActivityForResult(chooser, INSTAGRAM_REQUEST_CODE);
}

private void facebookShare(String caption, String mediaPath) {
    final File media = new File(mediaPath);
    final Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".social.share.fileprovider",
            media);
    final SharePhoto photo = new SharePhoto.Builder().setImageUrl(uri).setCaption(caption).build();
    final SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();
    final ShareDialog shareDialog = new ShareDialog(activity);
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            channel.invokeMethod("onSuccess", null);
            Log.d("SocialSharePlugin", "Sharing successfully done.");
        }

        @Override
        public void onCancel() {
            channel.invokeMethod("onCancel", null);
            Log.d("SocialSharePlugin", "Sharing cancelled.");
        }

        @Override
        public void onError(FacebookException error) {
            channel.invokeMethod("onError", error.getMessage());
            Log.d("SocialSharePlugin", "Sharing error occurred.");
        }
    });

    if (ShareDialog.canShow(SharePhotoContent.class)) {
        shareDialog.show(content);
    }
}

private void facebookShareLink(String quote, String url) {
    final Uri uri = Uri.parse(url);
    final ShareLinkContent content = new ShareLinkContent.Builder().setContentUrl(uri).setQuote(quote).build();
    final ShareDialog shareDialog = new ShareDialog(activity);
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            channel.invokeMethod("onSuccess", null);
            Log.d("SocialSharePlugin", "Sharing successfully done.");
        }

        @Override
        public void onCancel() {
            channel.invokeMethod("onCancel", null);
            Log.d("SocialSharePlugin", "Sharing cancelled.");
        }

        @Override
        public void onError(FacebookException error) {
            channel.invokeMethod("onError", error.getMessage());
            Log.d("SocialSharePlugin", "Sharing error occurred.");
        }
    });

    if (ShareDialog.canShow(ShareLinkContent.class)) {
        shareDialog.show(content);
    }
}

private void twitterShareLink(String text, String url) {
    final String tweetUrl = String.format("https://twitter.com/intent/tweet?text=%s&url=%s", text, url);
    final Uri uri = Uri.parse(tweetUrl);
    activity.startActivityForResult(new Intent(Intent.ACTION_VIEW, uri), TWITTER_REQUEST_CODE);
}

ilyoungkim avatar May 22 '21 14:05 ilyoungkim