2016-06-30 195 views
0

我正在製作應用程序,我想整合Facebook,但是這個錯誤無法繼續,附加了我的問題。集成Facebook SDK

import UIKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 

     FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 
     // Override point for customization after application launch. 
     return true 

    } 
    func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { 

     return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation:annotation) } THIS IS THE PROBLEM -- > ////Use of unresolved identifier "sourceApplication"/// 
    } 
} 
+0

您是否導入了Facebook框架? – Adolfo

+0

@Adolfo這不是問題。問題是這個用戶複製並粘貼'FBSDKApplicationDelegate'調用到iOS 8委託中,而不理解'openURL'和URL方案的工作方式。看到我的答案。 – JAL

回答

0

您的委託方法與Facebook使用的方法不匹配。那樣的事情呢?

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { 
    return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) 
}