简体   繁体   中英

How to use Facebook Comments Plugin in UIWebView

I want to present Facebook comments plugin in my application UIWebView . If user is not logged in, there is a big "Login to Facebook to Post a Comment" button which opens login page inside UIWebView and let users to login. The application got rejected by Facebook and the reason was that application didn't try to login with native Facebook app but instead it wanted to do that with UIWebView . It will not be possible to show Facebook comments plugin in UIWebView if users are not logged in embedded UIWebview .

So my question is how to use Comments Plugin if Facebook doesn't allow users to login with embedded UIWebview .

You must implement native login behavior, then fetch Comments with Facebook iOS SDK and display it in UITableView or whatever you`d like ,

When you open any View and there should be Comments , check if user is already logged in with Facebook , if no then display Login with facebook button ( not an UIWebView ) , after user logs in you can make graph request to fetch Comments ( if user is already logged in you can directly do it )

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{object-id}/comments"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    NSLog(@"Comments Result %@",result);
}];

make sure you set proper Object ID for this request

more about comments object https://developers.facebook.com/docs/graph-api/reference/v2.4/object/comments

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