Ecco la mia risposta: Poche parole chiave come FBSessionStateCreatedTokenLoaded
errore gettato per me .. quindi questo potrebbe aiuta
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Whenever a person opens the app, check for a cached session
if FBSession.activeSession().state == FBSessionState.CreatedTokenLoaded
{
// If there's one, just open the session silently, without showing the user the login UI
FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: false, completionHandler: {
(session, state, error) -> Void in
self.sessionStateChanged(session, state: state, error: error)
})
}
return true
}
func sessionStateChanged(session : FBSession, state : FBSessionState, error : NSError?)
{
// If the session was opened successfully
if state == FBSessionState.Open
{
println("Session Opened")
}
// If the session closed
if state == FBSessionState.Closed
{
println("Closed")
}
}
On Butto n clicca fare Facebook login
@IBAction func FacebookLoginPressed(Sender: AnyObject)
{
if (FBSession.activeSession().state == FBSessionState.Open || FBSession.activeSession().state == FBSessionState.OpenTokenExtended)
{
// Close the session and remove the access token from the cache
// The session state handler (in the app delegate) will be called automatically
FBSession.activeSession().closeAndClearTokenInformation()
}
else
{
// Open a session showing the user the login UI
// You must ALWAYS ask for public_profile permissions when opening a session
FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: true, completionHandler: {
(session:FBSession!, state:FBSessionState, error:NSError!) in
let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
// Call the app delegate's sessionStateChanged:state:error method to handle session state changes
appDelegate.sessionStateChanged(session, state: state, error: error)
})
}
}
fonte
2014-11-25 04:39:32
Quale codice swift hai provato e quali errori stai ricevendo? – drewag
Inoltre, questo potrebbe aiutare: http://stackoverflow.com/questions/24189946/call-facebook-delegates-in-swift/24196013#24196013 – drewag