> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quickblox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> Learn how to install QuickBlox SDK and send your first message.

QuickBlox SDK helps you implement real-time chat, video chat, and push notifications to your app. You can fully concentrate on your mobile app development. QuickBlox iOS SDK supports both **Swift** and **Objective-C** programming languages.

## Start with sample apps

If you are just starting your app and developing it from scratch, we recommend to use our sample apps. We use GitHub repositories to make it easy to explore, copy, and modify our code samples. The guide on how to launch and configure the sample app is on GitHub.

### Chat samples

Choose the code sample below to jump-start the development.

<CardGroup>
  <Card title="Objective-C Chat Sample App" icon="apple">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat-obj-c">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/ios-chat">
      <Icon icon="book" />  Documentation
    </a>
  </Card>

  <Card title="Swift Chat Sample App" icon="swift">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat-swift">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/ios-chat">
      <Icon icon="book" />  Documentation
    </a>
  </Card>
</CardGroup>

### Video calling samples

Choose the code sample below to jump-start the development.

<CardGroup>
  <Card title="Objective-C Video Calling Sample App" icon="apple">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-videochat-webrtc">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/ios-video-calling">
      <Icon icon="book" />  Documentation
    </a>
  </Card>

  <Card title="Swift Video Calling Sample App" icon="swift">
    <a className="inline-link" href="https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-videochat-webrtc-swift">
      <Icon icon="github" /> View on GitHub
    </a>

    <br />

    <a className="inline-link" href="/sdks/ios-video-calling">
      <Icon icon="book" />  Documentation
    </a>
  </Card>
</CardGroup>

### More samples

For more samples, head to our [Code Samples](/code-samples/code-samples) page. These sample apps are available on GitHub so feel free to browse them there. Just clone the repository and modify the source code for your own projects.

## Get application credentials

QuickBlox application includes everything that brings messaging right into your application - chat, video calling, users, push notifications, etc. To create a QuickBlox application, follow the steps below:

1. Register a new account following [this link](https://admin.quickblox.com/signup). Type in your email and password to sign in. You can also sign in with your Google or GitHub accounts.
2. Create the app clicking **New app** button.
3. Configure the app. Type in the information about your organization into corresponding fields and click **Add** button.
4. Go to **Dashboard => *YOUR\_APP* => Overview**  section and copy your **Application ID**, **Authorization Key**, **Authorization Secret**, and **Account Key** .

## Requirements

The minimum requirements for QuickBlox iOS SDK are:

* iOS 13.0
* CocoaPods 1.1
* Xcode 11

## Install QuickBlox SDK into your app

You can install the QuickBlox iOS SDK using either SPM (Swift Package Manager) or CocoaPods.

### Swift Package Manager

<Warning>
  QuickBlox iOS SDK is available using the \[Swift Package Manager] ([https://www.swift.org/package-manager/](https://www.swift.org/package-manager/)) (SPM) since version 2.18.1 for QuickBlox and since version 2.8.1 for QuickbloxWebRTC.
</Warning>

To add QuickBlox iOS SDK to your project using SPM, you can follow these steps:

1. Open your Xcode project and navigate to File > Swift Packages > Add Package Dependency.
2. In the search bar, enter the QuickBlox repository URL: [https://github.com/QuickBlox/ios-quickblox-sdk.git](https://github.com/QuickBlox/ios-quickblox-sdk.git) or QuickbloxWebRTC repository URL: [https://github.com/QuickBlox/ios-quickblox-sdk-webrtc.git](https://github.com/QuickBlox/ios-quickblox-sdk-webrtc.git) and click Add Package.
3. Xcode will then fetch the SDK and you can add it to your project by clicking Add Package.
4. You can then import QuickBlox modules into your code and use its API.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    import Quickblox
    import QuickbloxWebRTC
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    #import <Quickblox/Quickblox.h>
    #import <QuickbloxWebRTC/QuickbloxWebRTC.h>
    ```
  </Tab>
</Tabs>

For more information on spm customization options, you can refer to the [Apple Documentation](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app).

### CocoaPods

<Note>
  [CocoaPods](https://cocoapods.org) must be installed.
</Note>

1. Create a `Podfile`. Project dependencies should be managed by CocoaPods. Create this file in the same directory with your project.

```Bash Bash theme={null}
pod init
touch Podfile
open -e Podfile
```

2. Open the created `Podfile` and enter the following code lines into it. Specify the SDK version being installed.

```Podfile Podfile theme={null}
platform :ios, "12.0"
use_frameworks!
target 'MyApp' do
    pod 'QuickBlox', '~> 2.17.10'
    pod 'Quickblox-WebRTC', '~> 2.7.6'
end
```

3. Install QuickBlox dependencies in your project.

```Bash Bash theme={null}
pod install
```

4. Import headers to start using QuickBlox frameworks.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    import Quickblox
    import QuickbloxWebRTC
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    #import <Quickblox/Quickblox.h>
    #import <QuickbloxWebRTC/QuickbloxWebRTC.h>
    ```
  </Tab>
</Tabs>

## Send your first message

### Initialize QuickBlox SDK

Initialize the framework with `applicationID`, `authKey`, `authSecret`, and `accountKey`. Add the code below to the **AppDelegate** file located in the root directory of your project:

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    Quickblox.initWithApplicationId(92, authKey: "wJHdOcQSxXQGWx5", authSecret: "BTFsj7Rtt27DAmT", accountKey: "7yvNe17TnjNUqDoPwfqp")
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    [Quickblox initWithApplicationId:92 authKey:@"wJHdOcQSxXQGWx5" authSecret:@"BTFsj7Rtt27DAmT" accountKey:@"7yvNe17TnjNUqDoPwfqp"];
    ```
  </Tab>
</Tabs>

<Warning>
  **Security**

  It's not recommended to keep your **authKey** and **authSecret** inside an application in production mode, instead of this, the best approach will be to store them on your backend and initialize QuickBlox SDK with applicationId and acountKey only. More details you can find in [Initialize QuickBlox SDK without Authorization Key and Secret](/sdks/ios-setup#initialize-quickblox-sdk-without-authorization-key-and-secret) section.
</Warning>

### Authorize user

Now, it is time to log in with the user. To create a user session, call the `logIn()` method and pass the user login and user password as arguments to it.

<Tabs>
  <Tab title="Swift Concurrency">
    ```Swift theme={null}
    let user = try await QBRequest.login("userLogin", password: "userPassword")
    ```
  </Tab>

  <Tab title="Swift">
    ```Swift theme={null}
    QBRequest.logIn(withUserLogin: "userLogin", password: "userPassword", successBlock: { (response, user) in

    }, errorBlock: { (response) in

    })
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objc theme={null}
    [QBRequest logInWithUserLogin:@"userLogin" password:@"userPassword" successBlock:^(QBResponse * _Nonnull response, QBUUser * _Nonnull tUser) {

    } errorBlock:^(QBResponse * _Nonnull response) {

    }];
    ```
  </Tab>
</Tabs>

### Connect to chat

Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call the `connect()` method and pass the `user.id` and `user.password` to it.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    QBChat.instance.connect(withUserID: user.id, password: user.password, completion: { (error) in

    })
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    [QBChat.instance connectWithUserID:currentUser.ID password:currentUser.password completion:^(NSError * _Nullable error) {

    }];
    ```
  </Tab>
</Tabs>

### Create dialog

QuickBlox provides three types of dialogs: **1-1 dialog**, **group dialog**, and **public dialog**. Learn more about dialogs [here](/sdks/ios-chat-dialogs#create-dialog).

Let’s create a simple **1-1 dialog**. Create a `QBChatDialog` instance and set the `dialogID`, `type`, and `occupantIDs` fields. Call the `createDialog()` method and pass the `dialog` to it as an argument.

<Tabs>
  <Tab title="Swift Concurrency">
    ```Swift theme={null}
    let dialogInfo = QBChatDialog.create(.private)
    dialogInfo.occupantIDs = [34]
    let dialog = try await QBRequest.createDialog(dialogInfo)
    ```
  </Tab>

  <Tab title="Swift">
    ```Swift theme={null}
    let dialogInfo = QBChatDialog.create(.private)
    dialogInfo.occupantIDs = [34]
    QBRequest.createDialog(dialogInfo, successBlock: { (response, dialog) in

    }, errorBlock: { (response) in

    })
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objc theme={null}
    QBChatDialog *dialogInfo = [QBChatDialog create:QBChatDialogTypePrivate];
    dialogInfo.occupantIDs = @[@34]; // an ID of opponent
    [QBRequest createDialog:dialogInfo successBlock:^(QBResponse * _Nonnull response, QBChatDialog * _Nonnull dialog) {

    } errorBlock:^(QBResponse * _Nonnull response) {

    }];
    ```
  </Tab>
</Tabs>

### Receive messages

To track events in your chat (for example, receive messages, track to whom your messages are delivered and who read them), you must implement the chat delegate methods for your chat controller. Use the `addDelegate()` method to add a listener enabling the app to listen to the received messages. In other words, you subscribe to this event using chat delegate in your chat controller.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    QBChat.instance.addDelegate(self)
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    [QBChat.instance addDelegate: self];
    ```
  </Tab>
</Tabs>

Implement the`QBChatDelegate` methods you need in your chat controller.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    /// MARK: - QBChatDelegate
    extension YourViewController: QBChatDelegate {
        // MARK: - Manage chat receive message callback's
        func chatRoomDidReceive(_ message: QBChatMessage, fromDialogID dialogID: String) {
            // Called whenever group chat dialog did receive a message.
            // !!!note Will be called on both recipients' and senders' device (with corrected time from server)
        }
        func chatDidReceive(_ message: QBChatMessage) {
            // Called whenever new private message was received from QBChat.
            // !!!note Will be called only on recipient device
        }
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    /// MARK: - QBChatDelegate
    // MARK: - Manage chat receive message callback's
    - (void)chatDidReceiveMessage:(QBChatMessage *)message {
        // Called whenever new private message was received from QBChat.
        // !!!note Will be called only on recipient device
    }
    - (void)chatRoomDidReceiveMessage:(QBChatMessage *)message fromDialogID (NSString*)dialogID {
        // Called whenever group chat dialog did receive a message.
        // !!!note Will be called on both recepients' and senders' device (with corrected time from server)
    }
    ```
  </Tab>
</Tabs>

### Send message

To send a message, create `QBChatMessage` instance. Set the text of the message. Call the `send()` method and pass the `message` as an argument to it.

<Tabs>
  <Tab title="Swift">
    ```Swift theme={null}
    let message = QBChatMessage()
    message.text = "How are you today?"
    message.customParameters["save_to_history"] = true
    let privateDialog = ...
    privateDialog.send(message) { (error) in
    }

    //MARK: ChatDelegate
    func chatDidReceive(_ message: QBChatMessage) {
     }
    ```
  </Tab>

  <Tab title="Objective-C">
    ```Objective-C theme={null}
    QBChatMessage *message = [[QBChatMessage alloc] init];
    message.text = @"How are you today?";
    message.customParameters[@"save_to_history"] = @"1";
    QBChatDialog *privateDialog = ...;
    [privateDialog sendMessage:message completionBlock:^(NSError * _Nullable error) {
    }];

    //MARK: ChatDelegate
    - (void)chatDidReceiveMessage:(QBChatMessage *)message {
    } (edited)
    ```
  </Tab>
</Tabs>

<Note>
  Set the `save_to_history` parameter if you want this message to be saved in chat history.
</Note>
