6

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.

4

1 回答 1

3

这意味着只有当用户“授权”了您的应用程序时,您才能获得 completionGesture(即他们在您的应用程序中通过 Facebook 按钮单击了某种形式的登录,并为您的应用程序提供了至少基本权限)。

如果他们没有,那么您得到的只是 getNativeDialogDidComplete,它始终返回 true(无论用户单击“共享”还是“取消”),除非发生错误。

于 2013-09-26T23:25:33.923 回答