问题
We are using phonegap to wrap our HTML5 app into a native iOS application. We need to login to facebook, but the JS SDK will pop up a Mobile Safari window and, from there, it's a bit weird to go back to the app.
What we want to do is use Facebook's iOS SDK and get an access token and then somehow use that token in our JS code to authenticate the user.
Obviously, we still want to use the JS SDK which has been thought out to not need tokens.
Do you know how we could do that?
回答1:
try
FB._authResponse.accessToken = 'YOUR TOKEN RETRIEVED FROM iOS SDK'
so with access to the UIWebView where your application lives:
[webView stringByEvaluatingJavaScriptFromString:
@"FB._authResponse.accessToken = '%@'",accessToken]
回答2:
So you want to pass the token from your native app to your server, so you can initialise the javascript SDK with the access token you received in the native login?
I don't see a specific reason this wouldn't work, you'd just have to POST the access token and associated user info to your server from your native app once the SSO process completes.
回答3:
Have you had a look over the ChildBrowser PhoneGap Plug-in for iPhone?! Especially the FBConnect example
来源:https://stackoverflow.com/questions/7835381/how-can-i-use-an-access-token-to-circumvent-fb-login