3.7. Configure your app scheme URL, select your app from TARGETS, under Info section, click + to add the URL types, and paste your scheme in URL Schemes
Your scheme URL should be "pn" + your project app uuid.
For example, if your project app id is "63bfa427-cf5f-4742-9ff1-e8f5a1b9828f", your scheme URL is "pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f".
3.8 Edit Podfile, you should follow Podfile required to edit Podfile.
Expo support
if you are developing with Expo. you need add more in ios/Podfile
post_install do|installer| installer.pods_project.targets.each do|target|# specify our SDK name and sub moudule name,# this is an example for react-native-particle-auth packageif target.name =='ParticleNetworkBase'or target.name =='ParticleAuthService'or target.name =='CryptoSwift'or target.name =='SwiftyUserDefaults' target.build_configurations.each do|config| config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] ='YES'endendend
Before using the SDK you have to call init(Required)
// Get your project id and client from dashboard, // https://dashboard.particle.network/ParticleInfo.projectId =''; // your project idParticleInfo.clientKey =''; // your client key constchainInfo= Ethereum;constenv=Env.Production;particleAuth.init(chainInfo, env);
SecurityAccountConfig has two parameters, the first is promptSettingWhenSign, controls if show prompt when sign, the second is promptMasterPasswordSettingWhenSign. controls if show prompt when login.
particleAuth.openAccountAndSecurity();// You need listen for possible errorsprivate openAccountAndSecurityEvent: any;componentDidMount= () => {console.log('AuthDemo componentDidMount');if (Platform.OS==='ios') {constemitter=newNativeEventEmitter(particleAuth.ParticleAuthEvent);this.openAccountAndSecurityEvent =emitter.addListener('securityFailedCallBack',this.securityFailedCallBack); } else {this.openAccountAndSecurityEvent =DeviceEventEmitter.addListener('securityFailedCallBack',this.openAccountAndSecurityEvent ); }};componentWillUnmount() {this.openAccountAndSecurityEvent.remove();};securityFailedCallBack= (result:any) => {console.log(result);}
Set iOS modal present style and medium screen
// support iOS, doesn't support Androidconststyle=iOSModalPresentStyle.FormSheet;particleAuth.setModalPresentStyle(style)// request iOS 15 or later, doesn't support AndroidparticleAuth.setMediumScreen(isMedium);
Set language
// support EN, ZH_HANS, ZH_HANT, JA, KOparticleAuth.setLanguage(language);
Set appearance
// support Light, Dark, SystemparticleAuth.setAppearance(Appearance.Dark);
Set fiatCoin
// support USD, CNY, JPY, HKD, INR, KRWparticleAuth.setFiatCoin(FiatCoin.KRW);
Has master password, payment password, security account
// get value from local user infoconsthasMasterPassword=awaitparticleAuth.hasMasterPassword();consthasPaymentPassword=awaitparticleAuth.hasPaymentPassword();consthasSecurityAccount=awaitparticleAuth.hasSecurityAccount();// get value from remote servergetSecurityAccount=async () => {constresult=awaitparticleAuth.getSecurityAccount();if (result.status) {constsecuirtyAccount=result.data;consthasMasterPassword=secuirtyAccount.has_set_master_password;consthasPaymentPassword=secuirtyAccount.has_set_payment_password;constemail=secuirtyAccount.email;constphone=secuirtyAccount.phont;consthasSecurityAccount=!email ||!phone; console.log('hasMasterPassword', hasMasterPassword, 'hasPaymentPassword', hasPaymentPassword, 'hasSecurityAccount', hasSecurityAccount);
} else {consterror=result.data;console.log(error); }}
EVM Service
Write Contract
Get a write contract transaction
const from ="your public address";const contractAddress ="your contract address";const methodName ="mint"; // this is your contract method name, like balanceOf, mint.const params = []; // this is the method params.// abi json string, you can get it from your contract developer.// such as// [{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]
const abiJsonString ="";const transaction =awaitEvmService.writeContract(from, contractAddress, methodName, params, abiJsonString);
Read contract
Read conrtact data from blockchain
const contractAddress ="0x326C977E6efc84E512bB9C30f76E30c160eD06FB";const methodName ="balanceOf"; // this is your contract method name, like balanceOf, mint.const params = [address]; // this is the method params.// abi json string, you can get it from your contract developer.// such as// [{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]
const abiJsonString ="";const result =awaitEvmService.readContract(contractAddress, methodName, params, abiJsonString);
Estimated gas
Return estimated gas
const result =awaitEvmService.estimateGas(from, to, value, data);
Get suggested gas fees
Return gas fee json object.
const result =awaitEvmService.suggeseGasFee();
Get tokens and NFTs
Return all tokens, NFTs and native amount at this address.
const result =awaitEvmService.getTokensAndNFTs(publicAddress);
Get tokens
Return all tokens and native amount at this address.
const result =awaitEvmService.getTokens(publicAddress);
Get NFTs
Return all NFTs at this address.
const result =awaitEvmService.getNFTs(publicAddress);
Get token by token addresses
Return the balance of the token specified below this address
const result =awaitEvmService.getTokenByTokenAddresses(publicAddress, tokenAddresses);
Get transactions by address
Return all transaction at this address
const result =awaitEvmService.getTransactionsByAddress(publicAddress);
Get price
Return token price
const result =awaitEvmService.getPrice(tokenAddresses, currencies);
Get smart account
Require add particle_biconomy and enable Biconomy.
Return smart account json object
const eoaAddress =await particleAuth.getAddress();const result =awaitEvmService.getSmartAccount([eoaAddress], BiconomyVersion.v1_0_0);