質問

私のFacebook Appに共有機能を追加しています。「言っている」と選択されている場合、Facebook.andで「言って」を共有するためのボタンがあります。私のiOSアプリに関する情報はありません。これは、このような言葉が私のiOSアプリを通して共有されていることを誰でも知っていますか?私を助けてください....

役に立ちましたか?

解決

私は少し遅くなるかもしれません。これが役立つことを願っています。

あなたはあなたのアプリ名と共有するためにアカウントフレームワークとソーシャルフレームワークを使う必要があります。 最初にあなたがFacebookにあなたのアプリを正しく設定したことを確認してください。それからあなたはあなたのアプリを通してあなたの投稿を共有するためにFacebookアプリIDを使うことができます。

これは、社会の枠組みでアカウントフレームワークの使い方を示すサンプルコードです:

    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]);
        }
    }];
}
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top