简体   繁体   English

在iOS中使用Quickblox中的聊天功能

[英]Working with Chat feature in Quickblox in iOS

I want to implement chat feature in my app,its actually one to one chat,i have downloaded sample code from quickblox.com 我想在我的应用程序中实现聊天功能,它实际上是一对一的聊天,我已经从quickblox.com下载了示例代码

I have registered in Quickblox and just added my credentials in sample application which I downloaded, I'm getting the following issues 我已经在Quickblox中注册,并且刚刚在下载的示例应用程序中添加了我的凭据,但是出现了以下问题

1.404 and Token is required. 1.404和令牌是必需的。

I'm unsure whether I need to use API calls and where I can find API calls. 我不确定是否需要使用API​​调用以及在哪里可以找到API调用。

Can anybody please explain or provide me sample code to work. 任何人都可以解释或提供示例代码来工作吗?

I just implemented chat feature in my app. 我刚刚在应用中实现了聊天功能。 So I am elaborate you short description of how to enable chat in your app using Quickblox .Integrate sdk of Quickblox in your app or use pod. 所以我详细说明你如何使用,以确保您的应用程序的聊天简短描述Quickblox的.Integrate SDK Quickblox在您的应用程序或使用吊舱。

First of all go through this link quickblox ios chat tutorial than create users register users from here than in your app, login in Quickblox by using this code 首先,通过此链接quickblox ios聊天教程 ,然后创建用户从此处而不是在您的应用程序中注册用户Quickblox使用此代码登录Quickblox

Method to login in Quickblox 在Quickblox中登录的方法

[QBRequest logInWithUserLogin: self.Name.text password:self.Password.text  successBlock:^(QBResponse *response, QBUUser *user)
 {

 }
                   errorBlock:^(QBResponse *response)
 {

     NSLog(@"error: %@", response.error);
 }];

Dialog box means to create session between users like : one to one or group chat 对话框意味着在用户之间创建会话,例如:一对一或群聊

You need to create dialog box in order to enable chat, here is demo code of how to create dialog 您需要创建对话框以启用聊天功能,这是如何创建对话框的演示代码

//create dialog

QBChatDialog *chatDialog = [[QBChatDialog alloc] initWithDialogID:null type:QBChatDialogTypeGroup];
chatDialog.name = @"Chat with Bob, Sam, Garry";
chatDialog.occupantIDs = @[@(55), @(678), @(22)];

// change id with your register user's id

[QBRequest createDialog:chatDialog successBlock:^(QBResponse *response, QBChatDialog *createdDialog)
 {

 } errorBlock:^(QBResponse *response)
 {

 }];

// you can see created dialogbox in your quickblox admin panel in chat option
**//retrive list of buddies**

QBGeneralResponsePage *page = [QBGeneralResponsePage responsePageWithCurrentPage:1 perPage:10];
[QBRequest usersForPage:page successBlock:^(QBResponse *response, QBGeneralResponsePage *pageInformation, NSArray *users)
 {
     NSLog(@"%lu",(unsigned long)users.count);
     for (int i=0; i<users.count; i++)
     {
         QBUUser *user = [users objectAtIndex:i];
         [buddyData addObject:user];
     }
     [self.buddyList reloadData];
 }
             errorBlock:^(QBResponse *response)
 {
 } ];

This is basic setup of Quickblox in your app. 这是您应用中Quickblox基本设置。 All details are already given in Quickblox tutorial. Quickblox教程中已经给出了所有详细信息。 If you need any help than just tell me. 如果您需要任何帮助,不只是告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM