Make sure you have added the following packages as your dependencies:
You should have also decided which blockchains will be supported in your application and what transport layers to use to establish the communication. Make sure you have added the appropriate Blockchain and Transport packages as your dependencies as well.
See the Installation page for more information about the packages and how to install them.
Follow the steps below to learn how to interact with a dApp. The guide assumes all blockchains and transport layers are supported.
Beacon.WalletClient instance by providing your app's name, registering supported blockchains and transport layers that will be used for communication.
The example below creates a new
Beacon.WalletClient instance with default settings. See the Configuration guide to learn about more advanced setups.
Currently only one instance of
Beacon.WalletClient should be created per application.
Subscribe to requests from the dApp by connecting to the Beacon network and listening to incoming requests.
To connect to a new dApp take the pairing request (obtained from, for example, a paring QR code) and transform it to
Beacon.P2PPeer. Next, register the new instance of
Beacon.P2PPeer in your wallet client.
Having received a request, you can create a response and send it back to the dApp. The response should always be created from an incoming request. Attempting to send a response that was not created from a request awaiting answer will result in an error.
The first request your app receives from a dApp is a permission request. The example below shows how to respond to it in the most basic way. To get more information about other kinds of requests or learn more advanced use cases see the Blockchain guides.
Or in Xcode open the
Add Package Dependency window (as described in the official guide) and enter the
Beacon iOS SDK GitHub repository URL