flutter_facebook_app_links 1.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • new56

Flutter Facebook App Links #

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.

Getting Started #

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)

Configure Android #

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)

<string name="facebook_app_id">[APP_ID]</string>

After that, add that string resource reference to your main AndroidManifest.xml file

<meta-data
  android:name="com.facebook.sdk.ApplicationId"
  android:value="@string/facebook_app_id" />

Configure iOS #

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>

Please refer to the official SDK documentation for [Android] and iOS.

IMPORTANT NOTE #

To correctly test deferred deeplinks, DO NOT use the preview of your FB ADS campaign. Instead, use this tool APP ADS HELPER

At the end of the page you will find a "Test deep link" button, click on it and type your custom url scheme (deeplink), for example: myawesomeapp://screen/login

Select the second checkbox (or both). Remember that to make it works, you'll need the Facebook app installed on your device (Android or iPhone) and you must be logged in with the same account you're using in the Facebook Developers console.

Your app doesn't need to be published on the store, simply uninstall it and re-install using Android Studio/VSCode or XCode after you've sent the deferred deep link.

1.0.1+1 #

  • Removed the deprecated author: field from pubspec.yaml

1.0.1 #

  • Added example code.

1.0.0 #

  • Initial release.

example/README.md

flutter_facebook_app_links_example #

Demonstrates how to use the flutter_facebook_app_links plugin.

Getting Started #

You can use the following code inside a Stateful Widget, usually the root so that it will be triggered when your app is opened:

import 'package:flutter_facebook_app_links/flutter_facebook_app_links.dart';
import 'dart:io' show Platform;

void catchFBDeferredDeeplinks() async {
    
    if (Platform.isAndroid) {
      try{
        Map<String, String> data = await FlutterFacebookAppLinks.initFBLinks();

        if(data!=null && data['deeplink']!=null && data['deeplink'].isNotEmpty)
          manageDeepLink(data['deeplink']);

      }catch(e){
        print('Error on FB APP LINKS');
      }  
    
    } else if (Platform.isIOS) {
      try{
        var result = await FlutterFacebookAppLinks.initFBLinks();
        print('Link from FB APP LINKS: $result');
        if(result!=null && result.isNotEmpty && result!='nolink' && result!='error')
          manageDeepLink(result);

      }catch(e){
       print('Error on FB APP LINKS');
      }
      
    }
   
  }

void manageDeepLink(String url){
    /// ... do something with the received link
}

@override
void initState() {
    super.initState();
    catchFBDeferredDeeplinks();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_facebook_app_links: ^1.0.1+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_facebook_app_links/flutter_facebook_app_links.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
13
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

5 out of 5 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_facebook_app_links.dart.

Run flutter format to format lib/flutter_facebook_app_links.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test