Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

01. Setup

MyFlashLabs edited this page Apr 4, 2020 · 8 revisions

The recommended approach to add Facebook ANE or any other ANEs to your project is to use the ANELAB Software. If you are using the software, all dependencies and required frameworks will be downloaded and copied for your automatically. Your project's manifest .xml file will also be adjusted automatically. So, if you are using ANELAB, skip to the rest of wiki. Otherwise, read below to know what changes you need to make to your app to be able to run Facebook ANE.

Initialization

import com.myflashlab.air.extensions.fb.*;
import com.myflashlab.air.extensions.dependency.OverrideAir;

// init the ANE as soon as possible, preferably in the constructor function of your documentClass 
Facebook.init("Your_Facebook_APP_ID");

// Add these listeners right after initializing the ANE
Facebook.listener.addEventListener(FacebookEvents.INIT, onAneInit);
Facebook.listener.addEventListener(FacebookEvents.INVOKE, onAneInvoke);

// You can receive the hashKey for your Android certificate like below.
// This hashkey is required when you are setting the Android side of your Facebook app
if (OverrideAir.os == OverrideAir.ANDROID) trace("hash key = ", Facebook.hashKey);

function onAneInvoke(e:FacebookEvents):void
{
    trace("onAneInvoke: " + decodeURIComponent(e.deeplink));
}

function onAneInit(e:FacebookEvents):void
{
    trace("onAneInit");

    // check if user is already logged in or not
    if(Facebook.auth.currentAccessToken)
    {
        trace("user is login already");
    }
}

Minimum Requirements

  • AIR SDK 30.0
  • Android API 19
  • iOS 10.0

Manifest setup

<!--
    ANDROID:
-->
<application android:name="android.support.multidex.MultiDexApplication">
    <activity android:hardwareAccelerated="false">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </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" />

            <!--    
                Add your app scheme here. it is usually your app package name 
                but could be other things also. The important thing is that 
                you should try to keep it unique.
            -->
            <data android:scheme="air.com.site.app" />
        </intent-filter>
    </activity>

    <!--
        This is required by the Facebook ANE. replace the zeros with your actual Facebook App ID
        While doing that, notice the empty space after the "\ ". This is required because the ANE
        must see the value as an String.
    -->
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 0000000000000000"/>

    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:label="My App Name" />

    <activity android:name="com.facebook.CustomTabMainActivity" />
    <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" />

            <!-- Your facebook App ID here. keep the 'fb' prefix -->
            <data android:scheme="fb000000000000" />
        </intent-filter>
    </activity>

    <!-- Replace 00000000 with your Facebook App ID -->
    <provider
        android:authorities="com.facebook.app.FacebookContentProvider000000000"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true" />

    <receiver android:name="com.facebook.CurrentAccessTokenExpirationBroadcastReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.facebook.sdk.ACTION_CURRENT_ACCESS_TOKEN_CHANGED"/>
        </intent-filter>
    </receiver>

    <receiver
                android:name="com.facebook.CampaignTrackingReceiver"
                android:exported="true"
                android:permission="android.permission.INSTALL_PACKAGES">
                <intent-filter>
                    <action android:name="com.android.vending.INSTALL_REFERRER"/>
                </intent-filter>
            </receiver>

</application>








<!--
    iOS:
-->
<key>FacebookAppID</key>
<string>00000000000</string>

<key>FacebookDisplayName</key>
<string>Air Native Extension</string>

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <!-- Change zeros with your Facebook App ID. keep the 'fb' prefix -->
            <string>fb00000000000</string>
            
            <!-- Your application scheme. read here for more information: http://www.myflashlabs.com/open-adobe-air-app-browser-pass-parameters/ -->
            <string>air.com.site.app</string>
        </array>
    </dict>
</array>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fb-messenger-share-api</string>
    <string>fb-messenger</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this feature in my app</string>








<!--
    Extensions:
-->
<extensionID>com.myflashlab.air.extensions.facebook</extensionID>
        
<!-- Download dependencies from https://github.com/myflashlab/common-dependencies-ANE -->

<!-- Needed on Android/iOS -->
<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID>
        
<!-- Needed on Android ONLY -->
<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.arch</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.cardview</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.core</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.design</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.lifecycle</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.utils</extensionID>

iOS Frameworks Download Facebook SDK for iOS V5.6.0 and copy the following frameworks to your AdobeAIR SDK: lib/aot/stub/

  • FBSDKCoreKit.framework
  • FBSDKLoginKit.framework
  • FBSDKShareKit.framework
  • FBSDKPlacesKit.framework