2015-11-22 102 views
10

我已將Parse Framework與所有Facebook依賴項集成到我的應用中。 我的plist配置是這樣的:IOS 9 Swift - 解析Facebook登錄無法打開本地Facebook應用

<key>CFBundleURLTypes</key> 
    <array> 
     <dict> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>fbXXXXXXXXXXXXX</string> 
      </array> 
     </dict> 
    </array> 
    <key>FacebookAppID</key> 
    <string>XXXXXXXXXXXXX</string> 
    <key>FacebookDisplayName</key> 
    <string>XXXXX</string> 

    <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>LSApplicationQueriesSchemes</key> 
    <array> 
     <string>fbauth2</string> 
    </array> 

我登錄的代碼看起來像這樣:

PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionsArray, block: { (user, error) -> Void in 
      if(error != nil){ 
       print("Login failed") 
      }else{ 
       if let currentUser = user{ 
        if(currentUser.isNew){ 
         print("New user") 
        }else{ 
         print("Login success") 
        } 
       }else{ 
        print("Login canceled") 
       } 

      } 
     }) 

一切運作良好,但是在登錄過程中的Safari瀏覽器正在做的,而不是在安裝Facebook應用。

我錯過了什麼?

+0

試試這個:http://stackoverflow.com/questions/33315083/error-in-facebook-login-ios-9-swift – lukaivicev

回答

5

由於iOS 9 Facebook SDK不再通過Facebook應用提供授權。 原因是在應用程序可以打開其他應用程序之前會提示用戶,這會影響用戶體驗。

你唯一的選擇是使用FBSDKLoginBehaviorSystemAccountFBSDKLoginBehaviorBrowser

PFFacebookUtils.facebookLoginManager().loginBehavior = FBSDKLoginBehavior.SystemAccount 
+0

感謝您的回覆,但是我可以看到其他應用程序成功使用此方法(如AirBnB)。我嘗試添加'(PFFVideosUtils.facebookLoginManager())。loginBehavior = FBSDKLoginBehavior.SystemAccount'沒有運氣。任何其他想法? –

+0

你總是可以使用舊版本的SDK來取回'FBSDKLoginBehavior.Native',但不推薦。爲了使'FBSDKLoginBehavior.SystemAccount'工作,FB需要在iOS設置中設置,否則它將回退到瀏覽器。 –

+0

您能否詳細說明需要配置的設置?我在IOS平臺中唯一設置的是Bundle ID。 P.S - .Native具有相同的效果 –