Flutter plugin for Facebook App Links SDK. This plugin must be used to catch deferred deeplinks sent from Facebook after your app has been installed from a FB ADS.
First of all, if you don't have one already, you must first create an app at Facebook developers: https://developers.facebook.com/
Get your app id (referred to as [APP_ID]
below)
For Android configuration, you can follow the same instructions of the Flutter Facebook App Events plugin:
Read through the "Getting Started with App Events for Android" tutuorial and in particular, follow step 2 by adding the following into /app/res/values/strings.xml
(or into respective debug
or release
build flavor)
configure inside android/app/main/res/values/strings.xml the above values (without square brackets):
<string name="facebook_app_id">[your_app_id]</string>
<string name="facebook_client_token">[your_client_token]</string>
then, add that string resource reference to your main AndroidManifest.xml
file, within ...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
For iOS configuration, you can follow the same instructions of the Flutter Facebook App Events plugin:
Read through the "Getting Started with App Events for iOS" tutuorial and in particular, follow step 4 by opening info.plist
"As Source Code" and add the following
- If your code does not have
CFBundleURLTypes
, add the following just before the final</dict>
element:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[APP_ID]</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>
- If your code already contains
CFBundleURLTypes
, insert the following:
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[APP_ID]</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>
## How to use
import 'dart:io' show Platform;
...
...
/// FB Deferred Deeplinks
void initFBDeferredDeeplinks() async {
String deepLinkUrl;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
deepLinkUrl = await FlutterFacebookAppLinks.initFBLinks();
if(Platform.isIOS)
deepLinkUrl = await FlutterFacebookAppLinks.getDeepLink();
/// do what you need with the deeplink...
/// ...
}catche(e){
/// in case of error...
}
}
Please refer to the official SDK documentation for Android and iOS.
How documented on Facebook docs, starting from v5.0.0 of the SDK, they introduce a flag for disabling automatic SDK initialization to be GDPR compliant.
It means that you should collect user consent before you use call the method initFBLinks()
of this plugin and save the user choice. Moreover, you should give the user a chance to revoke their consent in the future.
Please keep in mind that this plugin uses FacebookSDK.setAutoInitEnabled(true)
in Android and Settings.isAutoInitEnabled = true
in iOS by default, so the consent must be granted in your Dart code before you call FlutterFacebookAppLinks.initFBLinks()
.