2016-11-10 5 views
1

die docs herefacebookSDK, swift3 und AppDelegate zu Anmeldungen behandeln

Nach ich den Login-Button fein implementiert haben, die App geht auf den FBLogin aus vervollständigt gut, aber nachdem ich melden Sie sich an i zurück an die App übergeben bekommen und immer die Konsole liest

„Benutzer abgebrochen Login“

einige der Suche rund um das Internet zeigt, dass ich brauche etwas hinzufügen aber die Dokumentation AppDelegate.Swift nur Code für Objective-C-Projekte.

ist es this guy's guide aber ich denke, es für eine schnelle 1.x geschrieben

verändert es leicht für den Abwurf von NSURL gesorgt ich verwende:

import UIKit 
import FBSDKCoreKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     // Override point for customization after application launch. 
     return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 
    } 

    func application(application: UIApplication, 
        open url: URL, 
        sourceApplication: String?, 
        annotation: AnyObject?) -> Bool { 
     return FBSDKApplicationDelegate.sharedInstance().application(
      application, 
      openURL: url, 
      sourceApplication: sourceApplication, 
      annotation: annotation) 
    } 
    func applicationWillResignActive(_ application: UIApplication) { 
     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
     // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
    } 

    func applicationDidEnterBackground(_ application: UIApplication) { 
     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
    } 

    func applicationWillEnterForeground(_ application: UIApplication) { 
     // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
    } 

    func applicationDidBecomeActive(_ application: UIApplication) { 
     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
     FBSDKAppEvents.activateApp() 
    } 

    func applicationWillTerminate(_ application: UIApplication) { 
     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
    } 


} 

Aber ich erhalte die Fehlermeldung ‚Anwendung (: openURL: sourceApplication: Anmerkung :) Anwendung‘wurde umbenannt in" (: offen: sourceApplication: Anmerkung :)

Wer irgendwelche Ideen, wie diese Delegation an der Arbeit und ge die richtigen Sachen von einem Facebook Login zurückholen?

Antwort

0

Sie müssen wie unten Änderungen in AppDelegate machen:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) 
} 

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]) 
} 

mit FacebookCore.ApplicationDelegate (dass ich hoffe, dass es FBApplicationDelegate genannt werden), wie es

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

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    return FacebookCore.ApplicationDelegate.shared.application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) 
} 

siehe Link für weitere folgen: https://github.com/facebook/facebook-sdk-swift/issues/35

+0

Absolute Legende, ich schulde dir ein Bier. –