> 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/login-library/init.md).

# Initialization

This is how to initialize the Wepin iOS Login Library.

Before creating a WepinLogin instance, please pass App ID, and App Key to the WepinLoginParams object as follows.

```swift
let initParam = WepinLoginParams(appId: appId, appKey: appKey)
```

Please create the WepinLogin instance by passing the previously created WepinLoginParams.

```swift
WepinLogin wepin = new WepinLogin(initParam);
```

After creating the WepinLogin instance, call the `initialize` method to proceed with the initialization.

```swift
await wepin!.initialize()
```

### Example

```swift
let appKey: String = "Wepin-App-Key"
let appId: String = "Wepin-App-ID"
var wepin: WepinLogin? = nil
let initParam = WepinLoginParams(appId: appId, appKey: appKey)
wepin = WepinLogin(initParam)
// Call initialize function
do{
    let res = try await wepin!.initialize()
    self.tvResult.text = String("Successed: " + String(res!))
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}
```

## isInitialized

You can use the `isInitialized`method to check whether the WepinLogin instance has been initialized correctly. The return values are as follows:

* \<Bool>\
  it returns **true** if the initialization is successful and **false** if the initialization fails.

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


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.wepin.io/en/widget-integration/ios-swift-sdk/login-library/init.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
