1

I am trying to get the sentDirectMessages of a twitter user via MGTwitterEngine. However, I am not receiving an MGTwitterEngine delegation method callback from the engine to say its received data.

I put an NSLog to see if the connectionFinished method was being called, and it was, but no other methods were i.e - (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier

Please could you tell me what the problem is, all delegates are set to self.

 [manager.engine getSentDirectMessagesSinceID:0 startingAtPage:0];
max_
  • 24,076
  • 39
  • 122
  • 211

1 Answers1

1
  1. Sry, but I will ask the routine question: Do you have MGTwitterEngineDelegate in your .h file?

  2. I suggest throwing some logging in requestSucceeded: and requestFailed:withError:

  3. Are you successfully doing any other types of Twitter communication within that project? within the same class?

EDIT

I setup a DM request and it worked correctly with a requestSucceeded: and a directMessagesReceived:forRequest:

Based on your:

"So everytime I want to get the dm's of the user, I will have to get the user to logout and then login again."

I am wondering if this is not an issue where the users token is not being stored correctly? I suggest look into how the successful login is storing the token?

In particular this MGTwitterEngineDelegate method.

- (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString *)connectionIdentifier
{
    NSLog(@"Access token received! %@",aToken);
    [manager.engine setAccessToken:aToken];

    //I have an OAToken variable called "token" defined in my .h
    token = [aToken retain];

    NSLog(@"storing token in userdefaults");

    //this line is key for maintaining a login token throughout the app
    //even when the user closes the app and comes back
    [token storeInUserDefaultsWithServiceProviderName:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] prefix:@"twitter"];

    //call your dm or whatever methods for after login here
    .
    .
    .
}

Hope this helps.

dredful
  • 4,378
  • 2
  • 35
  • 54
  • hey, yes to all questions. The request allways succeeds, but the delegate method is only being called when you login. So everytime I want to get the dm's of the user, I will have to get the user to logout and then login again. Have you come across this error before? – max_ Apr 30 '11 at 14:16
  • Sry, I have not come across this problem. I will try some tests later and see if I can come up with anything. – dredful Apr 30 '11 at 14:31
  • Did the token storing fix it? – dredful Apr 30 '11 at 15:36
  • sorry I meant to say the sent dm's rather than the dms in general. – max_ May 01 '11 at 02:28