iOS Quickstart
Quickstart: Implementing Particle Connect within iOS Applications
Getting started with Particle Connect on iOS only takes a few minutes.
Below is a quick, step-by-step rundown on installing, configuring, and utilizing Particle Connect on iOS.
For complete documentation covering the implementation of Particle Connect on iOS in more depth, head over to the iOS SDK reference.
To begin, you’ll need to ensure that your project meets the following requirements (if it doesn’t, you may encounter compatibility issues).
Prerequisites
- Xcode 15.0 or higher.
- CocoaPods 1.14.3 or higher.
- iOS 14 or higher.
Installing Particle Connect
Once you’ve ensured that your project meets the aforementioned prerequisites, you’ll need to install Particle Connect and various associated SDKs, including:
ParticleConnectKit
ParticleConnect
ConnectCommon
ParticleAuthCore
ParticleMPCCore
Thresh
AuthCoreAdapter
- For EVM,
ConnectWalletConnectAdapter
- For Solana,
ConnectPhantomAdapter
- Optionally,
ParticleWalletAPI
- Optionally,
ParticleWalletGUI
- Optionally,
ParticleWalletConnect
The following snippet should be included within your Podfile (with or without the optional libraries).
Configuring Particle Connect
Once installed, you’re ready to configure the SDK.
To configure, and eventually initialize Particle Connect, you’ll need three key values from the Particle dashboard: your project ID, client key, and app ID. These authenticate your instance of Particle Connect and connect your project to the dashboard.
To retrieve these values, follow the steps below:
For more information on the Particle dashboard, take a look at the dashboard quickstart.
With your project ID, client key, and app ID retrieved, you’ll add a file named ParticleNetwork-Info.plist
to your project, then insert these values as is shown below.
Configuring Xcode
Finally, before initializing and using the SDK, you’ll need to configure your Info.plist
file; this file should contain an array of strings representing the wallets you intend to support, alongside a number of permissions, as is shown below.
Additionally, you’ll need to add your scheme URL to your Xcode project.
For example, if your appId
is 63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, then the scheme URL would be pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, simply adding pn
to the beginning of the appId
.
Initialize SDK
Before using Particle Connect, you’ll need to initialize the SDK through the initialize
method on ParticleConnect
, which takes the following parameters:
env
, representing the mode in which you’d like your environment to be in, such as.debug
,.staging
, or.production
. This primarily affects the amount of information logged during usage.chainInfo
, specifying the primary chain you intend to use within your application.dAppData
, the metadata used for WalletConnect.adapters
, an array of adapters representing the wallets you’d like to support within your application.
Additionally, you can set specific chains to be used within WalletConnect (chainInfo
structures) with setWalletConnectV2SupportChainInfos
. An example of this can be found below.
Facilitating connection
Now that Particle Connect has been installed, configured, and initialized, you’re ready to facilitate connection through the Particle Connect modal.
To do this, you’ll need to establish a config
specifying the:
- Onboarding mechanisms you’d like to support, through
connectOptions
(such as.email
,.phone
). - Social login providers you’d like to support, through
socialProviders
(such as.google
,.apple
). - Wallets you’d like to be included as options within the modal, through
walletProviders
(specified through an instance ofEnableWalletProvider
, as shown below). - (Optionally), layout options altering the format of the connection modal through
additionalLayoutOptions
. - (Optionally), additional customizations, such as a custom icon, through
designOptions
.
Upon generating this config (with ConnectKitConfig
), you’ll be able to call ParticleConnectUI.connect
, initiating the resulting connection modal.
Examples of Utilization
Retrieving User Information
Upon wallet connection (or social login), you’ll be able to retrieve information about the resulting account.
Basic account information can be found through the result of ParticleConnectUI.connect
, in this case, that was saved to account
, which contains properties such as publicAddress
and walletType
.
To explicitly retrieve userInfo
(a collection of information regarding the login mechanism, attached addresses, and so on; more information can be found within its API reference), you’ll need to call auth.getUserInfo
.
An example of both approaches can be found below.
Send a Transaction
Sending a transaction using the resulting account follows a similar process to other mobile SDKs. A basic transaction will need to be constructed using ParticleWalletAPI.evm().createTransaction
, this takes basic parameters such as from
, to
, value
, and (optionally) data
and returns a machine-readable transaction object.
To execute the resulting transaction, you’ll need to initialize an instance of the active connected wallet; an example of doing this has been included in the snippet below.
Finally, using this instance, the transaction can be executed through {adapter}.signAndSendTransaction
, taking the sender’s address alongside the previously constructed transaction object.
Open Wallet
If you included ParticleWalletGUI
within your Podfile, you can open the (optional) embedded wallet interface at any time after a user connects, use ParticleWalletGUI.setSupportChain
to set supported chains, then PNRouter
to open the interface.
ParticleAA
SDK and refer to this documentation. Additionally, a demo repository can be found here. Was this page helpful?