iOS
Add Auth Service to Your iOS Project
Prerequisites
Install the following:
Xcode 14.1 or later
CocoaPods 1.12.1 or higher
Make sure that your project meets the following requirements:
Your project must target these platform versions or later:
iOS 14
Please note that the current version of our software does not support simulation testing. To perform testing, you will require an actual iPhone device.
Create a Particle Project and App
Before you can add our Auth Service to your iOS app, you need to create a Particle project to connect to your iOS app. Visit Particle Dashboard to learn more about Particle projects and apps.
👉 Sign up/log in and create your project now
Add the Auth Service SDK to Your App
Auth Service supports installation with CocoaPods.
Here's how to install the Auth Service using CocoaPods:
Create a Podfile if you don't already have one. From the root of your project directory, run the following command:
2. To your Podfile, add the Auth Service pods that you want to use in your app:
3. Install the pods, then open your .xcworkspace
file to see the project in Xcode:
Edit Podfile
It is required for every iOS project that integrates the Auth Service SDK.
Initialize Auth Service in your app
The final step is to add an initialization code to your application. You may have already done this as part of adding the Auth Service to your app.
Create a ParticleNetwork-Info.plist into the root of your Xcode project
Copy the following text into this file:
Replace
YOUR_PROJECT_UUID
,YOUR_PROJECT_CLIENT_KEY
, andYOUR_PROJECT_APP_UUID
with the new values created in your DashboardImport the
ParticleNetwork
module in yourUIApplicationDelegate
Initialize the ParticleNetwork service, which is typically in your app's
application:didFinishLaunchingWithOptions:
method:
Our SDK requires the 'Privacy - Face ID Usage Description' permission in order to function correctly. This is necessary because our SDK utilizes Face ID for secure user authentication. To request this permission, you must include the
NSFaceIDUsageDescription
key in your app'sInfo.plist
file, accompanied by a string value explaining the reason for the request. The text you provide is presented to the user when your app first attempts to use Face ID. Here's an example:
Together with Wallet Service
If you want to use with Wallet Service, you should add more pods in Podfile.
Initialize Particle Connect Service, add AuthCoreAdaper to your adapters.
API Reference
Get an AuthCore object
Get verification code
If you want to custom login page, add phone number or email login, here is the method to get the verification code
Prototype
Parameters
email
: Email addressphone
: Phone number, format E164.
Returns
The function returns a bool value.
Example usage
Login
You can authenticate users in your app with an Auth
object, by using the self.auth.connect
function. This function supports different login types such as email, phone, Google, Apple, and Facebook. When the login is successful, a user wallet is created.
Prototype
Parameters
type
: Specifies the login type (e.g., email, phone, jwt, google, apple, facebook).account
: Optional parameter for email, phone, or jwt login methods. You should pass in the user's email address, phone number, or jwt token here, the phone number must be in E164 format.code
: Optional parameter for email and phone, the verification code.supportAuthType
: Controls whether third-party login buttons are displayed. By default, all third-party login buttons are shown.socialLoginPrompt
: Social login prompt.
Returns
The function returns a user information object (userinfo
) if the login is successful.
Example usage
We also keep the old method, one line code to login Particle with JWT.
Account Abstraction could use together with Auth Core Service, explore Account Abstraction for more detail, learn how to get a smart account address, how to send transaction under AA mode.
Wallet Service could use together with Auth Core Service, explore Wallet Service for more detail, learn how to open wallet page, how to open send page, how to open swap page etc.
Present login page
Present a login page to help email and phone login, if you pass other login type, will bridge to connect
method.
Prototype
Parameters
type
: Specifies the login type (e.g., email, phone, jwt, google, apple, facebook).account
: Optional parameter for email, phone, or jwt login methods. You should pass in the user's email address, phone number, or jwt token here, the phone number must be in E164 format.supportAuthType
: Controls whether third-party login buttons are displayed. By default, all third-party login buttons are shown.socialLoginPrompt
: Social login prompt.config
: LoginPageConfig, custom your icon, title and welcome message.
Returns
The function returns a user information object (userinfo
) if the login is successful.
Example usage
Get user info
Logout
The SDK will delete users' account information in cache.
Check user login status
Get Wallet Address
Switch ChainInfo
Signatures
Use Auth Core SDK to sign a transaction or message.
Master Password
Wallet can set master password to protect assets.
Payment Password
If set a payment password, user should input password before sign message and transaction.
Open account and security
Bind more login account, manage payment password etc.
Set security account config
Custom interface style
Language setting
Set custom UI json string
Blind sign enable
This switch will work if the following conditions are met:
1. your account is connected with JWT
2. your account does not set payment password
3. SecurityAccountConfig.promptSettingWhenSign is 0, you can call ParticleNetwork.setSecurityAccountConfig to update its value.
Error
Try cast error into type ParticleNetwork.Response
, you can check the information by printing its attributes.
Last updated