0

I'm trying to post a message on my Facebook page and it works fine but the post is visible only to me. My friends don't see it! It seems like it's not "public".

I have set defaultAudience:FBSessionDefaultAudienceEveryone so it should post to everyone, not only for me.

Here is my code :

-(void)postOnFacebook
{
    if (FBSession.activeSession.isOpen)
        [self postOnWall];
    else
    {
        [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions", nil]
                                           defaultAudience:FBSessionDefaultAudienceEveryone
                                              allowLoginUI:YES
                                         completionHandler:^(FBSession *session,
                                                         FBSessionState status,
                                                         NSError *error)
        {
           if (error)
              NSLog(@"Login failed");
           else if (FB_ISSESSIONOPENWITHSTATE(status))
              [self postOnWall];
        }];
    };
}

- (void)postOnWall
{
   FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];

   FBRequestHandler handler =
       ^(FBRequestConnection *connection, id result, NSError *error) {
            [self requestCompleted:connection forFbID:@"me" result:result error:error];
       };

   NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                   @"pippo", @"message",
                                   nil];

   FBRequest *request=[[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
   [newConnection addRequest:request completionHandler:handler];
   [requestConnection cancel];
   requestConnection = newConnection;
   [newConnection start];
}
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
swifferina
  • 293
  • 4
  • 16

2 Answers2

1

One possible reason could be that your App is in development mode, so the posts made by you using this app will only be visible to the developers/testers added.

So you can do 2 things-

  1. Remove the app from development mode and make it live.

    enter image description here

  2. Add some friends as testers/developers/administrators.

    enter image description here

Community
  • 1
  • 1
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • Thanks a lot! I didn't know that it was in development mode! – swifferina Apr 03 '14 at 14:27
  • Sure! It was not necessary to add some friends as testers/developers/administrators, I've only removed the development mode. – swifferina Apr 03 '14 at 14:31
  • Yes of course its not necessary, but i was just saying that if you dont want to put it on live for now, you can add some testers to get your app test. – Sahil Mittal Apr 03 '14 at 14:32
0

Need to give permission to your app to access Facebook..

[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions","email",@"friends_location",@"status_update",@"publish_stream", nil]
                                   defaultAudience:FBSessionDefaultAudienceEveryone
                                      allowLoginUI:YES
                                 completionHandler:^(FBSession *session,
                                                     FBSessionState status,
                                                     NSError *error)

Hope this helps you..

Bhanu
  • 1,249
  • 10
  • 17