swift 2 parse facebookSDK ios9

前端 未结 4 867
旧巷少年郎
旧巷少年郎 2021-01-31 08:50

I am trying to Log In a user via Facebook. In the previous version of swift 1.2 everything worked perfectly, but after migration I can\'t seem to log in via my FB account I am s

4条回答
  •  不思量自难忘°
    2021-01-31 09:17

    I suggest following the instructions from Facebook to prepare an app for iOS 9: https://developers.facebook.com/docs/ios/ios9

    1. Download the latest Facebook SDK for iOS

    Download the appropriate version of the Facebook SDK for your app.

    v4.x - Recommended. v3.24.0 - Only if you have not migrated to v4.x of the SDK yet. 2. Whitelist Facebook Servers for Network Requests

    If you compile your app with iOS SDK 9.0, you will be affected by App Transport Security. Currently, you will need to whitelist Facebook domains in your app by adding the following to your application's plist:

    NSAppTransportSecurity
    
        NSExceptionDomains
        
            facebook.com
            
                NSIncludesSubdomains
                                
                NSExceptionRequiresForwardSecrecy
                
            
            fbcdn.net
            
                NSIncludesSubdomains
                
                NSExceptionRequiresForwardSecrecy
                
            
            akamaihd.net
            
                NSIncludesSubdomains
                
                NSExceptionRequiresForwardSecrecy
                
            
        
    
    

    or you will encounter errors like:

    NSUnderlyingError=0x7f88f9436eb0 {Error Domain=kCFErrorDomainCFNetwork
    Code=-1200 "An SSL error has occurred and a secure connection to
    the server cannot be made." UserInfo={NSErrorFailingURLStringKey=
    https://graph.facebook.com/v2.4, NSLocalizedRecoverySuggestion=
    Would you like to connect to the server anyway?,
    _kCFNetworkCFStreamSSLErrorOriginalValue=-9802,
    kCFStreamPropertySSLPeerCertificates={type = immutable, count = 2, values = (
    0 : 
    1 :  )}, 
    _kCFStreamPropertySSLClientCertificateState=0,
    kCFStreamPropertySSLPeerTrust=,
    NSLocalizedDescription=An SSL error has occurred and a secure connection
    to the server cannot be made.,_kCFStreamErrorDomainKey=3,
    NSErrorFailingURLKey=https://graph.facebook.com/v2.4,
    _kCFStreamErrorCodeKey=-9802}}
    
    1. Whitelist Facebook Apps

    If you use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, you will need to update your application's plist to handle the changes to canOpenURL described in https://developer.apple.com/videos/wwdc/2015/?id=703

    If you're recompiling with iOS SDK 9.0, add the following to your application's plist if you're using a version of the SDK v4.5 or older:

    LSApplicationQueriesSchemes
    
        fbapi
        fbapi20130214
        fbapi20130410
        fbapi20130702
        fbapi20131010
        fbapi20131219    
        fbapi20140410
        fbapi20140116
        fbapi20150313
        fbapi20150629
        fbauth
        fbauth2
        fb-messenger-api20140430
    
    

    If you're using FBSDKMessengerShareKit from versions older than the v4.6 release, also add

    fb-messenger-platform-20150128
    fb-messenger-platform-20150218
    fb-messenger-platform-20150305
    

    If you're using v4.6.0 of the SDK, you only need to add:

    LSApplicationQueriesSchemes
    
            fbapi
            fb-messenger-api
            fbauth2
            fbshareextension
    
    

    This will allow the FacebookSDK integration to properly identify installed Facebook apps to perform an app switch. If you are not recompiling with iOS SDK 9.0, your app is limited to 50 distinct schemes (calls to canOpenURL afterwards return NO).

提交回复
热议问题