Interacting with Particle Auth on Android using Kotlin.
projectId
, clientKey
, and appId
. All three can be retrieved by heading to the Particle dashboard.
ParticleNetwork
.
Start by declaring the Particle Auth SDK in your Gradle file.
projectId
, clientKey
, and appId
within the relevant AndroidManifest.xml
file.
An example of such a configuration is attached below. Placeholders such as pn_project_id
will need to be filled in.
ParticleNetwork
must be initialized to function correctly.
This can be done by calling the init
method on ParticleNetwork
and passing in the primary chain you intend to use within your application.
AuthCore.switchChain
. This allows for asynchronous switching, just like the initial setup.
AuthCore.connect
triggers the standard login popup, which changes based on configurations like loginType
(similar to the Web SDK’s preferredAuthType
) and supportAuthTypeValues
.
This popup serves as the primary method for account creation and login for existing users.
The AuthCore.login
function accepts the following parameters:
Field | Type | Description |
---|---|---|
loginType | LoginType | Specifies the preferred social login method. Options include EMAIL , PHONE , TWITTER , GOOGLE , FACEBOOK , APPLE , DISCORD , GITHUB , TWITCH , MICROSOFT , LINKEDIN , and JWT . |
account | String | The account parameter allows you to pass an expected email, phone number, or JWT. This field is optional for email and phone logins but required for JWT . The phone number must be in E.164 format. |
supportLoginTypes | List<SupportLoginType> | Defines the supported social login methods. By default, all options are supported: EMAIL , PHONE , FACEBOOK , GOOGLE , APPLE , TWITTER , DISCORD , GITHUB , TWITCH , MICROSOFT , and LINKEDIN . You can also specify a subset of these types if needed. |
prompt | LoginPrompt? | Controls the prompt displayed after social login. Options are None , Consent , or SelectAccount . This is only supported by Google, Discord, and Microsoft. |
loginPageConfig | LoginPageConfig? | Customizes the UI of the login page, including the project name, icon, and description. |
loginCallback | AuthCoreServiceCallback<UserInfo> | Callback triggered after the login attempt. Success: Returns UserInfo .Failure: Returns ErrorInfo . |
AuthCore.disconnect
logs the user out of their current session and returns them to their pre-login state.
AuthCore.isLogin
returns a Boolean indicating whether the user is currently logged in with Particle.
syncUserInfo
to synchronize the information.
ParticleNetwork
has been initialized and a user has successfully logged in, signatures can be proposed for confirmation through a pop-up.
AuthCore.evm.personalSign
or AuthCore.evm.personalSignUnique
method.
If you need the same message to return a unique signature each time, use the AuthCore.evm.personalSignUnique
method. Otherwise, the AuthCore.evm.personalSign
method is generally recommended.
Field | Type | Description |
---|---|---|
hexUnSignedMessage | PrefixedHexString | A required field that accepts either a hexadecimal string starting with ‘0x’ or a human-readable string. |
callback | AuthCoreSignCallback<SignOutput> | Handles the response of the signing operation. Success: Returns the signature. Failure: Returns ErrorInfo . |
AuthCore.evm.signTypedData
or AuthCore.evm.signTypedDataUnique
method.
If you need the same message to return a unique signature each time, use the AuthCore.evm.signTypedDataUnique
method. Otherwise, the AuthCore.evm.signTypedData
method is generally recommended.
Field | Type | Description |
---|---|---|
data | PrefixedHexString | A hexadecimal string that must start with “0x”. |
callback | AuthCoreSignCallback<SignOutput> | Handles the response of the signing operation. Success: Returns the signature. Failure: Returns ErrorInfo . |
AuthCore.evm.sendTransaction
.
Field | Type | Description |
---|---|---|
transaction | PrefixedHexString | A hexadecimal string that must start with “0x”. |
callback | AuthCoreSignCallback<SignOutput> | Handles the response of the signing operation. Success: Returns the signature. Failure: Returns ErrorInfo . |
feeMode | FeeMode | The mode for handling transaction fees. The default is FeeModeNative() . Use this field only when AA mode is enabled. |
ParticleNetwork.evm.createTransaction()
method.
AuthCore.solana.signMessage
.
Field | Type | Description |
---|---|---|
message | String | A base58-formatted string that is required for the signature request. |
callback | AuthCoreSignCallback<SignOutput> | Handles the response of the signing operation. Success: Returns the signature. Failure: Returns ErrorInfo . |
AuthCore.solana.signAndSendTransaction
.
Field | Type | Description |
---|---|---|
transaction | String | A base58-formatted string that is required for the transaction. |
callback | AuthCoreSignCallback<SignOutput> | Handles the response of the transaction. Success: Returns the signature. Failure: Returns ErrorInfo . |
Field | Type | Description |
---|---|---|
transaction | String | A base58-formatted string is required. |
callback | AuthCoreSignCallback<SignOutput> | Success: Returns the signature. Failure: Returns ErrorInfo . |
AuthCore. Solana.signAllTransactions
.
Field | Type | Description |
---|---|---|
serializedTransactions | List<Base58String> | A list of base58-formatted strings is required. |
callback | AuthCoreSignCallback<SignAllOutput> | Success: Returns the signatures. Failure: Returns ErrorInfo . |
AuthCore.openAccountAndSecurity
.
promptSettingWhenSign
for payment (signature) passwords and promptMasterPasswordSettingWhenLogin
for a login-based master password.
By default, promptSettingWhenSign
is set to 1, prompting the user on the first signature for a given account. If set to 0, the prompt is never shown; if set to 2, it is shown for every signature confirmation.
The same logic applies to promptMasterPasswordSettingWhenLogin
, though it defaults to 0.
auth.changeMasterPassword
.
To set or change the payment password, call AuthCore.openAccountAndSecurity()
.
ParticleNetwork.setLanguage
and retrieve the currently active language with ParticleNetwork.getAppliedLanguage
. The default language is English.
Field | Type | Description |
---|---|---|
languageEnum | LanguageEnum | The specific language to be used. Options include ZH_CN , ZH_TW , EN , JA , KO . |
isRelaunch | Boolean | If true, the app will relaunch upon a language switch; if false, the activity will be recreated. |
isInit | Boolean | If isRelaunch is set to true, isInit defaults to true. The activity will not be recreated and should be called before methods like signMessage or sendTransaction . |
SecurityAccountConfig.promptSettingWhenSign
is set to 0. You can update this value by calling ParticleNetwork.setSecurityAccountConfig
.