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

did receive acknowledgments for stanza ids count. #883

Closed RamandeepGosal closed 7 years ago

RamandeepGosal commented 7 years ago

New Issue Checklist

Environment details

Info Value
iOS Version 10.3
Quickblox iOS SDK version 2.9.2
QuickbloxWebRTC SDK version 2.4.2
Xcode Version Xcode 8.3.1
Repro with our demo sample No

Having a strange error of - did receive acknowledgments for stanza ids count

The messages are getting sent but when I reload my tableview to add the message that has been sent. this call is made by the application and this causes strange behaviors in the app. I have tried adding sending messages to background threads as you can see, but it is not helping. Please help me with this.

I am sending the messages like this -

-(void)sendMsg
{
  QBChatMessage *message =[QBChatMessage message];
  [message setText:txtMsg.text];
  NSDateFormatter *formate = [[NSDateFormatter alloc]init];
  formate.dateFormat = @"HH:mm:aa | dd-MM-yyyy";
  NSString *strDate = [formate stringFromDate:[NSDate date]];
  message.customParameters[@"senderName"] = currentUser.fullName;
  message.updatedAt = [formate dateFromString:strDate];
  message.customParameters[@"save_to_history"] = @"1";
  message.dateSent = [NSDate date];
  [message setRecipientID:[_opponentID integerValue]];
  [arrMsgHistory addObject:message];
  [self manageDialogsInSections];
  [tblObj reloadData];
  //[self bringInddividualTopNavBarViewInFrame];
  NSInteger rowPath = [arrMsgSectionHistory[arrMsgSectionHistory.count -1] count] -1;
  NSIndexPath* ipath = [NSIndexPath indexPathForRow: rowPath inSection:arrMsgSectionHistory.count-1];
  txtMsg.text = @"";
  [tblObj scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES];

  dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){

    [_dialog sendMessage:message completionBlock:^(NSError * _Nullable error) {
      if (error == nil)
      {
        NSMutableString *messageValue = [NSMutableString stringWithString:@""];
        if(currentUser.fullName.length > 0){
          [messageValue appendString:currentUser.fullName];
          [messageValue appendString:@": "];
        }
        [messageValue appendString:message.text];

        NSMutableDictionary *payload = [NSMutableDictionary dictionary];
        NSMutableDictionary *aps = [NSMutableDictionary dictionary];
        [aps setObject:@"default" forKey:QBMPushMessageSoundKey];
        [aps setObject:_dialog.ID forKey:DIALOG_ID];
        [aps setObject:[NSString stringWithFormat:@"%lu",(unsigned long)currentUser.ID] forKey:SENDER_ID];
        [aps setObject:@"Private" forKey:@"chatType"];
        [aps setObject:INDIVIDUAL_CHAT forKey:TYPE_OF_CHAT];
        [aps setObject:messageValue forKey:QBMPushMessageAlertKey];
        [payload setObject:aps forKey:QBMPushMessageApsKey];
        QBMPushMessage *pushMessage = [[QBMPushMessage alloc] initWithPayload:payload];
        //Background Thread
        [QBRequest sendPush:pushMessage toUsers:_opponentID successBlock:^(QBResponse *response, QBMEvent *event) {
          [UtilityClass HideHud:self.view];
        } errorBlock:^(QBError *error) {
          // Handle error
          NSLog(@"Failed to send PUSH with error: %@", error);
          [UtilityClass HideHud:self.view];
        }];
      }
    }];
  });
}

I cannot follow the sample app now because This app was already created and I have to make amendments I don't know changing things will cause what effect on the application.

<details>
<summary>Logs from console </summary>

2017-10-06 12:45:20.691109+0530 Panda[722:149458] Dvhghj
2017-10-06 12:45:20.746631+0530 Panda[722:151106] [ChatService] Message SNT: <message id="59d72d88c845f2d2020041e5" type="chat" to="34419722-61375@chat.quickblox.com"><body>Dvhghj</body><extraParams xmlns="jabber:client"><save_to_history>1</save_to_history><senderName>sonia zapbuild</senderName><date_sent>1507274120</date_sent><dialog_id>59d71cbba0eb47260ceb58f5</dialog_id></extraParams></message>
2017-10-06 12:45:20.777280+0530 Panda[722:151090] [ChatService] StreamManagement: did request acknowledgment
2017-10-06 12:45:21.154092+0530 Panda[722:151090] [ChatService] StreamManagement: did receive acknowledgments for stanza ids count: 8
2017-10-06 12:45:21.156876+0530 Panda[722:151090] [QBPushNotifications] message: {
    payload = "{\"aps\":{\"chatType\":\"Private\",\"typeOfChat\":\"1\",\"dialogID\":\"59d71cbba0eb47260ceb58f5\",\"alert\":\"sonia zapbuild: Dvhghj\",\"senderID\":\"33824402\",\"sound\":\"default\"}}";
}
2017-10-06 12:45:21.159142+0530 Panda[722:151090] [QBCore] Request URL:https://api.quickblox.com/events.json
2017-10-06 12:45:21.159255+0530 Panda[722:151090] [QBCore] Request method: POST
2017-10-06 12:45:21.159332+0530 Panda[722:151090] [QBCore] Request parameters:{
    event =     {
        environment = development;
        "event_type" = "one_shot";
        message = "payload=eyJhcHMiOnsiY2hhdFR5cGUiOiJQcml2YXRlIiwidHlwZU9mQ2hhdCI6IjEiLCJkaWFsb2dJRCI6IjU5ZDcxY2JiYTBlYjQ3MjYwY2ViNThmNSIsImFsZXJ0Ijoic29uaWEgemFwYnVpbGQ6IER2aGdoaiIsInNlbmRlcklEIjoiMzM4MjQ0MDIiLCJzb3VuZCI6ImRlZmF1bHQifX0=";
        "notification_type" = push;
        "push_type" = apns;
        user =         {
            ids = 34419722;
        };
    };
}
2017-10-06 12:45:21.159454+0530 Panda[722:151090] [QBCore] Request headers: {
    "Accept-Language" = "en-IN;q=1";
    "Content-Type" = "application/x-www-form-urlencoded";
    "QB-OS" = "iOS 10.3.3";
    "QB-SDK" = "iOS 2.9.2";
    "QB-Token" = bc666f1adf471fb539e20099db3d024af500efbf;
    "QuickBlox-REST-API-Version" = "0.1.1";
    "User-Agent" = "Panda/1.1 (iPhone; iOS 10.3.3; Scale/2.00)";
}
2017-10-06 12:45:24.234388+0530 Panda[722:151106] [QBCore] Response headers: {
    "Access-Control-Allow-Origin" = "*";
    "Cache-Control" = "max-age=0, private, must-revalidate";
    Connection = "keep-alive";
    "Content-Length" = 579;
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Fri, 06 Oct 2017 07:15:23 GMT";
    Etag = "W/\"04372135bc1b305819fa623960d4cc76\"";
    "QB-Token-ExpirationDate" = "2017-10-06 09:11:29 +0000";
    "QuickBlox-REST-API-Version" = "0.1.1";
    Server = "openresty/1.9.15.1";
    "Set-Cookie" = "_mkra_ctxt=430e88719a6287de9c09e12a3f949776--201; path=/; max-age=5; HttpOnly; secure";
    Status = "201 Created";
    "Strict-Transport-Security" = "max-age=31536000, max-age=15768000;";
    "X-Content-Type-Options" = nosniff;
    "X-Frame-Options" = SAMEORIGIN;
    "X-Request-Id" = "7d7a519e-b12f-4726-8c2e-8142c7275e8b";
    "X-Runtime" = "0.038036";
    "X-XSS-Protection" = "1; mode=block";
}
2017-10-06 12:45:24.235660+0530 Panda[722:151106] [QBCore] Response object: {
    event =     {
        active = 1;
        "application_id" = 61375;
        "created_at" = "2017-10-06T07:15:23Z";
        date = "<null>";
        "end_date" = "<null>";
        environment = development;
        "event_type" = "one_shot";
        id = 21022942;
        kind = API;
        message = "payload=eyJhcHMiOnsiY2hhdFR5cGUiOiJQcml2YXRlIiwidHlwZU9mQ2hhdCI6IjEiLCJkaWFsb2dJRCI6IjU5ZDcxY2JiYTBlYjQ3MjYwY2ViNThmNSIsImFsZXJ0Ijoic29uaWEgemFwYnVpbGQ6IER2aGdoaiIsInNlbmRlcklEIjoiMzM4MjQ0MDIiLCJzb3VuZCI6ImRlZmF1bHQifX0=";
        name = "<null>";
        "notification_channel" =         {
            name = apns;
        };
        "occured_count" = 0;
        period = "<null>";
        "tag_query" = "<null>";
        "updated_at" = "2017-10-06T07:15:23Z";
        "user_id" = 33824402;
    };
}

</details>

The call to

[ChatService] StreamManagement: did request acknowledgment

Is made right in the middle when the app is reloading data.

ghost commented 7 years ago

Hi @RamandeepGosal, Could you please update to the latest version of Quickblox.framework and check again?

Thanks.

ghost commented 7 years ago

Hi @RamandeepGosal, Any updates ?

RamandeepGosal commented 7 years ago

Hi @Pro100Andrey, I was on a leave for the day, I'll surely check it today and revert back. Thanks...

RamandeepGosal commented 7 years ago

The versions of quickblox which I am using are-

  - QuickBlox (2.9.2)
  - Quickblox-WebRTC (2.4.2):
  - QuickBlox (>= 2.7)

Are there any newer versions than these? these are already installed using cocoapods dependency.

ghost commented 7 years ago

Hi @RamandeepGosal,

Are there any newer versions than these?

Yes, last version - 2.12.

Thanks.

RamandeepGosal commented 7 years ago

Oh, yes It solved the issue Thank you very much 'Sir' for your courtesy and time.