Facebook登录问题:-canOpenURL:URL失败:" fbauth2:/" - 错误:"操作无法完成

时间:2016-12-02 21:51:12

标签: ios iphone swift xcode facebook-login

几天前我开始学习Xcode和Swift,今天我想为新的应用程序创建一个Facebook登录。

所以我在youtube上关注了这个视频指南:https://www.youtube.com/watch?v=MNfrBdyEvmY

并且一切正常,除非在我点击模拟器上的登录按钮的最后一步没有显示。

[登录页面截图] [1]

然后我回到Xcode并发现了这两个错误:

  1. (在我点击按钮之前)
  2. 2016-12-02 16:12:54.008 f2f_sample [1805:113503]由于模拟器错误而退回到从NSUserDefaults加载访问令牌 2016-12-02 16:12:54.008 f2f_sample [1805:113503]因为模拟器bug而回归到在NSUserDefaults中存储访问令牌 2016-12-02 16:12:54.009 f2f_sample [1805:113503]因为模拟器bug而退回到NSUserDefaults的加载访问令牌 2016-12-02 16:12:54.009 f2f_sample [1805:113503]因为模拟器bug而回归到在NSUserDefaults中存储访问令牌 2016-12-02 16:12:54.009 f2f_sample [1805:113503]因为模拟器bug而退回到NSUserDefaults的加载访问令牌 2016-12-02 16:12:54.010 f2f_sample [1805:113503]因为模拟器bug而回归到在NSUserDefaults中存储访问令牌 2016-12-02 16:12:54.011065 f2f_sample [1805:113559] [] nw_host_stats_add_src recv太小,收到24,预计28 2016-12-02 16:12:54.016238 f2f_sample [1805:113559] [] ____nwlog_simulate_crash_inner_block_invoke dlopen CrashReporterSupport失败 2016-12-02 16:12:54.016593 f2f_sample [1805:113559] [] __nwlog_err_simulate_crash模拟崩溃失败" nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK失败:[42]协议不可用" 2016-12-02 16:12:54.017905 f2f_sample [1805:113559] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK失败:[42]协议不可用,转储回溯:         [x86_64] libnetcore-856.20.4     0 libsystem_network.dylib 0x000000010998f682 __nw_create_backtrace_string + 123     1 libnetwork.dylib 0x0000000109c6c932 nw_socket_add_input_handler + 3100     2 libnetwork.dylib 0x0000000109c4a4f4 nw_endpoint_flow_attach_protocols + 3768     3 libnetwork.dylib 0x0000000109c49511 nw_endpoint_flow_setup_socket + 563     4 libnetwork.dylib 0x0000000109c48270 - [NWConcrete_nw_endpoint_flow startWithHandler:] + 2612     5 libnetwork.dylib 0x0000000109c6344d nw_endpoint_handler_path_change + 1261     6 libnetwork.dylib 0x0000000109c62e7c nw_endpoint_handler_start + 570     7 libnetwork.dylib 0x0000000109c7aae5 nw_endpoint_resolver_start_next_child + 2240     8 libdispatch.dylib 0x000000010970c980 _dispatch_call_block_and_release + 12     9 libdispatch.dylib 0x00000001097360cd _dispatch_client_callout + 8     10 libdispatch.dylib 0x0000000109713e6b _dispatch_queue_serial_drain + 236     11 libdispatch.dylib 0x0000000109714b9f _dispatch_queue_invoke + 1073     12 libdispatch.dylib 0x00000001097173b7 _dispatch_root_queue_drain + 720     13 libdispatch.dylib 0x000000010971708b _dispatch_worker_thread3 + 123     14 libsystem_pthread.dylib 0x0000000109adf4de _pthread_wqthread + 1129     15 libsystem_pthread.dylib 0x0000000109add341 start_wqthread + 13

    1. (点击按钮后)
    2. 2016-12-02 16:13:59.084 f2f_sample [1805:113503] -canOpenURL:网址失败:" fbauth2:/" - 错误:"操作无法完成。 (OSStatus错误-10814。)" 2016-12-02 16:13:59.085 f2f_sample [1805:113503]因为模拟器bug而回归到在NSUserDefaults中存储访问令牌 2016-12-02 16:13:59.089 f2f_sample [1805:113503] -canOpenURL:URL失败:" fbauth2:/" - 错误:"操作无法完成。 (OSStatus错误-10814。)"

      我也查看了其他线程,但似乎没有一个符合我的情况。我不知道我做错了什么,我只是被困在这里..

      以下是我的代码: 1. AppDelegate.swift:

      //
      //  AppDelegate.swift
      //  f2f_sample
      //
      //  Created by victor on 12/2/16.
      //  Copyright © 2016 F2F. All rights reserved.
      //
      
      import UIKit
      
      @UIApplicationMain
      class AppDelegate: UIResponder, UIApplicationDelegate {
      
      
          var window: UIWindow?
      
      
      
          func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
              // Override point for customization after application launch.
      
      
              FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
              return true
          }
          func application(_ application:UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
              return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as 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.
      }
      
      func applicationWillTerminate(_ application: UIApplication) {
          // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
      }
      

      }

      1. 导入UIKit

        类ViewController:UIViewController {

        let loginButton: FBSDKLoginButton = {
            let button = FBSDKLoginButton()
            button.readPermissions = ["email"]
            return button
        }()
        
        override func viewDidLoad() {
            super.viewDidLoad()
        
            view.addSubview(loginButton)
            loginButton.center = view.center
        
        
        }
        
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
        
      2. }

        1. info.plist中:

          <key>CFBundleURLTypes</key>
          <array>
              <dict>
                  <key>CFBundleURLSchemes</key>
                  <array>
                      <string>fb{131875597297624}</string>
                  </array>
              </dict>
          </array>
          <key>FacebookAppID</key>
          <string>{131875597297624}</string>
          <key>FacebookDisplayName</key>
          <string>{f2f_sample}</string>
          
          <key>LSApplicationQueriesSchemes</key>
          <array>
              <string>fbapi</string>
              <string>fb-messenger-api</string>
              <string>fbauth2</string>
              <string>fbshareextension</string>
          </array>
          <key>NSPhotoLibraryUsageDescription</key>
          <string>{human-readable reason for photo access}</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>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>
          

        2. 感谢任何帮助!

0 个答案:

没有答案