Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Facebook SDK Share dialog: never return Completion Gesture

I am using facebook android sdk v3.5 in my app for messsage sharing. For statistics I need to track if the message was successfully posted or not. However I always get null by getting FacebookDialog.getNativeDialogCompletionGesture in onActivityResult()

The code I use is very standard.

Code to call facebook share dialog:

    private void sendToFacebook()
    {
        if (!FacebookDialog.canPresentShareDialog(getActivity().getApplicationContext(),        FacebookDialog.ShareDialogFeature.SHARE_DIALOG))
        {
         return;
        }

        FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(getActivity())
                .setName(getString(R.string.refer_friend_facebook_name))
                .setDescription(getString(R.string.refer_friend_facebook_description))
                .setCaption(getString(R.string.facebook_app_name))
                .setLink(getString(R.string.web_endpoint))
                .setPicture(getString(R.string.facebook_picture_90))
                .build();

        activity.getFacebookUiHelper().trackPendingDialogCall(shareDialog.present());

    }

Code I use to process call result:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data)
    {
            facebookUiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback()
            {
                @Override
                public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data)
                {
                 // track on error                                                   
                }

                @Override
                public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data)
                {
                    if (FacebookDialog.getNativeDialogDidComplete(data))
                    {
                        if (FacebookDialog.getNativeDialogCompletionGesture(data) == null 
                              || FacebookDialog.COMPLETION_GESTURE_CANCEL.equals(FacebookDialog.getNativeDialogCompletionGesture(data)))
                        {
                            // track cancel                                                   
                        }
                        else
                        {
                            // track post
                        }
                    }
                    else
                    {
                        // track cancel              
                    }
                }
            });
}

In facebook sdk documentation it is stated that:

FacebookDialog.getNativeDialogCompletionGesture - Only available if the user logged into your app using Facebook and did complete is true. Value is either "post" or "cancel".

But I can not understand what exactly do they mean by this phrase.

like image 566
Alexey A. Avatar asked Sep 25 '13 18:09

Alexey A.


1 Answers

It means that you only get the completionGesture if the user has "auth"ed your app (i.e. they've clicked on some form of login via Facebook button in your app, and gave your app at least basic permissions).

If they have not, then all you get is getNativeDialogDidComplete, which always returns true (whether the user clicked "Share" or "Cancel") unless an error occurred.

like image 132
Ming Li Avatar answered Nov 04 '22 06:11

Ming Li