Facebook login with Chrome Custom Tabs

airfacebook-ctt-hor

Chrome Custom Tabs is an Android library providing in-app view with Chrome-like look and feel. Furthermore, it shares cookies stored by the browser and as a result, users don’t have to type in their account details again if they have signed in to Facebook before using Chrome. The library offers better user experience compared to in-app web view, which requires user’s details every time. Of course, if native Facebook app is installed, it’ll be used instead.

Chrome Custom Tabs are supported on Android 4.1 with Chrome browser installed and AIRFacebook extension from version 1.4.3. It is an optional feature, and the native SDK will fallback to in-app web view if the library is not included in your app.

To support Custom Tabs in your app, update AIRFacebook to version 1.4.3 or newer. Then download custom tabs extension from this repository and include it in your project by adding its ID to your app descriptor XML:

<extensionID>com.marpies.ane.androidsupport.customtabs</extensionID>

Finally, add the custom tab activities to your Android manifest:

<activity
    android:name="com.facebook.CustomTabActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="fb{FACEBOOK_APP_ID}" />
    </intent-filter>
</activity>
<activity
    android:name="com.facebook.CustomTabMainActivity"
    android:exported="true">
</activity>

Note you need to replace {FACEBOOK_APP_ID} with the app ID as specified in the dashboard of your Facebook app.

Visit the Modifying AIR descriptor file section of the setup guide if you’re unsure where to paste this snippet.

Leave a Comment