Invite users with AppInviteDialog

erdomester picture erdomester · May 16, 2015 · Viewed 8.6k times · Source

I am glad that Facebook finally let users invite their friends with the SDK version 4 but I don't know how to do it. The documentation is clear at least for a while:

if (appInviteDialog.canShow()) {
      AppInviteContent content = new AppInviteContent.Builder()
          .setApplinkUrl("https://play.google.com/store/apps/details?id=com.myapp.android")
          .setPreviewImageUrl("http://www.myapp.com/Images/stub.jpg")
          .build();
      appInviteDialog.show(MainActivity.this, content);
}

So far this couldn't be simpler. But once I select a user to invite I get Missing App Link URL error:

enter image description here

I understand I need to create an App Link URL, but I don't really know how. According to the documentation I should put meta tags between the <head></head> sections on the website associated with my Facebook app in the developer console's Settings/Site URL section.

So I put these on my website:

<meta property="al:android:url" content="https://fb.me/1047359658624810" />
<meta property="al:android:app_name" content="MyApp" />
<meta property="al:android:package" content="com.myapp.android" />
<meta property="al:web:url" content="http://myapp.com" />

The https://fb.me/1047359658624810 is created with the App link generator.

This part is totally obscure. In the example the url is sharesample://story/1234 and sharesample is defined as a scheme in an intent filter, but then what is story/1234?

In the App Link Generator

  1. I added the intent filter to AndroidManifest with the scheme <data android:scheme="com.myapp.android" />

  2. I set deep linking in the launcher class as

    Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(this, getIntent()); if (targetUrl != null) { Log.i("ACTIVITY", "App Link Target URL: " + targetUrl.toString()); }

  3. I set the App Link Name as App Link URL for MyApp

  4. I set the URL as the Google Play URL
  5. I set the App Name as MyApp
  6. I set the package name as com.myapp.android
  7. Then I set the generated App Link URL on the website as

<meta property="al:android:url" content="https://fb.me/1047359658624810" />

For now all I need is to be able to send app invites and when users click on them they should be taken to the Google Play URL of the app. It's like I'm one step from finishing this thing but I can't figure out what I am missing.

Answer

abhishekkharwar picture abhishekkharwar · May 16, 2015

You have to create your app url thorough facebook have a look into bellow url

How to create App Link URL

It will show page like. You don't need to fill iOS information if your app is only for android

enter image description here

After filling required information click on next and it will generate App Link Url.

enter image description here

Use the generated url and cheers