Walletconnect - iOS

We recommend downloading the demo client app and follow the usage

1. Initial the configuration

  • Install the packages required

Use Cocoapods

pod 'WalletConnectSwift'

Or add the https://github.com/WalletConnect/WalletConnectSwift.git by SPM

  • Add scheme

Open the info.plist, add the scheme "io.iotex.iopay" to LSApplicationQueriesSchemes

  • Add WalletConnect.swift

Drag the WalletConnect.swift located in the Demo to your project, the copy option must be selected

2. Build the connection

initialize the WalletConnect instance first and conform all the delegate, then build the connection with ioPay app

var walletConnect: WalletConnect!
// initialize the WalletConnect instance
walletConnect = WalletConnect(delegate: self)
walletConnect.reconnectIfNeeded()
        
//open the ioPay and ask for the connect
let connectionUrl = walletConnect.connect()
let deepLinkUrl = "io.iotex.iopay://wc?uri=\(connectionUrl)"
if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
 }

3. Send the common action

Now the ioPay supports these actions:personal_sign, eth_signTypedData ,eth_signTransaction,eth_sendTransaction and custom contract action.You can read the relative codes in "ActionsViewController.swift"

4. Send the custom action

5. Tip

Because of the restriction of iOS background, some behaviors just like presenting viewcontroller won't work perhaps, so you need to jump the iOPay after sending actions.

Last updated