I am using the Facebook Graph API in my iOS application to post a message to Facebook. I am able to post the message, but I am facing an issue. When I launch the app it asks Facebook credentials (it display the login page again even I logged in successfully before). I am unable to find what I am missing.
if (FBSession.activeSession.isOpen)
{
[FBRequestConnection startForPostStatusUpdate:@"Sample Text" completionHandler:^(FBRequestConnection * connection , id result , NSError * error){
if (!error)
{
NSLog(@"Posted success fully");
}
else
{
NSLog(@"Error %@",error);
}
}];
}
else
{
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", @"publish_stream", nil];
NSLog(@"Need to login");
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[FBSession setActiveSession:session];
NSLog(@"Susccess %@",session.accessTokenData);
}];