我在AppDelegate.m
中有这个[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我不知道它在哪里的问题,必须打开一个会话或什么?
仅供参考:此对话框ID" 56d9e95ba28f9a7bf5000058"来自Quickblox仪表板,它不是随机的或假的
由于
答案 0 :(得分:0)
要在群聊对话框中发送消息,您应该在服务器上创建对话框。
对话框必须包含occupantID
+ (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;
答案 1 :(得分: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]
如果这对您有用,请告诉我。