> 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/deprecated/ios-swift-sdk/method.md).

# 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 %}
