Search code examples
iosfacebookfeed

Change or show privacy setting when using Feed Dialog


My app is posting to facebook with help of Feed Dialog, but unfortunately public audience of my post is only-me. When I'm trying to set privacy key in publish params for friends visibility:

 NSMutableDictionary *params =
    [NSMutableDictionary dictionaryWithObjectsAndKeys:
     @"my app_id", @"app_id",
     @"my app name", @"name",
     @"some text.", @"caption",
     @"some more text.", @"description",
     @"web site link", @"link",
     @"some picture link", @"picture",
     @"ALL_FRIENDS", @"privacy",
     nil]; 

So when adding @"ALL_FRIENDS", @"privacy", I receive an error in Dialog window when I try to publish: Error100 (I'm using incorrect privacy parameter). So my question is how can I change this parameter or how can I let user to change it Feed dialog window (I'm using 3.5 facebook SDK). Thanks in advance!


Solution

  • OK, so what have I done to solve the problem:

    1.I'm closing any active session when my app launches:

    FBSession* currentSession = [FBSession activeSession];
    if(currentSession) {
        [currentSession close];
    }
    

    2.Establishing new connection with friends as default audience

     [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                       defaultAudience:FBSessionDefaultAudienceFriends
                                          allowLoginUI:YES
                                     completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                         if (!error && status == FBSessionStateOpen) {
                                             [self publishWithWebDialog];
                                         }else{
                                             NSLog(@"error");
                                         }
                                     }];
    

    3.Calling method for publishing with Feed Dialog:

    [self publishWithWebDialog];
    

    The fun part starts when application is launched for the second time :) There is no need to press all that OK buttons and application just opens Feed dialog, by the way this approach also fixes the problem with deleting application in Facebook from users Account Settings - > Apps.