Swift Client (iOS)

Quick Start For Wallets Using Swift Client (iOS)

Swift implementation of WalletConnect v.2 protocol for native iOS applications.

Note: The Swift client is in Alpha and should only be used for testing.

Requirements

  • iOS 13

  • XCode 13

  • Swift 5

Usage

Instantiate Client

let url = URL(string: "wss://relay.walletconnect.com")!
let options = WalletClientOptions(apiKey: String, name: String, isController: true, metadata: AppMetadata(name: String?, description: String?, url: String?, icons: [String]?), relayURL: url)
let client = WalletConnectClient(options: options)

Pair Clients

Pair client with a uri generated by the dapp.

let uri = "wc:..."
try! client.pair(uri: uri)

Approve Session

Sessions are always proposed by the Proposer client so Responder client needs either reject or approve a session proposal.

class ClientDelegate: WalletConnectClientDelegate {
...
    func didReceive(sessionProposal: SessionType.Proposal) {
        client.approve(proposal: proposal)
    }
...

or

    func didReceive(sessionProposal: SessionType.Proposal) {
        client.reject(proposal: proposal, reason: Reason)
    }

Handle Delegate methods

    func didSettle(session: SessionType.Settled) {
        // handle settled session
    }
    func didReceive(sessionProposal: SessionType.Proposal) {
        // handle session proposal
    }
    func didReceive(sessionRequest: SessionRequest) {
        // handle session request
    }

JSON-RPC Payloads

TODO

API Keys

For api keys look at API Keys.

Last updated