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:
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
I added the intent filter to
AndroidManifest
with the scheme<data android:scheme="com.myapp.android" />
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()); }
I set the App Link Name as App Link URL for MyApp
- I set the URL as the Google Play URL
- I set the App Name as MyApp
- I set the package name as com.myapp.android
- 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.