Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add metadata to Facebook App invite

While sending out an App invite in my app, I am trying to find a way to add metadata to it so I can track internally who sent invites and how successful they were (Facebook only shows data from when the dialog is opened and there is no way to track specific funnels).

my code for sending the invite is:

private void openFacebookAppInvite() {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(FACEBOOK_APP_LINK_URL)
                .setPreviewImageUrl(INVITE_PREVOEW_IMAGE_URL)
                .build();
        // WANT TO ADD METADATA HERE
        AppInviteDialog.show(this, content);
}
like image 645
thepoosh Avatar asked Mar 14 '16 08:03

thepoosh


People also ask

How do I invite someone to the Facebook app developer?

If notification is missing, then invited person should navigate to https://developers.facebook.com/requests/ and accept invite there. At the bottom it should say "1 developer request". Click through to that and approve the app, and you should be good to go.


1 Answers

Maybe this is not the answer that you had hoped for, but I think it will help to implement your requirements.

Part 1: send data directly with an AppInvite

As far as I know, it is not possible to send custom data with AppInvites created with an AppInviteContent.Builder directly. I will explain a more complex possibility in Part 3. But maybe a GameRequest is an option for you. A GameRequestDialog can be initialized with a GameRequestContent object. The method setData of the class GameRequestContent.Builder "sets optional data which can be used for tracking".

Part 2: tracking invites

Of course you can track that an user opened the AppInviteDialog (by do a simple request to your server). Sadly it is not possible to track which or how many users are invited.

But after an invited user accepts the invitation, installs and run the mobile app (or give you the permissions on a canvas, if you have a canvas app too), you are able to get all AppRequests (Invites) by do a query to /me/apprequests with the Graph API.

Also possible:

  1. Canvas App: The POST request, your server will get after an invited user opens the canvas page, contains a parameter request_ids. This is a comma separated list of app-request-ids, which can be used in a graph query.
  2. Mobile App: After the invited user installed and started the app in response to an AppRequest, you are able to get the app-request-ids from the intent or by the use of AppLinkData.fetchDeferredAppLinkData and appLinkData.getTargetUri().getQueryParameter("request_ids"). See the section "Supporting incoming links" in the documentation. Now you are able to create a graph api request.

Part 3: send data with an AppInvite via an App-Link

As shown in Part 2.2., you will get a targetUrl after an invited user opens the app. This targetUrl is specified in the AppLink found under the AppLinkUrl you used for the AppInvite. With a "Dynamic App Link endpoint" it is possible to send data to the invitees. Here an idea how to implement this:

  1. Your server defines an endpoint with the uri-template POST:http://example.com/users/${USER}/invites/. ${USER} is the username of the sender of the invitation.
  2. Before creating the invitation dialog, the client sends a POST request to the endpoint from step 1 and will get an UUID as a response, which references the planned invitation and the user.
  3. the server defines a second endpoint GET:http://example.com/users/${USER}/invites/${UUID}. The response to this endpoint is a page with a defined AppLink where al:android:url is example://users/${USER}/invites/${UUID} - of course the placeholder ${USER} and ${UUID} are replaced with the correct values from step 1 and 2.
  4. The client uses the endpoint from step 3 (http://example.com/users/${USER}/invites/${UUID}) as the app-link-url when creating the AppInviteContent.
  5. The invited user accepts the invitation and opens the app. Now we are able to get the UUID from the targetUrl (see step 2.2 / "Supporting incoming links").
like image 175
Meiko Rachimow Avatar answered Oct 13 '22 05:10

Meiko Rachimow