Is there any support for using Facebook SDK (app events to be specific) in Flutter?

Viewed 2853
2 Answers

You can integrate Facebook app events using this package called facebook_app_events(null-safety).

Android Setup:

STEP 1: goto your_project\android\app\src\main\res\values create a new file called strings.xml (if you don't have any already) In the strings.xml file just paste this

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="facebook_app_id">[APP_ID]</string>
</resources>

Don't forget to replace [APP_ID] with the original APP_ID you got from Facebook e.g

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="facebook_app_id">1234567890</string>
</resources> 

STEP 2: goto your_project\android\app\src\main\AndroidManifest.xml and paste this under your app <application> open tag

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

Android setup done.

iOS setup:

goto one_app\ios\Runner\info.plist file and add

  • 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>

iOS setup is done

NOTE: don't forget to add the package to your pubspec.yaml file

dependencies:
  facebook_app_events: ^0.12.0

So far, you can find the facebook_app_events package at pub.dev which is very good. Note that (at the time of writing this answer) the package doesn't support null safety, so you should use it with Dart 2.11 and lower.

There are no official packages from Facebook yet.

Related