için
func applicationDidBecomeActive(_ application: UIApplication)
{
FBSDKAppEvents.activateApp();
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> (Bool)
{
let wasHandled: Bool = FBSDKApplicationDelegate.sharedInstance().application(application
,open:url
,sourceApplication:sourceApplication
,annotation:annotation)
if (wasHandled) {
if let fbtoken = FBSDKAccessToken.current() {
loginWithFacebook(fbtoken.tokenString);
}else{
print("no current token")
}
}
return wasHandled
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let wasHandled: Bool = FBSDKApplicationDelegate.sharedInstance().application(
app,
open: url as URL!,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation]
)
if (wasHandled) {
if let fbtoken = FBSDKAccessToken.current() {
loginWithFacebook(fbtoken.tokenString);
}else{
print("no current token")
}
}
return wasHandled;
}
sayesinde bu artık çalışmıyor.
FBSDKLoginButton
kullanıyorsanız, geri arama beklemek için FBSDKLoginButtonDelegate
kullanmanız gerekir.
class LoginView: UIViewController, FBSDKLoginButtonDelegate {
@IBOutlet weak var facebookButton: FBSDKLoginButton!
override func viewDidLoad() {
facebookButton.delegate = self
}
//Called at the end of the user connection
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if ((error) != nil) {
//Process error
} else if result.isCancelled {
// Handle cancellations
print("result is canceled")
} else {
if let fbToken = result.token.tokenString {
print(fbToken)
}
}
}
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
print("logout from FB")
}
}
Ayrıca, FBSDKLoginManager'ı da kullanabilirsiniz. Burada documation göz atın:
https://developers.facebook.com/docs/reference/ios/current/class/FBSDKLoginManager/
Umut bu yardım!
Ben de geri pod 'FBSDKCoreKit', '4.15.0' pod 'FBSDKLoginKit', '4.15.0' pod 'FBSDKShareKit' ile '4.15.0' haddelenmiş ve http izledi: // stackoverflow. com/a/41119777/1220633 Artık hem gerçek cihazda hem de simülatörde çalışıyor. – RikiRiocma