# Methods

The following shows the methods provided by the Wepin widget iOS SDK.

## `openWidget`

The <mark style="color:blue;">`openWidget`</mark> method shows the widget window. The screen displayed in the widget window varies depending on the user's login status. If a user is not logged in, the login screen is displayed.

### Example

```swift
let wepin = Wepin.instance()
wepin.openWidget(){ (result, error) -> Void in
    if let _ = error {
        // Do error handling
        return 
    }
}
```

## `closeWidget`

The <mark style="color:blue;">`closeWidget`</mark> method closes the widget window. Closing the window does not log users out.

### Example

```swift
let wepin = Wepin.instance()
wepin.closeWidget(){ (result, error) -> Void in
    if let _ = error {
        // Do error handling
        return 
    }
}
```

## `getAccounts`

The <mark style="color:blue;">`getAccounts`</mark> method returns user accounts of the networks available in the app. The returned value is an array of <mark style="color:blue;">`Account`</mark> object. <mark style="color:blue;">`getAccounts`</mark> is a method available after widget login.

<pre class="language-swift"><code class="lang-swift"><strong>let wepin = Wepin.instance()
</strong><strong>wepin.getAccounts() { (accounts, error) -> Void in
</strong><strong>    if let _ = error {
</strong><strong>        // Do error handling
</strong><strong>        return
</strong><strong>    }
</strong><strong>    // Do something with accounts 
</strong><strong>}
</strong></code></pre>

### `Account`

The interface of the class returned by the <mark style="color:blue;">`getAccounts`</mark> function is as follows.

```swift
public struct Account {
    var address: String;  // The account address
    var network: String;  // The blockchain network of the account
}
```

* **`address`:** *string*\
  The account address
* **`network`**: *string*\
  The blockchain network of the account. The name of each network can be found below.

{% content-ref url="/pages/c58QTBKZd8FibB8m3Pc4" %}
[Supported blockchains](/en/wepin/supported-blockchains.md)
{% endcontent-ref %}


---

# 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.wepin.io/en/deprecated/ios-swift-sdk/method.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.
