2016-03-05 139 views
0

我有這樣的AppDelegate.m發送消息對話框的iOS Quickblox

[QBSettings setApplicationID:xxxxxx]; 
    [QBSettings setAuthKey:@"dsad"]; 
    [QBSettings setAuthSecret:@"asdd"]; 
    [QBSettings setAccountKey:@"asdsda"]; 
    [QBSettings setLogLevel:QBLogLevelNothing]; 

    [QBRequest logInWithUserLogin:@"testuser" password:@"testuser" successBlock:^(QBResponse *response, QBUUser *user) { 
     if (user) { 
      user.login = @"testuser"; 
      user.password = @"testuser"; 
      // __typeof(self) strongSelf = weakSelf; 
      [[QBChat instance] connectWithUser:user completion:^(NSError * _Nullable error) { 
} 
      ]; 
     } 
    } errorBlock:^(QBResponse * _Nonnull response) { 

    }]; 

這種努力在另一個ViewController.m

QBChatMessage *messagetosend = [QBChatMessage message]; 
    messagetosend.senderID = 10516336; 
    messagetosend.senderNick = @"Andrey M."; 
    messagetosend.text = @"test test"; 
    messagetosend.dateSent = [NSDate dateWithTimeInterval:-12.0f sinceDate:[NSDate date]]; 

    QBChatDialog *chatDialog = [[QBChatDialog alloc] initWithDialogID:@"56d9e95ba28f9a7bf5000058" type:QBChatDialogTypePublicGroup]; 

    [chatDialog joinWithCompletionBlock:^(NSError * _Nullable error) { 
     [chatDialog sendMessage:messagetosend completionBlock:^(NSError * _Nullable error) { 
      NSLog(@"%@",[error localizedDescription]); 
     }]; 

    }]; 

發送消息,但消息沒有發送到我在quickblox儀表板中檢查的對話框不起作用。我使用PHP框架,它的工作原理,但在iOS中,我不知道它在哪裏的問題,必須打開一個會議或什麼?

FYI:從Quickblox儀表盤此對話框ID「56d9e95ba28f9a7bf5000058」這不是隨機或假

感謝

+0

首先請隱藏您的應用程序ID。 –

+0

你可以檢查消息發送完成塊是否有錯誤嗎? –

回答

0

爲了在羣聊對話發送消息,你應該在服務器上創建對話框。

對話框必須包含occupantIDs

+ (QB_NONNULL QBRequest *)createDialog:(QB_NONNULL QBChatDialog *)dialog 
          successBlock:(QB_NULLABLE void(^)(QBResponse * QB_NONNULL_S response, QBChatDialog * QB_NULLABLE_S createdDialog))successBlock 
          errorBlock:(QB_NULLABLE QBRequestErrorBlock)errorBlock; 
0

您必須發送自定義參數

messagetosend.senderID = 10516336; 
messagetosend.senderNick = @"Andrey M."; 
messagetosend.text = @"test test"; 
/** You will see the on dashboard after you set save_to_history to true **/ 
messagetosend.customParameters = ["application_id":kQBApplicationID, "save_to_history":true] 

讓我知道這對你的作品。

+0

它適合你嗎? –