Creating the Wallet
The first key action a user will take is creating a wallet. This wallet will contain the user's first name, last name, and email address, which are necessary for identification and email verification.
Note: You should add a connection before excuting the verification flow using the addHome
function from contactManager.
Example: Create Wallet Screen
Here’s an example of a screen where the user will input their information:
import React, { useState } from "react";
import { View, TextInput, Button, Alert } from "react-native";
import { initializeAgent } from "../../one37Agent";
const CreateWalletScreen = () => {
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [email, setEmail] = useState("");
const handleCreateWallet = async () => {
if (!firstName || !lastName || !email) {
Alert.alert("Error", "Please fill all fields.");
return;
}
const agent = await initializeAgent();
const connectionResult = await agent.contactManager.addHome();
if (!connectionResult) {
console.log("error:", connectionResult.error);
return;
}
const result = await agent.contactManager.startEmailVerificationFlow(email);
if (result.isSuccessful) {
Alert.alert("Success", "Check your email to verify.");
} else {
Alert.alert("Error", result.error);
}
};
return (
<View>
<TextInput
placeholder="First Name"
value={firstName}
onChangeText={setFirstName}
/>
<TextInput
placeholder="Last Name"
value={lastName}
onChangeText={setLastName}
/>
<TextInput
placeholder="Email"
value={email}
onChangeText={setEmail}
keyboardType="email-address"
/>
<Button title="Create Wallet" onPress={handleCreateWallet} />
</View>
);
};
export default CreateWalletScreen;
In this screen, the user provides their basic details. Once the details are submitted, we trigger the email verification flow using the One37ID SDK's startEmailVerificationFlow(email)
method.