I am trying to view the facebook comment plugin in UIWebView on an iPhone application.
I started with a Facebook tutorial for iOS that implemented single sign-on. The application delegate takes care of SSO on Facebook and then redirects me to my single view controller, which displays the title bar and UIWebView.
I am uploading a webview with a local file called "comments.html" that has been added and copied to my bundle / project folder.
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"comments" ofType:@"html"] isDirectory:NO];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
My html file is a version of the plugin implementation created on the Facebook Comments plugin description site . I connected the URL and clicked "Get Code". I took the HTML5 code that was provided to me and stuck it in the HTML file
<html>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://www.bombslo.com" data-num-posts="4" data-width="470"></div>
</body>
</html>
UIWebView loads beautifully on my simulator. I hosted and ran the HTML on my device and it loads fine in Safari. The problem is that UIWebView will not load the Facebook comment plugin in the embedded UIWebView.
It is important to note that I am not getting a blank screen. I see two animated download bars typical of Facebook. Also note that the generated Facebook code comes in both HTML5 and XFBML. I tried to use both.
source
share