我在我的脸书app上添加了分享功能。就像"说"选择了一个用于分享的按钮"说"在facebook上。点击此按钮时,我只能在我的Facebook页面上看到共享的说法,没有关于我的ios应用程序的任何信息。我怎样才能让每个人都知道这个说法是通过我的iOS应用程序共享的?请帮帮我......
答案 0 :(得分:1)
我可能有点晚了。希望这会有所帮助。
您必须使用帐户框架和社交框架与您的应用名称共享。 首先确保您已在Facebook上正确设置了应用程序。然后,您可以使用Facebook App ID通过您的应用分享您的帖子。
以下是一个示例代码,向您展示如何将Accounts框架与Social Framework一起使用:
ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// At first, we only ask for the basic read permission
NSArray * permissions = @[@"email"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"275485699289493", ACFacebookAppIdKey, permissions, ACFacebookPermissionsKey, ACFacebookAudienceOnlyMe, ACFacebookAudienceKey, nil];
NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
//it will always be the last object with single sign on
self.facebookAccount = [accounts lastObject];
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
if (granted && error == nil) {
/**
* The user granted us the basic read permission.
* Now we can ask for more permissions
**/
NSArray *readPermissions = @[ @"publish_actions"];
[dict setObject:readPermissions forKey: ACFacebookPermissionsKey];
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
if(granted && error == nil) {
NSDictionary *parameters = @{@"message": @"This Should Work Perfectly !! "};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
feedRequest.account = self.facebookAccount;
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
// Handle response
}];
} else {
NSLog(@"error is: %@",[error description]);
}
}];
} else {
NSLog(@"error is: %@",[error description]);
}
}];
}