樓主是通過cocoapod接入ShareSDK, 后來發現無論是使用fb分享還是登錄, 都是跳出了網頁認證(即使我的手機有安裝了fb)
后來mob的技術客服小哥告訴我在構造分享參數的時候, 執行參數字典的SSDKEnableUseClientShare方法, 也就是
NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
[shareParams SSDKSetupShareParamsByText:@"Rinpe" images:nil url:[NSURL URLWithString:@"http://www.baidu.com"] title:@"Rinpe" type:SSDKContentTypeAuto]; [shareParams SSDKEnableUseClientShare];
然后登錄呢?由於一開始我在初始化ShareSDK的時候(也就是下面的方法)
+ (void)registerApp:(NSString *)appKey activePlatforms:(NSArray *)activePlatforms onImport:(SSDKImportHandler)importHandler onConfiguration:(SSDKConfigurationHandler)configurationHandler;
在onImport這個block里面需要連接到fb的SDK, 但是我找了半天沒找到類似下面這樣的方法
[ShareSDKConnector connectFacebook:[xxxx class]];
然后Mob客服的小哥說要用
[ShareSDKConnector connectFacebookMessenger:[FBSDKMessengerSharer class]];
然后我又找了半天沒有找到包含FBSDKMessengerSharer這個類的文件, 小哥就說使用pod 'ShareSDK3/ShareSDKPlatforms/FacebookMessengerSDK'
來集成這個SDK, 然而我不知道是我的原因還是他們的原因, pod update老是報錯...
迫於無奈, 我自己找到了FBSDKMessengerShareKit, 也就是使用pod 'FBSDKMessengerShareKit'來集成這個SDK...
好吧, 上面的問題解決了..結果一運行...
-canOpenURL: failed for URL: "fbauth2://authorize?client_id=xxxxx 出現了這個錯誤...
好吧..最后我找到了一個網站...
http://discoverpioneer.com/blog/2015/09/18/updating-facebook-integration-for-ios-9/
按上面的步驟給info.plist添加相應的參數...
問題終於解決了...
原文如下:
Updating Facebook Integration for iOS 9
So with iOS 9 out, there are a few enhancements in security. With that being said, the way your app integrates Facebook may be acting strange, or not working at all.
More than likely this is because you are being affected by App Transport Security. ‘App Transport Security is a feature that improves the security of connections between an app and web services. The feature consists of default connection requirements that conform to best practices for secure connections. Apps can override this default behavior and turn off transport security. ‘ -Apple
With all this being said, this is definitely something that you want to keep inside of your app. But now…. how do you make it work!?!
There are two solutions
1.
First: Whitelist Facebook Servers for Network Requests.
To do this add the following to your info.plist file:<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>
Then, Whitelist Facebook Apps by adding this to your info.plist as well:
<key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fbapi20130214</string> <string>fbapi20130410</string> <string>fbapi20130702</string> <string>fbapi20131010</string> <string>fbapi20131219</string> <string>fbapi20140410</string> <string>fbapi20140116</string> <string>fbapi20150313</string> <string>fbapi20150629</string> <string>fbauth</string> <string>fbauth2</string> <string>fb-messenger-api20140430</string> </array>
There you go, that should do the trick
2.
If this seems to be too much of a hassle for you, the second option is to turn off App Transport Security. You can do that by adding the following to your info.plist file:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>