# Get Started

## Configure and Initialize TapTalk.io iOS SDK

#### **Step 1: Create a new application from your dashboard**

**1.** Login to [TapTalk.io Dashboard](https://taptalk.io/), then choose **Development** -> **Apps**

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHKvQJYwokZj2SvRd6U%2F08a4ad0-Screenly_-_9.0_Development_-_Apps_-_Empty_State2x.png?alt=media\&token=6f629f44-d932-400f-984d-2fb1a1f0e408)

**2**. Click **New App** Button, input **App Name** and choose **Platform**, and then click **Create New App** Button.

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHKxC_cD1-kv3lPxiSk%2F58201a8-Screenly_-_9.1.0_Development_-_Apps_-_New_App_-_Empty_State2x.png?alt=media\&token=ab2fe069-a0b6-4d22-86d3-fdd8e51c235f)

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHKxGJV7RBtqLBu8UwT%2Ff2a1418-Screenly_-_9.1.1_Development_-_Apps_-_New_App_-_Filled2x.png?alt=media\&token=5b628aa3-05ec-47e9-98ef-dbc2c23de5bc)

**3.** A pop-up dialog will be shown with provided **App Key ID** & **App Key Secret**

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHKxQLyhxLOunGM05hx%2Ff869a40-Screenly_-_9.1.3_Development_-_Apps_-_New_App_-_Your_App_Key_-_Dismiss2x.png?alt=media\&token=b7bfb1cb-65ff-47e6-beda-69011f5addb8)

{% hint style="warning" %}
**Note:** Please remember to save your **App Key ID** & your **App Key Secret** because it will only be shown once and will be used in [TapTalk.io initialization](#step-5-initialize-taptalk-io-in-your-application-class)
{% endhint %}

#### Step 2: Install TapTalk.io SDK

You can install the TapTalk.io iOS SDK using [CocoaPods](https://cocoapods.org/) like the following. If you are new to CocoaPods, you can see more information in [Cocoapods guides](https://guides.cocoapods.org/using/getting-started.html). To create a **Podfile**, open a terminal window, navigate to your project directory, and then create a **Podfile** by running the following command:

{% tabs %}
{% tab title="Terminal" %}

```bash
$ pod init
```

{% endtab %}
{% endtabs %}

Then **Podfile** will be created in your project directory. Open the **Podfile** and add the following lines to the **Podfile**.

{% tabs %}
{% tab title="Podfile" %}

```ruby
# Please make sure you define platform on your Podfile
# Make sure to use ios 11.0 for minimum deployment target

platform :ios, '11.0'
use_modular_headers!

target "YourProjectName" do
    pod 'TapTalk'
end
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %} <mark style="color:red;">**Note**</mark><mark style="color:red;">:</mark> <mark style="color:red;"></mark><mark style="color:red;">**For SDK version 1.4.1 and above,**</mark><mark style="color:red;">**&#x20;**</mark><mark style="color:red;">**`use_frameworks!`**</mark><mark style="color:red;">**&#x20;**</mark><mark style="color:red;">**can be replaced with**</mark><mark style="color:red;">**&#x20;**</mark><mark style="color:red;">**`use_modular_headers!`**</mark><mark style="color:red;">**&#x20;**</mark><mark style="color:red;">**to handle some compatibility issues.**</mark>

For versions below 1.4.1, you can replace **`use_modular_headers!`** on the code above with **`use_frameworks!`**
{% endhint %}

{% hint style="warning" %}
**Note**: Please make sure you implement ios version 11.0 \
`platform :ios, '11.0'` \
for minimum deployment target to obtain the latest update of TapTalk.io SDK
{% endhint %}

Since TapTalk.io use uses **`git-lfs`** (Git Large Files Storage) you will need to install **GIT LFS** to clone/install TapTalk.io SDK through **Cocoapods**.

{% hint style="warning" %}
**Note**: Make sure to install **`git-lfs`**&#x62;efore pod install, otherwise the pod install / pod update will return an error
{% endhint %}

Easiest way to install [git-lfs](https://git-lfs.github.com) is using [brew](https://brew.sh):

{% tabs %}
{% tab title="Terminal" %}

```bash
brew install git-lfs
git lfs install
```

{% endtab %}
{% endtabs %}

Next, after the **`git-lfs`** is installed, install the TapTalk.io SDK through CocoaPods.

{% tabs %}
{% tab title="Terminal" %}

```bash
$ pod install
```

{% endtab %}
{% endtabs %}

#### Step 3: Grant permission in your application project

To make sure TapTalk.io has all permission to access the user's media, file, location, and contact, the application needs to ask for permission. Go to your **info.plist**, and add the following key-value pairs.

<table data-header-hidden><thead><tr><th width="339">Information Property Key</th><th>Information Property Value</th></tr></thead><tbody><tr><td><strong>Information Property Key</strong></td><td><strong>Information Property Value</strong></td></tr><tr><td>Privacy - Camera Usage Description</td><td>$(PRODUCT_NAME) needs to request access to your camera to send image messages and take profile picture.</td></tr><tr><td>Privacy - Contacts Usage Description</td><td>$(PRODUCT_NAME) need your permission to access your contact, we will sync your contact to our server and automatically find your friend so it is easier for you to find your friends.</td></tr><tr><td>Privacy - Photo Library Additions Usage Description</td><td>$(PRODUCT_NAME) needs to request access to your photo library to save photos.</td></tr><tr><td>Privacy - Photo Library Usage Description</td><td>$(PRODUCT_NAME) needs to request access to your photo library to send image messages and select profile picture.</td></tr><tr><td>Privacy - Location When In Use Usage Description</td><td>$(PRODUCT_NAME) needs to request access to your location to send location messages.</td></tr><tr><td>Privacy - Microphone Usage Description</td><td>$(PRODUCT_NAME) needs to request access to your microphone to record audio to send voice messages.</td></tr></tbody></table>

{% hint style="info" %}
**Note:** You can change **Information Property Value** with your preferred message, the string value will be displayed when the application requests the permission.
{% endhint %}

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHLISj3JHnpzjIeKv5r%2F8b43524-Screen_Shot_2019-08-28_at_13.57.43.png?alt=media\&token=b918d137-bd53-43fc-84df-ae605c44b0c9)

#### Step 4: Enable background modes

Background modes is required to handle background process in TapTalk.io. It is used to run some processes in the background before the app is killed. For more information about the processes, check out the [background process section](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/background-process-in-taptalk.io).\
To enable **background modes**, go to **Target** -> **Capabilities**, then turn **Background Modes** toggle to **ON**, next select **Background fetch** and **Remote notifications**

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHLIm1-VkzIwjxQilqS%2Feaab744-Screen_Shot_2019-08-28_at_13.37.54.png?alt=media\&token=02281a47-665d-4403-8062-8fb0fe48c64b)

After you turn on the **Background Modes**, **Required background modes** key will be added automatically in your **Info.plist** as shown below.

![](https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfVupFSqh_qZAY9OiCO%2F-MHKsq4vOlouRa03adbb%2F-MHLItjSE_HAsYniTXmS%2F979a00b-Screen_Shot_2019-08-28_at_13.44.36.png?alt=media\&token=ed490114-336d-4b7c-9777-7a6ddd88a521)

#### Step 5: Initialize Taptalk.io in your Application class

In order to use TapTalk.io, you must first initialize a TapTalk.io instance by passing the `APP_KEY_ID`, `APP_KEY_SECRET`, `APP_BASE_URL`, and `IMPLEMENTATION_TYPE` assigned to your application to the `initWithAppKeyID:appKeySecret:apiURLString:implementationType:` method as a parameter. Generally, initialization is implemented in the **appDelegate** `application:didFinishLaunchingWithOptions:` method.

{% hint style="warning" %}
**Note:** To get **BASE\_URL** you can follow our documentation on [how to get Base URL](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-server-api/base-url) on TapTalk.io.
{% endhint %}

{% tabs %}
{% tab title="Objective-C" %}
{% code title="AppDelegate.m" %}

```csharp
// Import TapTalk.io
#import <TapTalk/TapTalk.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Initialize TapTalk.io
    [[TapTalk sharedInstance] initWithAppKeyID:APP_KEY_ID appKeySecret:APP_KEY_SECRET apiURLString:APP_BASE_URL implementationType:IMPLEMENTATION_TYPE];
  
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**APP\_KEY\_ID**: (String) application key ID\
**APP\_KEY\_SECRET**: (String) application key Secret\
**APP\_BASE\_URL**: (String) base API URL\
**IMPLEMENTATION\_TYPE**: (enum) found in TapTalkImplentationType, more detailed information below
{% endhint %}

{% hint style="info" %}
**IMPLEMENTATION\_TYPE**\
TapTalkImplementationType consists of 3 types which are:\
\&#xNAN;**`TapTalkImplementationTypeUI`**: used for implementation with only TapUI\
\&#xNAN;**`TapTalkImplementationTypeCore`**: used for implementation with only TapCore\
\&#xNAN;**`TapTalkImplementationTypeCombine`**: used for implementation with both of TapCore and TapUI combined
{% endhint %}

{% hint style="info" %}
**Note**: In the [Event Delegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate) page, you can find detailed information on the usages of TapTalk iOS SDK's delegates and callbacks.
{% endhint %}

You may also call `initWithAppKeyID:appKeySecret:apiURLString:implementationType:success:` to obtain callback once the initialization is finished.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="AppDelegate.m" %}

```csharp
// Import TapTalk.io
#import <TapTalk/TapTalk.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
  //Initialize TapTalk.io
  [[TapTalk sharedInstance] initWithAppKeyID:APP_KEY_ID 
                                appKeySecret:APP_KEY_SECRET 
                                apiURLString:APP_BASE_URL 
                          implementationType:IMPLEMENTATION_TYPE
                                     success:^{
      // Initialization finished
  }];
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**APP\_KEY\_ID**: (String) application key ID\
**APP\_KEY\_SECRET**: (String) application key Secret\
**APP\_BASE\_URL**: (String) base API URL\
**IMPLEMENTATION\_TYPE**: (enum) found in TapTalkImplentationType, more detailed information below
{% endhint %}

{% hint style="info" %}
**IMPLEMENTATION\_TYPE**\
TapTalkImplementationType consists of 3 types which are:\
\&#xNAN;**`TapTalkImplementationTypeUI`**: used for implementation with only TapUI\
\&#xNAN;**`TapTalkImplementationTypeCore`**: used for implementation with only TapCore\
\&#xNAN;**`TapTalkImplementationTypeCombine`**: used for implementation with both of TapCore and TapUI combined
{% endhint %}

#### Step 6: Implement application delegate

To allow the iOS SDK to respond to the connection and state changes in your iOS client app, you have to implement all of our application delegate methods in your UIApplicationDelegate methods in appDelegate file. You can follow the instructions in [Implement Application Delegate page](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/implement-application-delegate).

#### Step 7: Authenticate to TapTalk.io

In order to use the abilities of the iOS SDK in your client app, a TapTalk instance must be initiated in each client app through user authentication with TapTalk.io server. An authenticated user account allows the instance to communicate and interact with the server. To authenticate your user with the server, follow the instructions in [Authentication page](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/authentication).

### Initialize Google Places API Key (Optional)

To enable location search result preview while sending location message, a Google Places API Key is required. To obtain the API key for your application, you can check [the documentation](https://developers.google.com/places/web-service/get-api-key) provided by Google. To initialize, insert your obtained key using the `initializeGooglePlacesApiKey()` method.

{% tabs %}
{% tab title="Objective-C" %}

```csharp
#import <TapTalk/TapTalk.h>
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //Initialize Google Places API Key
    [[TapTalk sharedInstance] initializeGooglePlacesAPIKey:GOOGLE_PLACES_API_KEY]; 
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**GOOGLE\_PLACES\_API\_KEY**: (String) Google Places API Key
{% endhint %}

{% hint style="info" %}
Starting from version **2.16.0**, location attachment will be enabled by default even when Google Places API Key is not provided, but location search will be hidden.\
To disable location attachment, you may call:

```
[[TapUI sharedInstance] setLocationAttachmentEnabled:NO];
```

{% endhint %}

## Open Your First Room List

To open room list view, simply initialize `TAPRoomListViewController` and choose to present or push the selected controller to your current view. Here we use **TapUI** to open room list view. Creating a user interface won't be necessary, because TapTalk.io have provided an integrated user interface to be used in your application. To use TapTalk.io's chat interface, simply initialize our **TapUI** method and you are good to go. For more information about **TapUI** and **TapCore**, please see [TapUI and TapCore](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/tapui-and-tapcore) page.

{% tabs %}
{% tab title="Objective-C" %}

<pre class="language-csharp" data-title="YourViewController.m"><code class="lang-csharp">#import &#x3C;TapTalk/TapUIRoomListViewController.h>
#import &#x3C;TapTalk/TapUI.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Initialize TapTalk.io room list view controller here
<strong>    TapUIRoomListViewController *roomListViewController = [[TapUI sharedInstance] roomListViewController]; 
</strong>    UINavigationController *roomListNavigationController = [[UINavigationController alloc] initWithRootViewController:roomListViewController];
  
    // You can choose to present or push view controller
  
    // Present room list view
    [self presentViewController:roomListViewController animated:YES completion:^{
      // Completion
    }];
  
    // Push room list view
    [self.navigationController pushViewController:roomListNavigationController animated:YES]; 
  
    // or you can add to your window root view controller
    self.window.rootViewController = roomListNavigationController;
  
}
</code></pre>

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** For more information about Room List View for TapUI, please see [Room List section](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/room-list).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/get-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
