带有嵌入式 UIWebView 的 Facebook-ios-sdk

Facebook-ios-sdk with embedded UIWebView(带有嵌入式 UIWebView 的 Facebook-ios-sdk)

本文介绍了带有嵌入式 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.

对于我的应用程序的一部分,我需要在 UIWebView 中使用 facebook 连接,使用 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 - 使用 SDK 登录后在 webView 中登录).有没有其他人遇到过这个和/或找到解决方法?这似乎是一个相当简单的用例,因为我没有尝试启动移动 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?

推荐答案

我可能会在这个方法中获得访问令牌

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:带有嵌入式 UIWebView 的 Facebook-ios-sdk

基础教程推荐