2016-02-28 63 views
0

好了,所以我實現了一個Facebook的登錄按鈕:斯威夫特。還記得Facebook登錄

loginButton.readPermissions = ["public_profile", "email", "user_friends"] 
loginButton.center = (self.view?.center)! 

loginButton.delegate = self 

self.view?.addSubview(loginButton) 

但每次我完全關閉該應用程序,然後再次打開它,我需要歸隊的時間,所以我的問題是如何在我做應用程序記得我已經登錄過一次?

回答

1

嘗試使用您的appDelegate這個

將這個代碼

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

if((FBSDKAccessToken.currentAccessToken()) != nil){ 
    //user is sign in 
    //Put here something what you want to do if user is sign in 

} 

return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 

} 
0

節省你從你的Userdefaults或coredata Facebook的反應獲得的電子郵件或Facebook令牌..

然後檢查爲登錄屏幕上的第一個值,並指導您的應用程序。