具有嵌入式UIWebView的Facebook-ios-sdk [英] Facebook-ios-sdk with embedded UIWebView

查看:121
本文介绍了具有嵌入式UIWebView的Facebook-ios-sdk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的facebook-ios-sdk,并将api成功地集成到我的本地应用程序中。我可以使用ios-sdk类的弹出对话框来验证用户并正确设置权限。

I'm working with the new facebook-ios-sdk and have successfully integrated the api into my native app. I am able to authenticate a user and properly setup permissions using a popup dialog with the ios-sdk classes.

对于我的一部分应用程序,我需要使用Facebook连接在 UIWebView 中,使用javascript和html来处理Webview中的数据。鉴于用户已经通过上面的例程进行了登录和验证,我会假设 UIWebView 将共享这些凭据,或者至少有一些方法传递或分配凭据到网页视图。

For a portion of my app I need to use the facebook connection within a UIWebView, using javascript and html to process data within the webview. Given that the user is already logged in and authenticated via the above routine, I would have assumed that the UIWebView would share those credentials, or that there would at least be some way to pass or assign the credentials to the webview.

不幸的是,我发现这个早期的帖子似乎表明这个方案不是很有用( iOS - 登录后在webView中登录与SDK )。有没有人遇到这个和/或找到一个工作?这似乎是一个非常简单的用例,因为我不是试图启动移动Safari或类似的东西 - 这都在同一本地应用程序。

Unfortunately, I found this earlier post which seems to suggest that this scheme doesn't quite work (iOS - being logged-in in a webView after logging in with the SDK). Has anyone else encountered this and/or found a work around? This seems like it would be a fairly straightforward use case given that I'm not trying to launch mobile safari or something like that - it's all within the same native app.

看起来似乎有一些简单的招式或设置,我错过了。可能会在新的 UIWebView 中设置Cookie?或者这样的东西?

It just seems like there must be some sort of easy trick or setting that I'm missing. Maybe somehow setting cookies in the new UIWebView? or something like this?

推荐答案

我可能会以这种方式获得Access令牌

I would probably get the Access token in this method

func loginViewFetchedUserInfo(loginView: FBLoginView, user:FBGraphUser ) {
    println(FBSession.activeSession().accessTokenData.accessToken)
}

此代码在Swift中,但该方法也适用于Obj C。
然后,您将使用Sandy和Steve所建议的Web视图中的访问令牌

This code is in Swift, but the method exists for Obj C as well. Then you would use the access token in the web view as suggested by Sandy and Steve

这篇关于具有嵌入式UIWebView的Facebook-ios-sdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆