在我的iPhone集成Facebook应用程序,但是当我发布在我的墙上,我的朋友无法分享我应该怎么办? [英] In my iPhone integrating Facebook app but when i post on my wall my friend unable to share what should i do?
问题描述
所以最好的解决方案是在我的FB应用程序有问题,或者我必须在iOS中做代码。
感谢提前
我检查过你的屏幕截图。看起来像fb喜欢帖子基本上。因为没有人不能分享这篇文章。我建议您使用最新的ios fb sdk 3.1.1,然后将该FB sdk与您的ios应用程序集成。然后使用以下代码
对于ios 6及更高版本,请使用ios 6 native fb post方法:
if(NSClassFromString(@SLComposeViewController)!= nil){
UIApplication * app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = NO;
SLComposeViewController * controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if(result == SLComposeViewControllerResultCancelled){
NSLog(@\\\
Cancelled);
} else
{
NSLog(@\\\
Done);
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:FB_POST_FEED_INITIAL_TEXT_MSG];
[controller addURL:[NSURL URLWithString:BITLY_VIEW_LINK]]; // youtube video link
[self presentViewController:controller animated:YES completion:Nil];
}
否则使用此FB sdk方法:
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession * session,
FBSessionState state, NSError * error){
switch(state){
case FBSessionStateOpen:
//首先显示Hud视图,然后启动post message feed进程
[self postFBMessageOnUserWall];
break;
case FBSessionStateClosed:
//需要处理
break;
case FBSessionStateClosedLoginFailed:
//需要处理
break;
默认值:
break;
}
}];
- (void)postFBMessageOnUserWall {
NSDictionary * params = [NSDictionary dictionaryWithObjectsAndKeys:
FB_POST_FEED_INITIAL_TEXT_MSG,@name,BITLY_VIEW_LINK,@link,nil] ;
[FBRequestConnection
startWithGraphPath:@me / feed
参数:params
HTTPMethod:@POST
completionHandler:^(FBRequestConnection * connection ,
id result,
NSError * error){
//显示警告说该消息成功发布在你的墙上
[self performSelectorOnMainThread:@selector(showAlertFromMainThread :) withObject:error waitUntilDone:NO];
NSLog(@\\\
\\\
fb post feed error status =%@,error);
}];
}
I using facebook integrate for one of my iOS application it share quote. But problem is that when quote post on my timeline my friends not able to share just "Like" and "Comment". I want share to please see attach screenshots so whats the best solution for that is there problem in my FB app or I've to do code for that in iOS.
Thanks in Advance
I checked your screenshot. That looks like fb "like post" basically. Since no one can't share this post. I would suggest you to use latest ios fb sdk 3.1.1 and then integrate that FB sdk with your ios app. Then use the following code
For ios 6 and later use ios 6 native fb post method:
if(NSClassFromString(@"SLComposeViewController") != nil) {
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = NO;
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"\nCancelled");
} else
{
NSLog(@"\nDone");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
[controller setInitialText:FB_POST_FEED_INITIAL_TEXT_MSG];
[controller addURL:[NSURL URLWithString:BITLY_VIEW_LINK]]; // youtube video link
[self presentViewController:controller animated:YES completion:Nil];
}
otherwise use this FB sdk method:
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
switch (state) {
case FBSessionStateOpen:
//first shows the hud view then initiating the post message feed process
[self postFBMessageOnUserWall];
break;
case FBSessionStateClosed:
//need to handle
break;
case FBSessionStateClosedLoginFailed:
//need to handle
break;
default:
break;
}
}];
-(void)postFBMessageOnUserWall {
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
FB_POST_FEED_INITIAL_TEXT_MSG, @"name", BITLY_VIEW_LINK, @"link", nil];
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
//show the alert says that message successfully posted in your wall
[self performSelectorOnMainThread:@selector(showAlertFromMainThread:) withObject:error waitUntilDone:NO];
NSLog(@"\n\nfb post feed error status = %@", error);
}];
}
这篇关于在我的iPhone集成Facebook应用程序,但是当我发布在我的墙上,我的朋友无法分享我应该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!