1
我按照指示here,但我無法獲得第5步與連接應用程序委託工作,因爲指令是在Objective C中,而我的AppDelegate文件是用Swift編寫的。如何在反應原生應用程序中安裝facebook sdk?
我嘗試這樣做:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
// Add any custom logic here.
return true
}
func application(_ application: UIApplication, open url: URL, options: (UIApplicationOpenURLOptionsKey & id)) -> Bool {
let handled: Bool = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey], annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
// Add any custom logic here.
return handled
}
將會產生此生成錯誤:
The following build commands failed:
CompileSwift normal x86_64 /Users/kevinchiang/jh-mobile/ios/JustHive/Appdelegate.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
我不熟悉的雨燕的OBJ-C,所以我想有可能是我的SWIFT代碼不對勁。
你的第二個功能是錯誤的。我想你想使用這個方法[應用程序(_:open:options:)](https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623112-application)而不是你在那裏的那個。讓我知道它是否有效 –
你能告訴我你的意思嗎?我嘗試過func應用程序(_ application:UIApplication,_:open:options:(UIApplicationOpenURLOptionsKey&id)),它沒有工作 –
我的回答是否幫助你?如果它確實標記爲正確的話。 –