简体   繁体   中英

Add Facebook comments to my iOS app

I am developing a content display app in which there is a table view and a corresponding detail view to display the html data in a web view.

I want to include facebook comments plugin, For that i have included the fb javascript sdk but the fb commnets are not loading in the web view.

I am not able to under stand the reason

here is my code for the fb sdk.

<div id='fb-root'></div>
<script>
window.fbAsyncInit = function() { FB.init({ appId : 'xxxxxxxxxxxxx', xfbml : true, version : 'v2.1' }); };
(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 = 'http://connect.facebook.net/en_US/sdk.js';
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class='fb-comments' data-href='http://xxxxx/xx/xx' data-numposts='5' data-colorscheme='light'></div>
It worked for me perfectly.

NSString *html =@"\
<!DOCTYPE html>\
<html>\
<head>\
</head>\
<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_US/all.js#xfbml=1&appId=211241782359485\";\
fjs.parentNode.insertBefore(js, fjs);\
}(document, 'script', 'facebook-jssdk'));</script>\
<div class=\"fb-comments\" data-href=\"http://www.google.com\" data-width=\"470\"></div>\
</body>\
</html>\
";
[self.commentsWebView stopLoading];
[self.commentsWebView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://www.google.com"]];    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM