문제

My Facebook 앱에 공유 기능을 추가하고 있습니다. "말하기"가 선택되면 Facebook.and에서 "말하기"를 공유하기위한 버튼이 있습니다.이 버튼을 클릭하면서 Facebook 페이지에서 공유하는 말을 볼 수 있습니다., 내 iOS 앱에 대한 정보가 없습니다. 어떻게이 말이 내 iOS 앱을 통해 공유되었음을 알 수 있습니까?제발 도와주세요 ....

도움이 되었습니까?

해결책

나는 조금 늦을지도 모른다.이것이 도움이되기를 바랍니다.

계정 프레임 워크와 소셜 프레임 워크를 사용하여 앱 이름과 공유해야합니다. 먼저 Facebook에서 앱을 올바르게 설정했는지 확인하십시오.그런 다음 Facebook App 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