Installing Particle Auth
@particle-network/rn-auth-core
alongside @particle-network/rn-base
.To do this, execute the command(s) below.Configuring Particle Auth
Access the Particle Dashboard
Create a new project or enter an existing project
Create a new iOS/Android application, or skip this step if you already have one
Retrieve the project ID, client key, and application ID
build.grade
file (which is generally found at ${project name}/android/app/build.gradle
).Specifically, within build.gradle
, you’ll need to set four different values:dataBinding
, this should be enabled with enabled = true
.manifestPlaceholders["PN_PROJECT_ID"]
, the project ID previously retrieved from the Particle dashboard.manifestPlaceholders["PN_PROJECT_CLIENT_KEY"]
, the client key previously retrieved from the Particle dashboard.manifestPlaceholders["PN_APP_ID"]
, the app ID previously retrieved from the Particle dashboard.ios/{project name}.xcworkspace
.Configuring ParticleNetwork-Info.plist
ParticleNetwork-Info.plist
. Ensure this is marked under “Target Membership.”From here, with a fresh ParticleNetwork-Info.plist
file, go ahead and fill it in with the previously retrieved project keys (from the Particle dashboard):Configuring Info.plist: Face ID
Info.plist
file and include the following snippet:Configuring your Podfile
Specific note for using Expo.
If you’re working with Expo, your Podfile needs additional editing to ensure compatibility with Particle Auth Core, as below:
You can reference this Podfile.
Initializing Particle Auth
ParticleInfo.projectId
and ParticleInfo.clientKey
.After doing so, simply call the init
method on particleBase
. This takes the following parameters:chainInfo
, representing the primary chain you intend to use (for example, ChainInfo.Ethereum
, chainInfo.Polygon
).env
, affecting the information logged within your environment (Env.dev
, Env.production
, or Env.staging
).Facilitating social login
particleAuthCore.connect
to initiate social login, passing in the specific login type you’d like the user to onboard through (.Google
, .Twitter
, .Discord
, etc.) alongside, if applicable, the type of account prompt used by the OAuth provider (.SelectAccount
, .Consent
, .None
).ParticleAuthCore.switchChain
to switch chains, and after waiting for 2 seconds, a new address for the selected chain will be generated for you.evm.getAddress
and particleAuthCore.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.
EvmService.createTransaction
using standard parameters such as evmAddress
(the sender), data
, value
, and receiverAddress
,
Upon construction, the transaction can be sent through evm.sendTransaction
; once the user signs/confirms, it’ll be pushed to the network; an example of this is shown below.