Question

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];
}
Était-ce utile?

La solution

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

Autres conseils

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..

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top