13

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.

erdomester
  • 11,789
  • 32
  • 132
  • 234

1 Answers1

21

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

abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
  • What I didn't know was that this is the app link URL I need to set in the application itself and not the google play link! Also, I don't need any meta tags on the website. Thanks! – erdomester May 16 '15 at 15:59
  • 2
    You can either put the meta tags on your website, and just use your website url as the app link url, OR you can create a URL using the tool above, and use that as the app link url. Both will work. – Ming Li May 18 '15 at 17:30
  • Is there someway to change how this appears as a post? I followed the same steps for sharing to Facebook, and it is working, but looks ugly as it displays fb.me post without any data. – Rowan Jun 16 '15 at 19:51
  • It won't appear in post it will appear in notification list only. Can you share the screenshot? – abhishekkharwar Jun 17 '15 at 08:46
  • this does not help at all if you need to pass a custom referral code and you need a web fallback for non-mobile users / platform you don't support. I've set my custom deep link URL in the al:android:url in the form myapp://my-string?myReferral=myref and I keep getting that error. The app is not released on Google Play (it's just in Alpha, only me can access). And I think I'm 100% compliant with facebook documentation still get the error message above. – Daniele Segato Oct 16 '15 at 09:24
  • @Daniele Did you figure it out.? I am using fb hosting api and still can't get referral to work – Snake Jan 27 '16 at 08:02
  • @Snake yes, I wasn't doing anything wrong. The problem was that Facebook caches every call, even those that return an error. The first time I tried there was an error in the page and Facebook cached it, It wasn't calling my server again. I had to input my URL here https://developers.facebook.com/tools/debug/ to see what was going on and force a cache purge. – Daniele Segato Jan 28 '16 at 10:18
  • @DanieleSegato Thank you. I have a question. What do you put in the my-string portion. Do I put anything? Or should be fb id or something sepecifc – Snake Jan 29 '16 at 07:16
  • @Snake I've no idea of what you are talking about. No clue on what "my-string" portion is. – Daniele Segato Jan 29 '16 at 10:33
  • I am talking about the url you said in your comment 2 posts ago. You said you used myapp://my-string?myReferral=myref . I was wondering what my string is – Snake Jan 29 '16 at 18:21
  • @Snake its whatever string you decide to use and intercept in your app :) – Daniele Segato Feb 17 '16 at 10:42
  • 3
    app link generator "404 Page not found" – Prasad Nov 27 '17 at 06:45
  • app link generator "404 Page not found" – Bhanu Sharma Dec 20 '17 at 06:12