使用ShareSDK完成Facebook第三方登录和Facebook分享时没办法跳转到Facebook应用

摘要:
建筑所有者通过cocoapod访问了ShareSDK。后来发现,无论是使用fb共享还是登录,它都不在网络认证范围内(即使我的手机上安装了fb)。后来,mob的技术客服兄弟告诉我,在构造共享参数时,要执行参数字典的SSDKEnableUseClientShare方法,即NSMutableDictionary*shareParams=[NSMutable DictionaryDictionary];[共享Pa

楼主是通过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

使用ShareSDK完成Facebook第三方登录和Facebook分享时没办法跳转到Facebook应用第1张

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>

免责声明:文章转载自《使用ShareSDK完成Facebook第三方登录和Facebook分享时没办法跳转到Facebook应用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇android中的文件操作详解以及内部存储和外部存储(转载)sed在行首或者行尾添加内容下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

fastjson的使用——JSON字符串、JSON对象、Java对象的互转

一、fastjson简介 fastjson是阿里出品的处理JSON字符串的Java类库,可以对JSON字符串、JSON对象、Java对象进行互相转换源码地址:https://github.com/alibaba/fastjson 二、依赖引用 如果使用的是maven,需要在pom.xml文件中加入依赖:<dependency><group...

tips

史上最全的Unity面试题(持续更新总结。。。。。。) 包含答案的Unity面试题 这个是我刚刚整理出的Unity面试题,为了帮助大家面试,同时帮助大家更好地复习Unity知识点,如果大家发现有什么错误,(包括错别字和知识点),或者发现哪里描述的不清晰,请在下面留言,我会重新更新,希望大家共同来帮助开发者 一:什么是协同程序? 在主线程运行的同时开启另...

Android 使用GPS定位获取经纬度的方法

移动 是手机与手持设备的最大特点,可以通过Eclipse的DDMS视图,模拟设备的位置变化,改变经纬度后,点击send,然后运行程序,在应用程序中,动态的获取设备位置,然后显示当前的位置信息。 获取位置信息分为三步: 1. 添加系统权限,来支持对LBS硬件的访问 < uses-permission android:name="android.perm...

iOS学习——如何在mac上获取开发使用的模拟器的资源以及模拟器中每个应用的应用沙盒

如题,本文主要研究如何在mac上获取开发使用的模拟器的资源以及模拟器中每个应用的应用沙盒。做过安卓开发的小伙伴肯定很方便就能像打开资源管理器一样查看我们写到手机本地或应用中的各种资源,但是在iOS开发中,在真机上还可以通过一些软件工具iExplorer等查看手机上的资源,但是如果你在开发过程中经常使用xcode自带的模拟器进行调试,这是你要查看模拟器中相关...

js和java中使用join来进行数组元素的连接

  合理地使用join来进行数组中元素的连接,代码简洁,比自己编码也更为方便。   js中join的用法 var arr = new Array(3) arr[0] = "a" arr[1] = "b" arr[2] = "c" arr.join(".") a.b.c ------------------ arr.join(",") a,b,c   ja...

Android 电量优化

极力推荐Android 开发大总结文章:欢迎收藏程序员Android 力荐 ,Android 开发者需要的必备技能 电量优化一直是Android 开发中的头等问题。本篇将分析一下Android M 以上电量优化措施电量优化相关的部分知识点。 注:文章参考MTK手机解决方案文档 通过本篇文章阅读,你将收获以下知识点: 1.Doze 模式 2.空闲状...