> For the complete documentation index, see [llms.txt](https://docs.wepin.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wepin.io/en/widget-integration/ios-swift-sdk/widget-library/initialization.md).

# initialization

The method for initializing the Wepin iOS Widget Library is as follows.

Before creating an instance of `WepinWidget`, please pass the App ID and App Key to the `WepinWidgetParams` object as shown below.

```swift
let initWidgetParam = WepinWidgetParams(viewController: UIViewController, appId: appId, appKey: appKey)
```

Please create a `WepinWidget` instance by passing the previously created `WepinPinParams`.

```swift
var wepinWidget = WepinWidget(initWidgetParam);
```

After creating the `WepinWidget` instance, call the `initialize` method to complete the initialization.

```swift
await wepinWidget?.initialize(attributes: attributes)
```

#### parameters

&#x20;`attributes` \<WepinWidgetAttributes>

* `defaultLanguage` \<String>\
  The default language setting for the widget screen is `'en'`. Currently supported languages are `'ko'`, `'en'`, and `'ja'`.
* `defaultCurrency` \<String>\
  The default language setting for the widget screen is `'USD'`. Currently supported languages are `'KRW'`, `'USD'`, and `'JPY'`.

#### Return value

`<Bool>`\
Returns **true** if successful, and **false** if it fails.

### Example

```swift
let appKey: String = "Wepin-App-Key"
let appId: String = "Wepin-App-ID"
var wepinWidget: WepinWidget? = nil
let initWidgetParam = WepinWidgetParams(appId: appId, appKey: appKey)
wepinWidget = WepinWidget(initWidgetParam)
// Call initialize function
let attributes = WepinWidgetAttributes(defaultLanguage: "en", defaultCurrency: "USD")
if let res = try await wepinWidget?.initialize(attributes: attributes) {
    self.tvResult.text = "Successed: \(res)"
} else {
    self.tvResult.text = "Failed: No result returned from initialization"
}
```

## isInitialized

You can use the `isInitialized` method to check if the `WepinWidget` instance has been successfully initialized.

* \<Bool>\
  Returns **true** if initialization was successful and **false** if it failed.

```swift
let result = wepinWidget!.isInitialized()
```

## changeLanguage

```swift
wepinWidget!.changeLanguage("ko", currency: "KRW")
```

Changes the language displayed on the widget screen. Currently, only `'ko'`, `'en'`, and `'ja'` are supported.<br>

**Parameters**

* &#x20;`_ language` \<String>
* `currency` \<String> *optional*

### **Return value**

* \<Void>

### Example

```swift
wepinWidget!.changeLanguage("ko", currency: "KRW")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.wepin.io/en/widget-integration/ios-swift-sdk/widget-library/initialization.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.
