And*_*ang 17 facebook facebook-sdk-4.0 swiftui
我已将正确的 Facebook sdk 值添加到 info.plist 中,如快速入门指南所示,并使用包管理器添加 SDK,但我仍然收到此错误
Thread 1: App ID not found. Add a string value with your app ID for the key FacebookAppID to the Info.plist or call [FBSDKSettings setAppID:]。
应用程序 ID 100% 正确,位于我的 info.plist 中。如果我在应用程序委托中设置名称和应用程序 ID,我只会收到此错误:
Thread 1: fbappid is not registered as a URL scheme. Please add it in your Info.plist
Facebook SDK 似乎在我的 info.plist 中找不到任何值?
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb823445029398455</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>823445029398455</string>
<key>FacebookDisplayName</key>
<string>vertoo-dev</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbapi20160328</string>
<string>fbauth</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Run Code Online (Sandbox Code Playgroud)
Ahm*_*ran 27
将其添加到新文件中
class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Initialize Facebook SDK
FBSDKCoreKit.ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
return true
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,因为我忘记在 URL 方案中添加fb应用程序 ID 的前缀。
确保您已将这样的内容添加fb{app_id}到如下图所示的网址方案中。
导航至此处:项目导航器 > 选择您的目标 > 信息 > URL 类型
在 Xcode 12.5 中测试
创建一个AppDelegate.swift并在下面添加此代码。
import SwiftUI
import FacebookCore
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return ApplicationDelegate.shared.application(app, open: url, options: options)
}
}
Run Code Online (Sandbox Code Playgroud)
接下来在您的@main App 文件中添加此行
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13726 次 |
| 最近记录: |