Note :- Facebook provides only 25 latest chat conversation messages
/This is completion handler method and takes 3-4 sec to load chat messages from FB/
NSMutableArray *arrConversation = [[NSMutableArray alloc]init];
NSArray *arrPermission = @[@"read_mailbox"];
if ([[FBSession activeSession]isOpen]) {
[FBRequestConnection startWithGraphPath:@"/me?fields=inbox" completionHandler:^(FBRequestConnection *connection,id user, NSError *error) {
if (error) {
//Sorry check permission or network.
} else {
//Here we can save conversations into an array and print that array...
arrConversation = [[user valueForKey:@"inbox"] valueForKey:@"data"];
NSLog(@"%@", arrConversation);
}
}];
}else{
[FBSession openActiveSessionWithReadPermissions:arrPermission
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (error) {
//Sorry check permission or network.
} else {
NSLog(@"%u", status);
}
}];
}
0 Comment(s)