11

In short: Everything seems to be working on the client side, but nothing received for the Facebook target friend.

These are the detailed steps with code and screenshots:

AppInviteContent content = new AppInviteConent.Builder()
    .setApplinkUrl("App link url created via the Facebook AppLink creator tool")
    .setPreviewImageUrl("http://www.redacted.com/previewImage.png")
    .build();

appInviteDialog.show(this, content);

This results in a dialog being shown with a preview of a link to the install of the app, and the option of entering a message at the top:

screenshot

I then click next, select one or more friends and click the top right Send button:

screenshot

The result is a seemingly successful send:

screenshot

I attached a callback as well to make sure it was actually a successful send:

appInviteDialog.registerCallback(facebookCallbackManager, new FacebookCallback<AppInviteDialog.Result>() {
    @Override
    public void onSuccess(AppInviteDialog.Result result) {
    Log.d(TAG,"onSuccess result = "+ result.getData().toString()); 
    }

    @Override
    public void onCancel() {}

    @Override
    public void onError(FacebookException e) {
        Log.d(TAG,"onError message = "+ e.getMessage());
    }
});

This prints out "onSuccess result = Bundle[{didComplete=1}]"

Expected result: Friend receives a notification. Actual result: Friend receives nothing.

Some more information that might be helpful:

  • App is only available on android.
  • Notification is not received on any platform including Facebook android app.
  • The App link url has been confirmed working by clicking on it in the Facebook android app. (It creates a popup linking to the Google Play Store)
  • Single Sign On has been enabled and user is logged in, although should not be necessary according to the AppInviteDialog documentation on Facebook.
  • Tried this with the target user not already having authorized the app, and also with user that already had the app installed. Same results.
  • The Facebook SDK version I am using is 4.0.0

It's frustrating because everything seems OK, and there is no way (that I know of) to debug this problem.

I hope someone can help me or point me in the right direction.

Thank you!

Joachim
  • 901
  • 8
  • 18
  • Have you added your friend as tester in "[Roles](https://developers.facebook.com/docs/apps/test-apps#role-management)" menu? – VadymVL Apr 22 '15 at 12:25
  • @VadymVL yes they are both test users. I have also tried with normal users. Both does not work. – Joachim Apr 22 '15 at 14:38
  • If they go into the Facebook app, click on the menu (top right button), scroll down to the Apps section, and go into App Invites (you may need to click on the See All section), do they see the invite there? There are many cases where a push notification may not be sent, we're working on documenting them. – Ming Li Apr 22 '15 at 15:42
  • @MingLi Yes, it was found there indeed. But a friend will never find it there unless they go looking, thus defeating the purpose of the app-invite, right? What must I do to get a push notification? Btw this was working fine on sdk v3 using webrequestdialog. – Joachim Apr 22 '15 at 16:11
  • Has the friend TOS'd your app? That will keep an invite from being generated. – benp Apr 24 '15 at 17:44
  • @benp What does TOS'd mean? – Joachim Apr 24 '15 at 21:40
  • Sorry, jargon. It means Terms of Service. It means they've gone through the authorization flow and accepted it. – benp Apr 28 '15 at 18:19

1 Answers1

16

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!

Joachim
  • 901
  • 8
  • 18
  • Thank you for this information. I'm currently trying to do the same thing. Just a little question if you don't mind. The App Link URL you created, it must be an valid one ? I mean, your app has to implement Deep Link also? Because I only want to have the Invite Dialog feature without the Deep Link functionality. When an user clicks the link, he should be redirected to the Google Play Store application. Do you think this is doable? Thank you. – Ionut Negru Apr 30 '15 at 05:40
  • 1
    @IonutNegru The app link url has to be a valid one. I created mine using their tool located at http://goo.gl/z5QdC1. You don't have to implement Deep Linking. I am using it exactly as you mention. Simply as a link to Google Play. – Joachim Apr 30 '15 at 09:33
  • I have created the App Link with the same tool. The App Link I got is "https://fb.me/892919744099420". I'm still unable to make an valid invite. I get stuck in that retry. – Ionut Negru Apr 30 '15 at 09:48
  • @IonutNegru Where do you get stuck? – Joachim Apr 30 '15 at 10:28
  • În their dialog with invite progress. It fails and always displays the retry the button. Could be because our app is currently unpublished? – Ionut Negru Apr 30 '15 at 10:31
  • @IonutNegru Our app is also not published, so that's not it. Can you click on the applink from within the facebook app itself? That's a way you can confirm you got a good applink. Also you can put a listener on the appinvite in your code, to get an error message? Is your app submitted and approved on Facebook? That might be necessary. – Joachim Apr 30 '15 at 10:58
  • If I acces the link from the device browser I get redirected to the correct page. I have the call back set. I don't get an response until I cancel, than I get the cancel result. The app is approved and is live. – Ionut Negru Apr 30 '15 at 11:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76634/discussion-between-ionut-negru-and-joachim). – Ionut Negru Apr 30 '15 at 11:17
  • Hey guys. I've read the chat. Did you realize what was the problem? And the solution? – Diego Stiehl Oct 07 '15 at 04:01
  • @DiegoStiehl Don't know what the problem was. It started working by itself apparently. – Joachim Oct 07 '15 at 07:58
  • Hey please help me same problem but some received for the Facebook target friend and not getting and log in callback . – Arpit Patel Aug 10 '16 at 08:49
  • **PRO TIP** : do not spend time on integrating `AppInviteDialog` because when it works, the target recipient will not be alerted to the app invite! The UX is totally horrible because the user would have to mysteriously know to check their App Invites buried deep in the facebook app. Instead, send the app invite over messenger. – Someone Somewhere Aug 17 '17 at 16:45