我已經看過這裏的每一個線程,我有最新的Parse SDK(1.8.5),我有最新的Facebook SDK(4.6)。我使用iOS9和Swift 2.0的Xcode版本7.0.1。我已經反覆閱讀Facebook API文檔頁面,以確保我不會錯過任何東西以及解析API文檔。這裏是我的視圖控制器Facebook登錄問題-canOpenURL:URL失敗:「fbauth2:///」 - error:「(null)」
import ParseFacebookUtilsV4
import Parse
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let permissions = ["public_profile"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
print("User signed up and logged in through Facebook!")
} else {
print("User logged in through Facebook!")
}
} else {
print("Uh oh. The user cancelled the Facebook login.")
}
}
}
這裏是AppDelegate中:
import UIKit
import CoreData
import Parse
import Bolts
import FBSDKCoreKit
import ParseFacebookUtilsV4
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
Parse.enableLocalDatastore()
// Initialize Parse.
Parse.setApplicationId("removed",
clientKey: "removed")
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
return true
}
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
這裏是info.plist中:
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>removed</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>removed</string>
<key>FacebookDisplayName</key>
<string>removed</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
沒有編譯器的問題,但是當我運行它,我得到的
canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"
-canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"
當模擬tor只啓動一個空白屏幕,它不會在模擬器上路由Facebook登錄。
任何人都可以請幫忙!
重置您的模擬器:選擇模擬器, 選擇重置內容和設置, 並選擇重置選項。從[這裏](http://stackoverflow.com/questions/32676334/ios-9-facebook-login-simulator-canopenurl-failed-for-url-fbauth2-erro)。 – Monkpit
也嘗試過幾次。不解決問題。 –
我在Facebook上看到了這個文檔,但無論在模擬器上,它都沒有帶我去登錄Facebook頁面 –