flutter - 是否支持在 Flutter 中使用 Facebook SDK(具体应用事件)?

标签 flutter dart facebook-sdk-4.0

我想将 Facebook 应用程序事件添加到我的 Flutter 项目中:https://developers.facebook.com/docs/app-events/android https://developers.facebook.com/docs/app-events/ios

我可以知道 Flutter 用户是否应该实现他们的插件以使用 Facebook 功能?

最佳答案

您可以使用名为 facebook_app_events(null-safety) 的包集成 Facebook 应用程序事件。

Android 设置:

第 1 步:转到 your_project\android\app\src\main\res\values 创建一个名为 strings.xml 的新文件(如果您还没有)strings.xml 文件中粘贴这个

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

不要忘记将 [APP_ID] 替换为您从 Facebook e.g

获得的原始 APP_ID
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="facebook_app_id">1234567890</string>
</resources> 

第 2 步:转到 your_project\android\app\src\main\AndroidManifest.xml 并将其粘贴到您的应用 <application> 打开标签下

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

Android 设置完成。

iOS 设置:

转到 one_app\ios\Runner\info.plist 文件并添加

  • 如果您的代码没有 CFBundleURLTypes ,只需添加以下内容 在最后的 </dict> 元素之前:
<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>
  • 如果您的代码已经包含 CFBundleURLTypes ,请插入 以下:
<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 设置完成

注意:不要忘记将包添加到您的 pubspec.yaml 文件中

dependencies:
  facebook_app_events: ^0.12.0

关于flutter - 是否支持在 Flutter 中使用 Facebook SDK(具体应用事件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65292994/

相关文章:

android-studio - 在Mac上使用Flutter设置Android Studio的问题

flutter - ListView Flutter 的单选

ios - flutter 错误无效的 `Podfile`文件: no implicit conversion of nil into String.我通过讨论搜索但我似乎无法解决问题

android - 我想在应用程序运行时更改应用程序的方向(仅适用于某些页面纵向和其他横向页面)

Flutter : icon ! = null 不正确

android - 在分享 Intent android 中使用 Facebook sdk 的 ShareContent

react-native - 找不到FBSDKCoreKit/FBSDKCoreKit.h文件错误 react native ios

flutter - Flutter:如何从JSON自定义标题

flutter Getx : initial value of obs variable set to null

ios - fatal error : unexpectedly found nil while unwrapping an Optional value on performing segue