WEPIN Developer Documentation
WepinBlogContact
English
English
  • Get Started
    • Introduction
  • Wepin
    • Features
    • Architecture
      • Key Generation
      • Signing
      • Key Backup
    • Workspace
      • App Registration and Key Issuance
      • Networks and Assets Addition
      • Widget Design
    • Supported blockchains
    • Account Abstraction
  • login
    • Overview
    • Social Login Auth Providers
      • Email/Password
      • Google
      • Apple
      • Discord
      • Naver
      • Facebook
      • Line
      • Kakao
    • User Interface
    • Simplified Login
    • Resource
  • Widget Integration
    • Prerequisites
    • Web: JavaScript SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
      • Provider
        • Ethereum Provider
        • Kaia Provider
        • Solana Provider
        • Wagmi Connector
      • Wallet Adapter
        • Solana Wallet Adapter
    • Android: Java & Kotlin SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget Library
        • Installation
        • Initialization
        • Methods
    • iOS: Swift SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget Library
        • installation
        • initialization
        • Methods
    • Flutter SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
    • React Native SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
    • Unity SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • Compose Multiplatform SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
  • API
    • Overview
    • Registration
    • Login
    • Wallet
    • Token and NFT
    • Transaction
  • Deprecated
    • Web: JavaScript SDK
      • SDK
        • Installation
        • Initialization
        • Methods
        • Final Review
      • Provider
        • EVM-Compatible Networks
      • Wagmi Connector
    • Android: Java & Kotlin SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • iOS: Swift SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • Flutter SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • React Native SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
      • Providers
        • Ethereum Providers
  • MISC
    • Logo & Brand
Powered by GitBook
On this page
  • getStatus
  • Parameters
  • Return Value
  • Example
  • loginWithUI
  • Parameters
  • Return Value
  • Example
  • openWidget
  • Parameters
  • Return Value
  • Example
  • closeWidget
  • Parameters
  • Return Value
  • Example
  • register
  • Parameters
  • Return Value
  • Example
  • getAccounts
  • Parameters
  • Return Value
  • Example
  • getBalance
  • Parameters
  • Return Value
  • Example
  • getNFTs
  • Parameters
  • Return Value
  • Example
  • send
  • Parameters
  • Return Value
  • Example
  • receive
  • Parameters
  • Return Value
  • Example
  • finalize
  • Parameters
  • Return Value
  • Example
  • login
  • Available Methods

Was this helpful?

  1. Widget Integration
  2. iOS: Swift SDK
  3. Widget Library

Methods

getStatus

Returns the lifecycle status of the WepinSDK.

Parameters

  • None

Return Value

  • <WepinLifeCycle>

    • notInitialized: WepinSDK has not been initialized.음

    • initializing: WepinSDK is in the process of initializing. 중

    • initialized: WepinSDK has been successfully initialized.

    • beforeLogin: WepinSDK is initialized, but the user is not logged in.음

    • login: The user is logged in and registered with Wepin.

    • loginBeforeRegister: The user is logged in but not registered with Wepin.

Example

do {
    let statusResult = try await widget.getStatus()
    self.lifecycle = statusResult
    return lifecycle
} catch {
    self.lifecycle = .notInitialized
    return lifecycle
}

loginWithUI

Parameters

  • viewController <UIViewController> The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

  • loginProviders<[LoginProviderInfo]> An array of login providers to configure the widget. If an empty array is provided, only the email login function is available.

    • provider<String> The OAuth login provider(예: 'google', 'naver', 'discord', 'apple')

    • clientId<String> The client ID of the OAuth login provider.

  • email<String> optional The email parameter allows users to log in using the specified email address when logging in through the widget.

Return Value

  • <WepinUser>

    • status <String> Indicates success or failure <'success'|'fail'>

    • userInfo <WepinUserInfo> optional User information.

      • userId <String> Wepin user ID.

      • email <String> The email address of the user logged in to Wepin.

      • provider <WepinLoginProviders> Login provider <'google'|'apple'|'naver'|'discord'|'email'|'external_toekn'>

      • use2FA <Bool> Indicates whether 2FA is enabled on the user’s wallet.

    • userStatus <WepinUserStatus> User status.

      • loginStatus <WepinLoginStatus> Login status ('complete' | 'pinRequired' | 'registerRequired'). If the user's loginStatus is not 'complete', they need to register with Wepin.

      • pinRequired <Bool> optional Indicates if a PIN is required.

    • walletId <String> optional Wepin user’s wallet ID.

    • token <WepinToken> Wepin token information.

      • access <String> Wepin Access Token

      • refresh <String> Wepin Refresh Token

Example

let providerInfos: [LoginProviderInfo] = [
    LoginProviderInfo(provider: "google", clientId: "GOOGLE_CLIENT_ID"),
    LoginProviderInfo(provider: "apple", clientId: "APPLE_CLIENT_ID"),
    LoginProviderInfo(provider: "discord", clientId: "DISCORD_CLIENT_ID"),
    LoginProviderInfo(provider: "naver", clientId: "NAVER_CLIENT_ID"),
    LoginProviderInfo(provider: "facebook", clientId: "FACEBOOK_CLIENT_ID"),
    LoginProviderInfo(provider: "line", clientId: "LINE_CLIENT_ID")
]
let user = try await widget.loginWithUI(viewController: self, loginProviders: self.providerInfos)

openWidget

Opens the widget window. If the user is not logged in, the widget window will not open. Therefore, the user must be logged in to Wepin before calling openWidget. To log in to Wepin, use the loginWithUI or loginWepin method from the login variable.

Parameters

  • viewController <UIViewController> The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

Return Value

  • <Bool> - true if the widget is successfully opened.

Example

do {
    let result = try await widget.openWidget(viewController: self)
    updateStatus(result ? "Widget Opened" : "Open Widget Failed")
} catch {
    updateStatus("Error: \(error.localizedDescription)")
}

closeWidget

Closes the widget window. Closing the window does not log out the user.

Parameters

  • None

Return Value

  • None

Example

try wepinWidget?.closeWidget()

register

Registers the user with Wepin. After signing up and logging in, the Wepin widget’s registration page opens, allowing the user to register (create a wallet and account) with Wepin services. This function can only be used when WepinLifeCycle is loginBeforeRegister. After calling the loginWepin() method from the login variable, if the loginStatus value in userStatus is not 'complete', this method should be called.

Parameters

  • viewController <UIViewController>

    The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

Return Value

  • <WepinUser>

    • status <String> Indicates success or failure <'success'|'fail'>

    • userInfo <WepinUserInfo> optional User information.

      • userId <String> Wepin user ID.

      • email <String> The email address of the user logged in to Wepin.

      • provider <WepinLoginProviders> Login provider <'google'|'apple'|'naver'|'discord'|'email'|'external_toekn'>

      • use2FA <Bool> Indicates whether 2FA is enabled on the user’s wallet.

    • userStatus <WepinUserStatus> User status.

      • loginStatus <WepinLoginStatus> Login status ('complete' | 'pinRequired' | 'registerRequired'). If the user's loginStatus is not 'complete', they need to register with Wepin.

      • pinRequired <Bool> optional Indicates if a PIN is required.

    • walletId <String> optional Wepin user’s wallet ID.

    • token <WepinToken> Wepin token information.

      • access <String> Wepin Access Token

      • refresh <String> Wepin Refresh Token

Example

do {
    let result = try await widget.register(viewController: self)
    self.updateStatus("Registered: \(result)")
} catch {
    self.updateStatus("Error: \(error.localizedDescription)")
}

getAccounts

Returns the user's account information (networks and addresses) available in the app. This function can only be used after logging in to Wepin. If no parameters are provided, it returns information for all the user's accounts.

Parameters

  • networks <[String]> optional The networks for which you want to return account information. The supported blockchain networks can be found on the supported blockchain page.

  • withEoa <Bool> optional If AA accounts are present, this determines whether to include EOA accounts in the return.

Return Value

  • <[WepinAccount]>

    • address <String> User account address.

    • network <String> The network type of the user's account.

    • contract <String> optional The contract address of the token.

    • isAA <Bool> optional Indicates if it is an AA account.

Example

do {
    let accounts = try await widget.getAccounts()
    self.updateStatus("Accounts: \(accounts)")
} catch {
    self.updateStatus("Error: \(error.localizedDescription)")
}

getBalance

Returns the balance information (amount) of accounts. This function can only be used after logging in to Wepin. If no accounts parameter is provided, it returns the balance of all user accounts.

Parameters

  • accounts <[WepinAccount]> optional

    • address <String> User account address.

    • network <String> The network type of the user's account.

    • contract <String> optional The contract address of the token.

    • isAA <Bool> optional Indicates if it is an AA account.

Return Value

  • <[WepinAccountBalanceInfo]>

    • network <String> The network type of the user's account.

    • address <String> The address of the user's account.

    • symbol <String> Network symbol.

    • balance <String> The amount of the network coin held.

    • token <[WepinTokenBalanceInfo]>

      • symbol <String> Token symbol.

      • balance <String> The amount of the token held.

      • contract <String> Token contract address.

Example

do {
    let balance = try await widget.getBalance()
    self.updateStatus("Balance: \(balance)")
} catch {
    self.updateStatus("Error: \(error.localizedDescription)")
}

getNFTs

Returns the user's NFTs. This function can only be used after logging in to Wepin. If no networks parameter is provided, it returns all of the user's NFT information.

Parameters

  • refresh <Bool> Required parameter to indicate whether to refresh the NFT data.

  • networks <[String]> optional A list of network names to filter the NFTs.

Return Value

  • <[WepinNFT]>

    • account <WepinAccount>

      • address <String> User account address.

      • network <String> The network type of the user's account.

      • contract <String> optional The contract address of the token.

      • isAA <Bool> optional Indicates if it is an AA account.

    • contract <WepinNFTContract>

      • name <String> NFT contract name.

      • address <String> NFT contract address.

      • scheme <String> Scheme of the NFT.

      • description <String> optional Description of the NFT contract.

      • network <String> Network associated with the NFT contract.

      • externalLink <String> optional External link associated with the NFT contract.

      • imageUrl <String> optional Image URL associated with the NFT contract.

    • name <String> Name of the NFT.

    • description <String> Description of the NFT.

    • externalLink <String> External link associated with the NFT.

    • imageUrl <String> Image URL associated with the NFT.

    • contentUrl <String> optional URL pointing to the content associated with the NFT.

    • quantity <Int> optional Quantity of the NFT.

    • contentType <String> Content type of the NFT ('image' | 'video').

    • state <Int> State of the NFT.

Example

do {
    let nfts = try await widget.getNFTs(refresh: false)
    self.updateStatus("NFTs: \(nfts)")
} catch {
    self.updateStatus("Error: \(error.localizedDescription)")
}

send

Performs the send function using the widget and returns the ID information of the send transaction. This function can only be used after logging in to Wepin.

Parameters

  • viewController <UIViewController>

    The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

  • account <WepinAccount>

    • address <String> User account address.

    • network <String> The network type of the user's account.

    • contract <String> optional The contract address of the token.

    • isAA <Bool> optional Indicates if it is an AA account.

  • txData <WepinTxData> optional

    • toAddress <String> The address to send to.

    • amount <String> The amount to send.

Return Value

  • <WepinSendResponse>

    • txId <String> The transaction ID of the send transaction.

Example

do {
     let result = try await widget.send(viewController: self, account: account)
    updateStatus("Send success: \(result)")
} catch {
    updateStatus("Error: \(error.localizedDescription)")
}

receive

The receive() method opens the account information page associated with the specified account. This method can only be used after logging into Wepin.

Parameters

  • viewController <UIViewController>

    The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

  • account <WepinAccount>

    • address <String> User account address.

    • network <String> The network type of the user's account.

    • contract <String> optional The contract address of the token.

    • isAA <Bool> optional Indicates if it is an AA account.

Return Value

  • <WepinReceiveResponse>

    • account <WepinAccount>

      • address <String> User account address.

      • network <String> The network type of the user's account.

      • contract <String> optional The contract address of the token.

      • isAA <Bool> optional Indicates if it is an AA account.

Example

do {
    let result = try await widget.receive(viewController: self, account: account)
    updateStatus("Receive success: \(result)")
} catch {
    updateStatus("Error: \(error.localizedDescription)")
}

finalize

wepinWidget.finalize()

Terminates the use of WepinSDK. The WepinLifeCycle changes to notInitialized.

Parameters

  • None

Return Value

  • None

Example

try await wepin.finalize()

login

If you choose not to use the integrated WepinLogin within WepinWidget and instead use a separate WepinLogin SDK, make sure both SDKs are using the same version. Using different versions of the two SDKs may result in errors.

Available Methods

These methods support various login scenarios, allowing you to select the appropriate method based on your needs.

Exception

Example

// Login with OAuth provider
do {
    let oauthParams = WepinLoginOauth2Params(provider: "discord", clientId: self.discordClientId)
    let res = try await wepin!.login.loginWithOauthProvider(params: oauthParams, viewController: self)
    let privateKey = "private key for wepin id/access Token"
        //call loginWithIdToken() or loginWithAccessToken()
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}

//Sign up with email and password
do {
    let email = "EMAIL-ADDRESS"
    let password = "PASSWORD"
    let params = WepinLoginWithEmailParams(email: email, password: password)
    wepinLoginRes = try await wepin!.login.signUpWithEmailAndPassword(params: params)
    self.tvResult.text = String("Successed: \(wepinLoginRes)")
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}

//Login with IDToken
do {
    let token = "ID-TOKEN"
    let params = WepinLoginOauthIdTokenRequest(idToken: token)
    wepinLoginRes = try await wepin!.login.loginWithIdToken(params: params)
        
    self.tvResult.text = String("Successed: \(wepinLoginRes)")
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}

//Login to Wepin
do {
    let res = try await wepin!.login.loginWepin(params: wepinLoginRes)
    wepinLoginRes = nil
    self.tvResult.text = String("Successed: \(res)")
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}

//get User Information 
do {
    let res = try await wepin!.login.getCurrentWepinUser()
    self.tvResult.text = String("Successed: \(res)")
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}

//logout
do {
    let res = try await wepin!.login.logoutWepin()
    self.tvResult.text = String("Successed: \(res)")
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}
PreviousinitializationNextFlutter SDK

Last updated 25 days ago

Was this helpful?

The login variable is a Wepin login library that includes various authentication methods, allowing users to log in using different approaches. It supports email and password login, OAuth provider login, login using ID tokens or access tokens, and more. For detailed information on each method, refer to the official .

The login variable is a Wepin login library that includes various authentication methods, allowing users to log in using different approaches. It supports email and password login, OAuth provider login, login using ID tokens or access tokens, and more. For detailed information on each method, refer to the official .

Login Library guide
Supported blockchains
Login Library guide
loginWithOauthProvider
signUpWithEmailAndPassword
loginWithEmailAndPassword
loginWithIdToken
loginWithAccessToken
getRefreshFirebaseToken
loginWepin
getCurrentWepinUser
logout
WepinError