Facebook アプリに共有機能を追加しています。たとえば、「発言」が選択されると、Facebook でその「発言」を共有するためのボタンが表示されます。私のiOSアプリに関する情報。このことわざが私のiOSアプリを通じて共有されていることをみんなに知らせるにはどうすればよいですか? 私を助けてください....
1 に答える
1
少し遅れるかもしれません。お役に立てれば。
アプリ名と共有するには、アカウント フレームワークとソーシャル フレームワークを使用する必要があります。まず、Facebook でアプリが正しく設定されていることを確認してください。その後、Facebook アプリ 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]);
}
}];
}
于 2014-07-04T12:40:16.120 に答える