QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
397 stars 358 forks source link

response Code=-1011 "Request failed: not found (404)" #958

Closed siddharth3322 closed 6 years ago

siddharth3322 commented 6 years ago

When QMChatViewController loaded at time, I was getting this kind of error log. Though if you test within devices then you don't feel any problem is running but xCode log showing this kind of error messages.

exnext_chat_error

I hope above log has given you all required details. Please reply me regarding this.

ghost commented 6 years ago

Hi @siddharth3322, Could you provide full logs (not screenshot)?

Thanks!

siddharth3322 commented 6 years ago

yes I can provide you full log now but which component, should I use? If I paste directly log over here then it will create complete mess up and all data get jumbled.

ghost commented 6 years ago

@siddharth3322 use gist - https://gist.github.com

siddharth3322 commented 6 years ago

Here is the uploaded log details: https://gist.github.com/siddharth3322/c1cff8b0578dba4a8af85494450b27fb

ghost commented 6 years ago

@siddharth3322 from your log:

10112018-03-11 20:32:13.042 ExNext[1169:690879] [QBCore] Request URL:https://api.quickblox.com/chat/Message.json?date_sent%5Bgte%5D=0&limit=10&sort_desc=date_sent
2018-03-11 20:32:13.043 ExNext[1169:690879] [QBCore] Request method: GET
2018-03-11 20:32:13.043 ExNext[1169:690879] [QBCore] Request parameters:{
    "date_sent[gte]" = 0;
    limit = 10;
    "sort_desc" = "date_sent";
}

"date_sent[gte]" = 0; - invalid field and you set nil for dialog id (required) in:


+ (QBRequest *)messagesWithDialogID:(NSString *)dialogID
                    extendedRequest:(NSDictionary *) extendedParameters
                            forPage:(QBResponsePage *)page
                       successBlock:(qb_response_messages_block_t)successBlock
                         errorBlock:(qb_response_block_t)errorBlock
siddharth3322 commented 6 years ago

now what should I require to do for solution?

ghost commented 6 years ago

@siddharth3322 my suggestion:

Thanks!

siddharth3322 commented 6 years ago

If I just update the framework file then will it work for me?

ghost commented 6 years ago

Please check documentation - HOWTO Retrieve chat history

Thanks!

siddharth3322 commented 6 years ago

At these two places, I am assigning dialogID

- (void)didPickAttachmentImage:(UIImage *)image {

    if (_chatUser.my_state == connection_state_completed_by_subscribed_user) {
        NSString *strHeOrShe = [_chatUser.gender  isEqual: @"M"] ? @"He" : @"She";
        [self showAlertWithTitle:@"Wait for a reply" withMessage:[NSString stringWithFormat:@"You can't send any more messages to %@ untill %@ replies.",_chatUser.name, strHeOrShe]];
        return;
    }

    QBChatMessage *message = [QBChatMessage new];
    message.senderID = self.senderID;
    message.dialogID = self.dialog.ID;
    message.dateSent = [NSDate date];

Here is another place:

 if (attachment.image) {

//         NSLog(@"-----> didPressSendButton - First - userInitiatedConnection - IF");
        [self userInitiatedConnection];

        QBChatMessage *message = [QBChatMessage new];
        message.senderID = self.senderID;
        message.dateSent = [NSDate date];

        if (self.dialog.ID) {
            message.dialogID = self.dialog.ID;

            [self.chatDataSource addMessage:message];

            [[QMServicesManager instance].chatService sendAttachmentMessage:message
                                                                   toDialog:self.dialog
                                                        withAttachmentImage:attachment.image
                                                                 completion:^(NSError *error) {

                                                                     [self.attachmentCells removeObjectForKey:message.ID];

                                                                     if (error != nil) {
                                                                         // perform local attachment deleting
                                                                         [self.chatDataSource deleteMessage:message];
                                                                         [self showAlertWithTitle:@"Failed" withMessage:error.localizedDescription];
                                                                         // [SVProgressHUD showErrorWithStatus:error.localizedDescription];
                                                                     }
                                                                 }];
        }

This is last way:

- (void)chatService:(QMChatService *)chatService didUpdateChatDialogInMemoryStorage:(QBChatDialog *)chatDialog {
    if (self.dialog.type != QBChatDialogTypePrivate && [self.dialog.ID isEqualToString:chatDialog.ID]) {
        self.dialog  = chatDialog;
        self.title = self.dialog.name;
    }
}

So at which place my ID going wrong for dialog?

ghost commented 6 years ago

@siddharth3322 for fix your issue you should check this method:

+ (QBRequest *)messagesWithDialogID:(NSString *)dialogID
                    extendedRequest:(NSDictionary *) extendedParameters
                            forPage:(QBResponsePage *)page
                       successBlock:(qb_response_messages_block_t)successBlock
                         errorBlock:(qb_response_block_t)errorBlock

and investigate calls tree from debugger

siddharth3322 commented 6 years ago

can you tell me exactly in which class this method exist?

Within my code I can't able to find this one...

siddharth3322 commented 6 years ago

I have not written this method any where in my code: messageswithdialogid_method_call

ghost commented 6 years ago

https://github.com/QuickBlox/q-municate-services-ios/blob/3370000d584c46051077b99f81bf603bf8fe7682/QMChatService/QMChatService/QMChatService.m#L995

ghost commented 6 years ago

yes but you call this method

ghost commented 6 years ago

and you should check why dialogID == nil

ghost commented 6 years ago

For example check our chat sample - https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat. Works fine.

siddharth3322 commented 6 years ago

Okay I will do this 👍

Now help me in my another posted issue.

ghost commented 6 years ago

From Quicblox "Response codes and errors" documentation: The requested resource could not be found:

ghost commented 6 years ago

Hi @siddharth3322, any updates ?

siddharth3322 commented 6 years ago

Basically I am new to application development and first time implementing chatting system within my application so at present I was searching exactly what I require to update!!!

sagarmseven commented 6 years ago

how to solve issue error: Request failed: not found (404) reasons: { code = ""; message = "Couldn't find user"; }