Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK 4.0 AppInviteDialog with callback

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?

like image 725
Philipp R. Steiner Avatar asked Apr 08 '15 13:04

Philipp R. Steiner


People also ask

What is Facebook SDK version?

The current version of the Facebook SDK for Android is version 15.1. 0 and requires the Android API 15. Code and samples for the Facebook SDK for Android are available on GitHub. When you use the Facebook SDK for Android, follow the Facebook Open Source Terms of Use and Privacy Policy.


1 Answers

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);
    }
}
like image 179
Karim Varela Avatar answered Oct 19 '22 13:10

Karim Varela