Search code examples
androidfacebookfacebook-sdk-4.0

'com.facebook.share.model.AppInviteContent' is deprecated


My function is not working it shows com.facebook.share.model.AppInviteContent is deprecated in the tool tip :

(AppInviteDialog.canShow()) {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(appLinkUrl)
                .build();
        AppInviteDialog appInviteDialog = new AppInviteDialog(MainActivity.this);
        CallbackManager sCallbackManager = CallbackManager.Factory.create();
        appInviteDialog.registerCallback(sCallbackManager,
                new FacebookCallback<AppInviteDialog.Result>() {
                    @Override
                    public void onSuccess(AppInviteDialog.Result result) {
                        Log.d("Invitation", "Invitation Sent Successfully");
                        Toast.makeText(getApplicationContext(), "Invitation Sent Succseesfully", Toast.LENGTH_LONG).show();

                    }

                    @Override
                    public void onCancel() {
                        Log.d("Invitation", "Invitation Cancel Successfully");
                    }

                    @Override
                    public void onError(FacebookException e) {
                        Log.d("Invitation", "Error Occured");
                    }

                });

Can anyone help me with this? Or is there any other way around to achieve this?


Solution

  • This is deprecated due that Facebook will no more support this functionality. It is supported until February 5,2018. I guess more information you can find on theirs page https://developers.facebook.com/docs/app-invites/android/.

    Update

    To make App Invites work change Facebook SDK from 4.28.0 in gradle file to for example 4.15.0(I've tested this one). There is one issue with it, it will only work if you have Facebook app installed on phone, otherwise it shows blank screen - it is reported as bug in theirs tech support https://developers.facebook.com/bugs/2172237199676104/.