Facebook App Invite, Invite Friends
Asked Answered
S

5

21

I switched to Facebook 4.0 in order to implement AppInviteDialog for Android. I followed this reference.

The dialog appears, I can select friends, invite them, I get the onSuccess() call, but my friends don't get the invite.

I have used the below applink URL: https://fb.me/****412097*****

No previewImageURL although I saw my app's image on the dialog.

Code:

//Inside onCreate -

        callbackManager = CallbackManager.Factory.create();

        mInvititeDialog = new AppInviteDialog(this);
        mInvititeDialog.registerCallback(callbackManager,
                new FacebookCallback<AppInviteDialog.Result>() {

                    @Override
                    public void onSuccess(Result result) {
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this,
                                "Invitation Sent Successfully!");
                        finish();
                    }

                    @Override
                    public void onCancel() {
                        Log.d("Result", "Cancelled");
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this, "Cancelled");
                        finish();
                    }

                    @Override
                    public void onError(FacebookException exception) {
                        Log.d("Result", "Error " + exception.getMessage());
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this,
                                "Error while inviting friends");
                        finish();
                    }
                });


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

            AppInviteDialog.show(InviteFriendsActivity.this, content);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);

    }

No help from below similar links (even though they are from ios)

Code for fb invitation not working

https://stackoverflow.com/questions/27547826/facebook-app-invites-issue

Facebook App Invite not received

Sepsis answered 20/5, 2015 at 9:24 Comment(2)
Is it compulsory to have Facebook app to make App Invite work?Olds
How to get the appLinkUrl I don't able to get it?Foretime
S
17

Ok, turns out everything was working fine after all. My mistake was in assuming not having the app installed, and not having the app authorized should generate a push notification.

After creating a new test user, using a device where the app was not currently installed and the app NEVER having been authorized with the user.

So the key here is that no push notification will be generated if the app is installed on the target device, even if the user has not authorized the app previously. Also, seemingly, if the user has authorized the app previously, even if it was removed it at some point, it also will not generate a notification.

So if you want to test this, create an entirely new test user and log in on the Facebook app on the platform you are testing on, and make sure the app is not installed on the device.

I think it should still generate a notification despite app being installed, because multiple users might be using the same device, but that's how it seems to be right now.

I'll leave this here in case anyone has a similar problem in the future.

Live long and prosper!

Source

It did actually work for me, however I am not very sure if it covers all the scenarios and is the perfect solution. Posting here for other users and suggestions if any.

Sepsis answered 21/5, 2015 at 12:49 Comment(1)
Problem when Invite Friend from Facebook. Can you please answer on this question : #38677549Mattern
G
6

I am using the following code and is working fine... but After inviting friends (if you've shared android application then invitee have to check on his/her mobile application..) the invitation is not visible through browsers

private CallbackManager sCallbackManager;

public void openDialogInvite(final Activity activity) {
            String AppURl = "https://fb.me/421570...5709";  //Generated from //fb developers

        String previewImageUrl = "http://someurl/13_dp.png";

        sCallbackManager = CallbackManager.Factory.create();

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

            AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
            appInviteDialog.registerCallback(sCallbackManager,
                    new FacebookCallback<AppInviteDialog.Result>() {
                        @Override
                        public void onSuccess(AppInviteDialog.Result result) {
                            Log.d("Invitation", "Invitation Sent Successfully");
                            finish();
                        }

                        @Override
                        public void onCancel() {
                        }

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

            appInviteDialog.show(content);
        }

    }
Greave answered 21/5, 2015 at 12:35 Comment(9)
if you've any problems ask meGreave
Thanks @Greave +1. Also I found some corner cases wherein it doesn't work. Have added it below for reference.Sepsis
The invitations can get on FB Account on all plateform by provide application setting for web and FB Canvas and ios with android setting.Gram
Invite Friend dialog comes but in Hindi Language. How to get data in English language???Palacios
Hello asad.qazi , pls check this link "#33916302" , If you have any idea for the same.Palacios
Hello I am able to send the app invitation but i am ab able to get any response in onSuccess or onError . Please help!Cachexia
i am not able to see log what should i do??Filature
@Greave Is it compulsory to have Facebook app to make App Invite work?Olds
yes you must have facebook application installed to have them work bcz facebook sdk uses its application for sharing and etcGreave
S
3

This may help some one with same problem Please use this code

private void InviteFbFriends()
{
    String appLinkUrl, previewImageUrl;
    appLinkUrl = "app url(create it from facebook)"; //your applink url
    previewImageUrl = "image url";//your image url 
    if (AppInviteDialog.canShow()) {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(appLinkUrl)
                .setPreviewImageUrl(previewImageUrl)
                .build();
        AppInviteDialog.show(this, content);
    }
}

Note. YOU CAN VIEW INVITATION ONLY IN DEVICES

Samadhi answered 18/6, 2016 at 7:57 Comment(1)
" YOU CAN VIEW INVITATION ONLY IN DEVICES" +1 Thanks.Erma
G
1
  1. I also integrate app invite api in my iOS application. i'm also facing same issue while after make changes in application setting. I got notifications on all side.
  2. As Mr.Asad said in his answer it will not show on browsers he's saying wrong . Actually to got invite on all side we have to make setting for a application for all side in following way. From Developer account select Your app and provide information for all platforms to get invitations on all site ios, Android, Facebook and web. If we will add setting for only one platform e.g provide information for only android notification will show on android devices not on other plateforms.
Gram answered 22/5, 2015 at 11:54 Comment(0)
P
0

In my case I was not able to receive the invitation and see them on the FB app because the FB app was in development mode (not live).

enter image description here

Priscella answered 5/10, 2017 at 16:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.