我假设你的问题只是如何将数据从本地应用程序传递到webview。 你可以使用js。例如假设这是一个利用保存为test.html
访问令牌上的网页视图代码:
<html>
<head></head>
<body>
<script type="text/javascript">
function usesAccessToken(access_token_string) {
// use access token
alert(access_token_string);
}
</script>
</body>
</html>
您可以通过以下方式值给js函数:
[self.myAppWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];
在UIWebViewDelegate
委托方法:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *accessToken = [FBSDKAccessToken currentAccessToken].tokenString;
NSString *functionToCall = [NSString stringWithFormat:@"usesAccessToken('%@')", accessToken];
[self.myAppWebView stringByEvaluatingJavaScriptFromString:functionToCall];
}
重要的是要注意,在客户端共享访问令牌是不可取的。 – Bangdel