0

フィード ダイアログ共有機能を使用して、最新の Facebook SDK を使用して Facebook でテキスト メッセージを共有しています。Facebookでテキストメッセージを共有すると問題なく動作しますが、有効なセッションとログインしているユーザーがいるにもかかわらず、共有をクリックすると再びログインダイアログが表示されるなどの問題に直面しています。

ここに画像の説明を入力

- (BOOL)openSessionAllowingLoginUI:(BOOL)allowLoginUI
{
NSArray *permissions = [[NSArray alloc] initWithObjects:@"offline_access",@"publish_actions",@"read_stream", nil];

return [FBSession openActiveSessionWithPublishPermissions:permissions
                                          defaultAudience:FBSessionDefaultAudienceOnlyMe 
                                             allowLoginUI:YES
                                        completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

                                            DLog(@"Facebook Error : %@", error);
                                            if (!error) {
                                                [self publishPost:self.shareMessage andLink:self.shareLink];
                                            }
                                        }];
}


- (void)publishPost:(NSString *)message andLink:(NSString *)url
{
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"sample", @"name",
                               self.shareMessage, @"description",
                               self.shareLink, @"link",
                               nil];

[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                       parameters:params
                                          handler:
 ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or publishing a story.
         NSLog(@"Error publishing post.");
     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled post publishing.");
         } else {
             // Handle the publish feed callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"post_id"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled story publishing.");
             } else {

                 // User clicked the Share button
                 [self displaySuccessMessage];
             }
         }
     }
 }];
 }
4

1 に答える 1

0

電話してみる

openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:

に続く

requestNewPublishPermissions:defaultAudience:completionHandler:

電話する代わりに

openActiveSessionWithPublishPermissions:defaultAudience:allowLoginUI:completionHandler:
于 2014-05-16T13:06:08.017 に答える