> For the complete documentation index, see [llms.txt](https://docs.taptalk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/general.md).

# General

### Get TapTalk Implementation Type

You can get your current TapTalk.io implementation type by using this method.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
// Get currently used implementation Type
TapTalkImplentationType implementationType = [[TapTalk sharedInstance] getTapTalkImplementationType];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

// Get currently used implementation Type
let implementationType = TapTalk.sharedInstance().getImplementationType()
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:**&#x20;

TapTalkImplementationType consists of 3 types which are **:**\
`TapTalkImplementationTypeUI`: used for implementation with only TapUI`TapTalkImplementationTypeCore`: used for implementation with only TapCore`TapTalkImplementationTypeCombine`: used for implementation with both of TapCore and TapUI combined
{% endhint %}

### Check TapTalk Initialized

You can check whether TapTalk instance has completed initialization by calling the method below.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
BOOL isInitialized = [[TapTalk sharedInstance] checkTapTalkInitialized];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

let isInitialized = TapTalk.sharedInstance().checkInitialized()
```

{% endtab %}
{% endtabs %}

### Update Application Badge Count

You can get your current TapTalk.io implementation type by using this method.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
[[TapTalk sharedInstance] updateApplicationBadgeCount];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TapTalk.sharedInstance().updateUnreadBadgeCount()
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**T**o listen to changes of application badge, please see the explanation in [event delegate page](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md) using`tapTalkUnreadChatRoomBadgeCountUpdated`method
{% endhint %}

### Remote Configs

A TapTalk.io project owns a remote configuration, which consists of 3 configuration types: **Core Configs**, **Project Configs**, and **Custom Configs**. A configuration value can be obtained with the respective configuration type's getter method, and will return a Map object. To get a specific value, call the **get** method from the returned dictionary with the respective key. The value obtained will always be in a **String** format and should be converted each according to their uses. Each configuration type will be explained below.

### Core Configs

| **Config Key**         | **Value**                                                                    |
| ---------------------- | ---------------------------------------------------------------------------- |
| chatMediaMaxFileSize   | Number of maximum allowed chat media file size in bytes                      |
| roomPhotoMaxFileSize   | Number of maximum allowed group chat room profile picture file size in bytes |
| userPhotoMaxFileSize   | Number of maximum allowed user profile picture file size in bytes            |
| groupMaxParticipants   | Number of maximum allowed participants in a group chat room                  |
| channelMaxParticipants | Number of maximum allowed participants in a channel                          |

Below is an example to get the value of chatMediaMaxFileSize:

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
NSDictionary *coreConfigsDictionary = [[TapTalk sharedInstance] getCoreConfigs];
NSString *maxFileSizeString = [coreConfigsDictionary objectForKey:@"maxFileSize"];
NSInteger maxFileSizeValue = [maxFileSizeString integerValue];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

let coreConfigsDictionary = TapTalk.sharedInstance().getCoreConfigs()
let maxFileSizeString = coreConfigsDictionary["maxFileSize"] as? String ?? ""
let maxFileSizeValue = Int(maxFileSizeString) ?? 0
```

{% endtab %}
{% endtabs %}

### Project Configs

| **Config Key**     | **Value**                                                                                                                                       |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| usernameIgnoreCase | <p><strong>"0"</strong> if username in the project is case sensitive<br><strong>"1"</strong> if username in the project is case insensitive</p> |

An example to obtain usernameIgnoreCase value:

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
NSDictionary *projectConfigsDictionary = [[TapTalk sharedInstance] getProjectConfigs];
NSString *usernameIgnoreCaseString = [projectConfigsDictionary objectForKey:@"usernameIgnoreCase"];
BOOL usernameIgnoreCase = [usernameIgnoreCaseString boolValue];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

let projectConfigsDictionary = TapTalk.sharedInstance().getProjectConfigs()
let usernameIgnoreCaseString = projectConfigsDictionary["usernameIgnoreCase"] as? String ?? ""
let usernameIgnoreCase = Bool(maxFileSizeString) ?? false
```

{% endtab %}
{% endtabs %}

### Custom Configs

Custom config values are specified by the user, and can be customized through the TapTalk.io Dashboard. To get the project's custom configs, call the **getCustomConfigs** method.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
NSDictionary *customConfigsDictionary = [[TapTalk sharedInstance] getCustomConfigs];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

let customConfigsDictionary = TapTalk.sharedInstance().getCustomConfigs()
```

{% endtab %}
{% endtabs %}

### Refresh Remote Configs

To refresh remote configs with the latest updated values, call the **refreshRemoteConfigs** method in TapTalk.io class.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>

[[TapTalk sharedInstance] refreshRemoteConfigsWithSuccess:^{
    // Successfully fetched latest configs
}
failure:^(NSError *error) {
    // Failed to fetch configs    
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TapTalk.sharedInstance().refreshRemoteConfigs {
    // Successfully fetched latest configs
}
failure: { error in
    // Failed to fetch configs
}
```

{% endtab %}
{% endtabs %}

### Enable / Disable Auto Contact Sync

If you are using UI implementation method in your application, TapTalk.io provides a feature to automatically sync your user's phone contacts with their TapTalk.io contacts. You can choose to enable or disable auto contact sync by calling these methods. If auto contact sync is enabled, TapTalk.io will automatically sync your user's phone contacts and add them to TapTalk.io contacts if their phone number is registered to TapTalk.io when the application is opened. Please note that the **default value** is **enabled**.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
// Enable or disabled auto contact sync
// Value is enabled by default if you do not set this method
[[TapTalk sharedInstance] setAutoContactSyncEnabled:IS_ENABLED];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

// Enable or disabled auto contact sync
// Value is enabled by default if you do not set this method
TapTalk.sharedInstance().setAutoContactSyncEnabled(IS_ENABLED)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameter**\
`IS_ENABLED`: (BOOL) set to TRUE/YES to enable auto contact sync
{% endhint %}

### Get Auto Contact Sync Status

Use this method to obtain auto contact sync status. This method will return true if auto contact sync is enabled.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>
  
BOOL isAutoContactSyncEnabled = [[TapTalk sharedInstance] isAutoContactSyncEnabled];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

let isAutoContactSyncEnabled = TapTalk.sharedInstance().isAutoContactSyncEnabled()
```

{% endtab %}
{% endtabs %}

### Obtain Current Navigation Controller in TapUI

To refresh remote configs with the latest updated values, call the **refreshRemoteConfigs** method in TapTalk.If you are using TapUI and want to integrate with your app, you can get the current active view controller or navigation controller by using the following codes.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapUI.h>

// Get TapTalk.io current active view controller
UIViewController *activeViewController = [[TapUI sharedInstance] getCurrentTapTalkActiveViewController];

// Get TapTalk.io current active navigation controller
UINavigationController *activeNavigationController = [[TapUI sharedInstance] getCurrentTapTalkActiveNavigationController];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

// Get TapTalk.io current active view controller
let activeViewController = TapUI.sharedInstance().getCurrentTapTalkActiveViewController()

// Get TapTalk.io current active navigation controller
let activeNavigationController = TapUI.sharedInstance().getCurrentTapTalkActiveNavigationController()
```

{% endtab %}
{% endtabs %}

### Set Image Compression Quality

You can customize the compression quality of images used for upload and download. The range of the compression quality is set between 0.1f and 1.0f. The higher the quality, the better the images will look, but they will also take more storage space as their size increases.

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

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapTalk.h>

[[TapTalk sharedInstance] setImageCompressionQuality:IMAGE_COMPRESSION_QUALITY];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TapTalk.sharedInstance().setImageCompressionQuality(IMAGE_COMPRESSION_QUALITY)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`IMAGE_COMPRESSION_QUALITY`**: (CGFloat) image compression quality between 0.1f to 1.0f
{% endhint %}

### Smart Local Cache Management

In order to optimize storage usage and performance, TapTalk.io cleans any local data of messages that are older than 1 month. This cleanup runs on a scheduled interval. Deleted messages can later be retrieved from the server when required.

### Encrypted Chat

TapTalk.io SDK encrypts all message contents before sending them to the server to protect any sensitive content contained in the messages. All messages received and stored in the server will stay encrypted. Messages will be decrypted once fetched in end user's local device in order to show their contents. TapTalk.io uses **AES Crypt** combined with secure local password to encrypt and decrypt message contents.
