This guide will help you get started with Particle Wallet iOS SDK by setting up your environment, based on the previous guides, should now understand how to create a Wallet, our Particle Wallet iOS SDK offers common wallet pages, quick sending, viewing NFTs, viewing transaction history, and other features.
If you face any problem anytime, you can always refer to the ParticleCommunity for us to help you out as soon as possible!
Install ParticleConnectService SDK using Cocoapods.
platform :ios,'14.0'source 'https://github.com/CocoaPods/Specs.git'target 'ParticleExample'do# Comment the next line if you don't want to use dynamic frameworks use_frameworks! pod 'ParticleNetworkBase','1.3.10' pod 'ParticleAuthService','1.3.10' pod 'ParticleWalletAPI','1.3.10' pod 'ParticleAA','1.3.10' pod 'ParticleWalletGUI','1.3.10' pod 'ParticleWalletConnect','1.3.10' pod 'ConnectCommon','0.2.16' pod 'ConnectEVMAdapter','0.2.16' pod 'ConnectSolanaAdapter','0.2.16' pod 'ConnectWalletConnectAdapter','0.2.16' pod 'ConnectPhantomAdapter','0.2.16' pod 'ParticleConnect','0.2.16' pod 'ParticleAuthAdapter','0.2.16'endpost_install do|installer| installer.pods_project.targets.each do|target| target.build_configurations.each do|config| config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] ='YES'endendend
Register your application
In order to use ParticleWalletService, you'll need to create a project in the Particle Dashboard and get your project id, client key and project app id.
Create a ParticleNetwork-Info.plist into the root of your Xcode project, Copy the following text into this file, then replace YOUR_PROJECT_UUID, YOUR_PROJECT_CLIENT_KEY, and YOUR_PROJECT_APP_UUID with the new values created in your Dashboard.
Next step is set your scheme, select your app from TARGETS in Xcode, go to the "Info" section and click on the '+' button to add a new entry to the "URL types" field, under "URL Schemes", paste your specific scheme information.
Your scheme URL should be "pn" followed by your project app id.
For instance, if your project app id is "63bfa427-cf5f-4742-9ff1-e8f5a1b9828f", your scheme URL should be "pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f".
Now, let's initialize ParticleConnectService in your project, chainInfo signifies the chain (ethereum, polygon ...) you want to initialize ParticleConnectService with.
importConnectCommonimportConnectPhantomAdapterimportConnectWalletConnectAdapterimportParticleAAimportParticleAuthAdapterimportParticleConnectimportParticleNetworkBaseimportParticleWalletConnectimportUIKit@mainclassAppDelegate:UIResponder, UIApplicationDelegate {var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.particleInit()returntrue }funcparticleInit() {let adapters: [ConnectAdapter] = [MetaMaskConnectAdapter(),ParticleAuthAdapter(),PhantomConnectAdapter(),WalletConnectAdapter(),RainbowConnectAdapter(),BitkeepConnectAdapter(),ImtokenConnectAdapter(),TrustConnectAdapter(),ZerionConnectAdapter(),MathConnectAdapter(),OmniConnectAdapter(),Inch1ConnectAdapter(),ZengoConnectAdapter(),AlphaConnectAdapter(),OKXConnectAdapter(), ] ParticleConnect.initialize(env: .debug, chainInfo: .polygon(.mumbai)) { adapters } ParticleConnect.setWalletConnectV2ProjectId("your wallet connect project id")// set your biconomy api keyslet biconomyApiKeys = [80001:"your biconomy api key for chain id 80001"]// We support biconomy v1 | biconomy v2 | cyberConnect | simple AAService.initialize(name: AA.AccountName.biconomyV1, biconomyApiKeys: biconomyApiKeys)let aaService =AAService() ParticleNetwork.setAAService(aaService) aaService.enableAAMode()// Set wallet connect chains,// Note metamask only support one chain for each connection.// ParticleConnect.setWalletConnectV2SupportChainInfos([.ethereum, .ethereumGoerli, .polygon, .polygonMumbai]) ParticleWalletConnect.initialize( WalletMetaData(name:"Particle Wallet", icon: URL(string:"https://connect.particle.network/icons/512.png")!, url: URL(string:"https://particle.network")!, description: "Particle Connect is a decentralized wallet connection protocol that makes it easy for users to connect their wallets to your DApp."))
ParticleWalletConnect.setWalletConnectV2ProjectId("your wallet connect project id") } func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return ParticleConnect.handleUrl(url) }}
All here, initialization is complete.
Wallet UI
After your connect a wallet, if you want to send token, call PNRouter.navigatorTokenSend,
it receives a parameter TokenSendConfig, pass nil means send native token.
You can create a new TokenSendConfig object, specify token address, receiver address and amount.
In this guide, we learned how to use the Particle Auth iOS SDK for social login, sending transactions, and signing message. If you want to learn more about different use cases, check out the Particle Wallet page.