Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBWebDialog disappears when presented in iOS 7

FBWebDialog disappears with a flash when it is presented in iOS 7. It shows up if I relaunch the application. It appears properly in iOS 5 and iOS 6. I am facing this weird behaviour in iOS 7. What should I do to resolve this issue. I am using Facebook sdk 3.7.1.

 -(void)facebookShareButtonClicked{ 

    NSArray *permissions = [NSArray arrayWithObjects: @"publish_stream", nil];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:link,@"link",subject,@"caption",description,@"description",nil];
    if(OS_VERSION >= 6.0){  
       [FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError* error){
       if(!error){
           [self displayShareDialogueBox:params];
       }
       else{
           NSLog(@"error=>%@",[error localizedDescription]);
       }
    }
    else{
          [self displayShareDialogueBox:params];
    }
}

-(void)displayShareDialogueBox:(NSDictionary*)params{

    [FBWebDialogs presentFeedDialogModallyWithSession:(OS_VERSION >= 6.0)?FBSession.activeSession:nil
                                           parameters:params
                                              handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or publishing a story.
             NSLog(@"Error publishing story.");
         }
         else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 // User clicked the "x" icon
                 NSLog(@"User canceled story 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
                     NSString *msg = [NSString stringWithFormat:
                                      @"Posted story, id: %@",
                                      [urlParams valueForKey:@"post_id"]];
                     NSLog(@"%@", msg);
                     // Show the result in an alert
                     [[[UIAlertView alloc] initWithTitle:@"Result"
                                                 message:msg
                                                delegate:nil
                                       cancelButtonTitle:@"OK!"
                                       otherButtonTitles:nil]
                      show];
                 }
             }
         }
     }];
   }

Thanks

like image 292
Alex Avatar asked Dec 02 '25 04:12

Alex


1 Answers

Just install the latest Facebook SDK package v 3.8 released by facebook with iOS 7 support. No need to do any changes in your code. Everything will work fine. It worked for me.

like image 194
iOS Monster Avatar answered Dec 04 '25 18:12

iOS Monster