Search code examples
quickblox

Quickblox: Custom Module - Custom callback function instead of default 'completedWithResult'


When using 'Custom Module', there are times when multiple asynchronous requests happen at the same time (handled by the same delegate) and there is a need to distinguish which request triggered the 'completedWithResult' callback.

Is there a way to provide a custom callback function for a particular request? If not, what would be the best way to distinguish between multiple requests inside the 'completedWithResult'callback?


Solution

  • You should use context

     [QBUsers logInWithUserLogin:@"injoitUser1" password:@"injoitUser1" delegate:self context:@"thisIsPoint1"];
    
     [QBUsers logInWithUserLogin:@"injoitUser1" password:@"injoitUser1" delegate:self context:@"thisIsPoint2"];
    
    - (void)completedWithResult:(Result *)result context:(void *)contextInfo{
        if([result isKindOfClass:QBUUserLogInResult.class]){
            if(result.success){
                if([((NSString *)contextInfo) isEqualToString:@"thisIsPoint1"]){
                    // do smthn
                }
            }
    }