Facebook SDK 4.0 AppInviteDialog with callback

房东的猫 提交于 2019-12-18 03:32:29

问题


In the new Fb SDK 4.0 for Android you can register a callback for the LoginButton according to the docs. https://developers.facebook.com/docs/facebook-login/android/v2.3

The question is is this possible for the AppInviteDialog as well? Or is there any other way to identify if the App-Invite was successful or not?


回答1:


Yes, this is possible.

public static void openDialogInvite(final Activity activity)
{
    String appLinkUrl, previewImageUrl;

    appLinkUrl = "your app link url";
    previewImageUrl = "https://www.example.com/my_invite_image.jpg";

    if (AppInviteDialog.canShow())
    {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(appLinkUrl)
                .setPreviewImageUrl(previewImageUrl)
                .build();

        AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
        CallbackManager sCallbackManager = CallbackManager.Factory.create();
        appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
        {
            @Override
            public void onSuccess(AppInviteDialog.Result result)
            {
            }

            @Override
            public void onCancel()
            {
            }

            @Override
            public void onError(FacebookException e)
            {
            }
        });

        appInviteDialog.show(content);
    }
}


来源:https://stackoverflow.com/questions/29515872/facebook-sdk-4-0-appinvitedialog-with-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!