2016-04-02 36 views
0

我正在使用QBSimpleChat SDK。我用魔杖发送简单的群消息。请帮忙。这是我的代码。看看我错过了什么。提前致谢。如何使用quickblox sdk发送简单的文本消息?

QBChatMessage * inviteMessage = [QBChatMessage message];

 NSMutableDictionary *customParams = [NSMutableDictionary new]; 
     //customParams[@"xmpp_room_jid"] = roomJID; 
     customParams[@"name"] = name; 
     customParams[@"_id"] = senderId1; 
     customParams[@"save_to_history"] = @YES; 

     //customParams[@"type"] = 2; 
     inviteMessage.senderID = senderId; 
     inviteMessage.dateSent = [NSDate date]; 
     inviteMessage.senderNick = @"me"; 
     inviteMessage.text = text; 

     customParams[@"occupants_ids"] = [occupides componentsJoinedByString:@","]; 
     NSString *afterSpace= [occupides componentsJoinedByString:@" "]; 
     NSUInteger num = [oneer integerValue]; 
     NSTimeInterval timestamp = (unsigned long)[[NSDate date] timeIntervalSince1970]; 
     customParams[@"date_sent"] = @(timestamp); 


     // send notification 
     // 
     inviteMessage.recipientID = num; 

     //} 
     inviteMessage.customParameters = customParams; 







    [QBRequest createMessage:inviteMessage successBlock:^(QBResponse *response, QBChatMessage *createdMessage) { 
     NSLog(@"success: %@", createdMessage); 
    } errorBlock:^(QBResponse *response) { 
     NSLog(@"ERROR: %@", response.error); 
    }]; 
    [self.chatSectionManager addMessage:inviteMessage]; 

    [self finishSendingMessageAnimated:YES]; 
    NSLog(@"message for group is = %@",inviteMessage); 

回答

0

可以使用QBChatDialog实例的方法发送消息:

- (void)sendMessage:(QB_NONNULL QBChatMessage *)message completionBlock:(QB_NULLABLE_S QBChatCompletionBlock)completion; 

更多进一步的解释,请遵循our guide

相关问题