# 원격 구성 적용

{% hint style="info" %}
iOS SDK 2.11.0 이상 버전에서 지원하는 기능입니다.
{% endhint %}

원격 구성은 애플리케이션에서 관리되고 있는 값, 또는 속성들을 핵클 대시보드에서 정의한 파라미터 값들로 대체하여 실시간으로 애플리케이션의 동작 및 설정 값들을 제어할 수 있는 기능입니다.

핵클의 대시보드의 원격 구성 화면으로 이동하여 파라미터 정보들을 설정하고, 사용자 식별 규칙에 따른 값들을 설정할 수 있습니다.

## remoteConfig

`remoteConfig()` 메소드를 호출하면 사용자에 대한 원격 구성 정보(설정한 파라미터 및 규칙 정보)를 담고 있는 `HackleRemoteConfig` 인스턴스를 얻을 수 있습니다.

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

```swift
// 원격 구성 정보 담은 인스턴스를 반환합니다.
let remoteConfig = hackleApp.remoteConfig()
```

{% endtab %}

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

```objectivec
// 원격 구성 정보 담은 인스턴스를 반환합니다.
HackleRemoteConfig *remoteConfig = [hackleApp remoteConfig];
```

{% endtab %}
{% endtabs %}

## 원격 구성 파라미터 조회

* `remoteConfig()` 메소드를 통해 전달받은 `HackleRemoteConfig` 인스턴스에는 원격 구성에서 설정한 전체 파라미터 설정 정보가 존재합니다.
* 핵클의 원격 구성 화면에서 설정한 파라미터 값이 key, value 형태로 존재하기 때문에, 설정한 파라미터 유형에 따라 아래 메소드를 사용하여 설정한 파라미터 값을 받아 활용할 수 있습니다.
* 원격 구성 파라미터 설정화면에서 규칙 및 값을 유동적으로 변경할 수 있습니다.

{% hint style="warning" %}
보관 후 원격 구성과 관련된 코드를 제거하세요.

원격 구성 파라미터를 보관한 경우 더이상 파라미터 정보에 접근 할 수 없습니다. 원격 구성 파라미터 보관 후에는 반드시 관련된 코드를 정리해주시기 바랍니다.
{% endhint %}

### getString

* STRING, JSON 유형으로 설정된 파라미터 값을 반환합니다.
* 상태 결정에 따라 기본 값 혹은 규칙에 설정된 값을 반환합니다.

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

```swift
let remoteConfig: HackleRemoteConfig = hackleClient.remoteConfig()

let strValue: String = remoteConfig.getString(forKey: "parameter_key_string_type", defaultValue: "defaultValue")
let jsonValue: String = remoteConfig.getString(forKey: "parameter_key_json_type", defaultValue: "defaultValue")
```

{% endtab %}

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

```objectivec
HackleRemoteConfig *remoteConfig = [[Hackle app] remoteConfig];

NSString *stringValue = [remoteConfig getStringForKey:@"string" defaultValue:@"defaultValue"];

NSString *jsonValue = [remoteConfig getStringForKey:@"parameter_key_json_type" defaultValue:@"defaultValue"];
```

{% endtab %}
{% endtabs %}

### getInt

* Number 유형으로 설정된 parameter 값을 Int 타입으로 반환합니다.
* 상태 결정에 따라 기본 값 혹은 규칙에 설정된 값을 반환합니다.

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

```swift
let remoteConfig: HackleRemoteConfig = hackleClient.remoteConfig()

let intValue: Int = remoteConfig.getInt(forKey: "parameter_key_number_type", defaultValue: 0)
```

{% endtab %}

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

```objectivec
HackleRemoteConfig *remoteConfig = [[Hackle app] remoteConfig];

int intValue = [remoteConfig getIntForKey:@"parameter_key_number_type" defaultValue:@0];
```

{% endtab %}
{% endtabs %}

### getDouble

* Number 유형으로 설정된 parameter 값을 Double 타입으로 반환합니다.
* 상태 결정에 따라 기본 값 혹은 규칙에 설정된 값을 반환합니다.

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

```swift
let remoteConfig: HackleRemoteConfig = hackleClient.remoteConfig()

let doubleValue: Double = remoteConfig.getDouble(forKey: "parameter_key_number_type", defaultValue: 0.0)
```

{% endtab %}

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

```objectivec
HackleRemoteConfig *remoteConfig = [[Hackle app] remoteConfig];

double doubleValue = [remoteConfig getDoubleForKey:@"parameter_key_number_type" defaultValue:0.0];
```

{% endtab %}
{% endtabs %}

### getBool

* Boolean 유형으로 설정된 parameter값을 반환합니다.
* 상태 결정에 따라 기본 값 혹은 규칙에 설정된 값을 반환합니다.

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

```swift
let remoteConfig: HackleRemoteConfig = hackleClient.remoteConfig()

let boolValue: Bool = remoteConfig.getBool(forKey: "parameter_key_boolean_type", defaultValue: false)
```

{% endtab %}

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

```objectivec
HackleRemoteConfig *remoteConfig = [[Hackle app] remoteConfig];

bool boolValue = [remoteConfig getBoolForKey:@"parameter_key_boolean_type" defaultValue:false];
```

{% endtab %}
{% endtabs %}


---

# 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.hackle.io/development-guide/ios/ios-remote-config.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.
