Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Get all Facebook chat messages in iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 351
    Comment on it

    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/

    1. NSMutableArray *arrConversation = [[NSMutableArray alloc]init];
    1. NSArray *arrPermission = @[@"read_mailbox"];
    2. if ([[FBSession activeSession]isOpen]) {
    1. [FBRequestConnection startWithGraphPath:@"/me?fields=inbox" completionHandler:^(FBRequestConnection *connection,id user, NSError *error) {
    2. if (error) {
    3. //Sorry check permission or network.
    4. } else {
    5.  
    6. //Here we can save conversations into an array and print that array...
    7. arrConversation = [[user valueForKey:@"inbox"] valueForKey:@"data"];
    8. NSLog(@"%@", arrConversation);
    9. }
    10. }];
    11. }else{
    12. [FBSession openActiveSessionWithReadPermissions:arrPermission
    13. allowLoginUI:YES
    14. completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    15. if (error) {
    16. //Sorry check permission or network.
    17. } else {
    18. NSLog(@"%u", status);
    19. }
    20. }];
    21. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: