2

I'm having great difficulty getting AppLinks working for my Android app, I will call MyApp. I have followed the documentation on the Facebook Developers site for integrating App Links into existing content. The Facebook Debug tool (https://developers.facebook.com/tools/debug/og/object/) shows my webpage getting scraped correctly, and shows my 3 meta tags for applinks:

<meta property="al:android:app_name" content="MyApp" />
<meta property="al:android:package" content="com.myapp.android" />
<meta property="al:android:url" content="myapp://myapphost/myapppath" />

I have Open Graph Stories that I post to Facebook using the Share Dialog, which share the URL I have just put through the Facebook Debug Tool. These Open Graph Stories have been reviewed/approved by Facebook, and show in the news feeds. When clicked on, in Facebook in a browser, they go to the URL associated with the Story. When clicked on, in Facebook for Android, they only open MyApp's default Activity (MainActivity), rather than the Activity that handles the URI scheme (UriLoadingActivity). I know the URI scheme works, because I use it in push notifications: when a user clicks on the notification, it takes them to the UriLoadingActivity:

  <activity
        android:name="com.myapp.android.activity.UriLoadingActivity"
        android:parentActivityName="com.myapp.android.activity.MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:host="myapphost"
                android:scheme="myapp" />
        </intent-filter>

        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.myapp.android.activity.MainActivity" />
    </activity> 

I have Logs in onCreate() of MainActivity to check the Intent data passed from Facebook. As such, I see the Facebook package and app name in the referer_app_link Bundle. I also get the target_url which has the webpage URL I posted in my Open Graph Story, however, I do not see any of the AppLink data I have provided in the Meta tags on my webpage.

Is anyone else experiencing similar issues?

Update: here is the code I use to post to FB.

    private void shareToFacebook(Bitmap image) {

    if (FacebookDialog.canPresentOpenGraphActionDialog(
            getApplicationContext(),
            FacebookDialog.OpenGraphActionDialogFeature.OG_ACTION_DIALOG)) {

        OpenGraphObject myObject = OpenGraphObject.Factory
                .createForPost("myapp:object");
        myObject.setProperty("title", "My Title");

        myObject.setUrl(Constants.SHARE_URL);

        myObject.setProperty("description",
                        "Just Posting to the News Feed!");

        OpenGraphAction action = GraphObject.Factory
                .create(OpenGraphAction.class);
        action.setType("myapp:action");
        action.setProperty("object", myObject);

        List<Bitmap> images = new ArrayList<Bitmap>();
        images.add(image);

        FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(
                this, action, "object").setImageAttachmentsForObject(
                "object", images, false).build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } 
}
Kevin Z
  • 333
  • 1
  • 10
  • Can you add some code snippets on how you're doing the share? I suspect the FB app is actually opening your app on the old deep link protocol (in your app settings) rather than App Links, and want to see if I can repro it somehow. – Ming Li Feb 02 '15 at 18:23
  • I posted my share above. I do have the Deep Linking toggle turned on in the Facebook settings. If I turn it off, it just opens the shared URL in the Android Facebook in-app browser. – Kevin Z Feb 03 '15 at 19:20

1 Answers1

0

Sorry it took so long to reply.

You are using the Object API to create a user-owned OG object. If you want that OG object to be App Link enabled, then the URL on that object (myObject.setUrl) must be the canonical_url from an App Link Hosting object (meaning you need to create it through the App Link Hosting API). You cannot use your own url as it will not merge properly. This is a limitation of the Object API. From here, you have two options:

  1. Create an App Link url using the App Link Hosting API https://developers.facebook.com/docs/applinks/hosting-api and use that as the url property on your OG object.

  2. Since you have a website, use urls from the website to host your OG objects rather than using the object API (this may not be possible if you want user-owned objects).

Ming Li
  • 15,672
  • 3
  • 37
  • 35
  • Thanks for the answer Ming, as a follow up- we have a website and we like having stories in the browser open up the pages that are linked from these stories. For this reason, we would like to stay away from using the hosting API. However, we also like having the user published stories use an image from the app for the post. Is there a way to host the OG objects yet still have a user generated image for the posts? Also, do you know if there are any plans to update the Object API to allow to link to our own webpages yet use the user-owned OG objects (like we are doing) but have app links work? – Kevin Z Feb 14 '15 at 03:13
  • You can attach an image to the OG action rather than the object, that way you can use your own hosted objects and still have attachments. AFAIK there are no plans to hook up object API objects with app links from your own site. – Ming Li Feb 17 '15 at 17:03