iOS Quickstart
Quickstart: Implementing Particle Auth within iOS Applications
Particle Auth, the core SDK responsible for driving social logins, has various iOS SDKs; implementation only takes a few steps.
This document will go through the step-by-step process of configuring, initializing, and using Particle Auth on iOS.
For complete documentation covering the implementation of Particle Auth on iOS in more depth, head over to the iOS SDK reference.
Before jumping into it, ensure your project meets the following minimum requirements (otherwise, you may encounter compatibility issues).
Prerequisites
- Xcode 15.0 or higher.
- CocoaPods 1.14.3 or higher.
- iOS 14 or higher.
Installing Particle Auth
To begin, you’ll need to install Particle Auth through your Podfile; specifically, you’ll need (at a minimum) the following libraries:
ParticleAuthCore
ParticleMPCCore
Thresh
- Optionally,
ParticleWalletAPI
for transaction construction. - Optionally,
ParticleWallerGUI
to enable an embedded wallet interface.
Below is a snippet representing the installation of the aforementioned libraries.
Configuring Particle Auth
Once installed, you’re ready to configure Particle Auth and initialize the SDK.
To do this, you’ll need three key values from the Particle dashboard: your project ID, client key, and app ID. These are used to authenticate your instance of Particle Auth and connect your project to the dashboard; these are required to properly initialize the SDK.
To retrieve these keys, follow the steps outlined 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 need to add a file named ParticleNetwork-Info.plist
to your project, then insert the aforementioned keys as is exemplified below.
Initialize Particle Auth
At this point, you’ve installed and configured Particle Auth; the only step remaining before the SDK can be used is initialization.
Particle Auth can be initialized by simply calling the initialize
method on ParticleNetwork
. This takes the following parameters:
config
, which takes:chainInfo
, representing the primary chain you intend to use (for example,.ethereum
,.polygon
).devEnv
, affecting the information logged within your environment (.debug
,.production
, or.staging
).
The snippet below is an example of this.
Facilitating social login
You’re ready to facilitate social login and interacting with the resulting accounts.
As shown below, you’ll need to call auth.connect
to initiate social login, passing in the specific login type you’d like the user to use (.google
, .twitter
, .discord
, etc.) alongside, if applicable, the type of account prompt used by the OAuth provider (.selectAccount
, .consent
, .none
).
auth.switchChain
to switch chains, and after waiting for 2 seconds, a new address for the selected chain will be generated for you.Examples of Utilization
Retrieve User Information
With a user logged in, you’ll be able to retrieve information about their account (such as their address, or specific details regarding the social login mechanism they used) through methods such as auth.evm.getAddress
and auth.getUserInfo
(getUserInfo
returns an object with numerous points of information; to learn more, head over to its API reference).
The following snippet is an example of retrieving a user’s address on both EVM and Solana alongside pulling their broader account information.
Send a Transaction
Now, as a final example, you can send a transaction, such as burning 0.000000001 ETH.
To do this, you’ll need to construct a transaction with ParticleWalletAPI.createTransaction
using standard parameters such as from
, to
, value
, and (optionally) data
.
Upon construction, the transaction can be sent through auth.evm.sendTransaction
; once the user signs/confirms, it’ll be pushed to the network; an example of this is shown below.
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.
Was this page helpful?