void _handleRegister() async {
try {
// Create the user with the phone number and name
await _account.create(
userId: ID.unique(),
phone: _phoneNumberController.text, // the error as no parameter called phone
name: _nameController.text,
);
// Navigate to the desired screen after successful registration
} catch (e) {
// Handle the error
print('Error: $e');
}
}
the error in parameter phone as it isn't in the model
I tried to add a phone to the model but I damaged it
how can I do that and modify
as the error says, there is no parameter phone
in _account.create
method.
for using phone number as authentication, do the following:
the phone authentication requires a two-step process:
import { Client, Account, ID } from "appwrite";
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
const account = new Account(client);
const sessionToken = await account.createPhoneSession(
ID.unique(),
'+14255550123'
);
const userId = sessionToken.userId;
then login with the secret that the user gets per sms.
import { Client, Account, ID } from "appwrite";
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
const account = new Account(client);
const session = await account.updatePhoneSession(
userId,
'[SECRET]'
);
you can check the appwrite documentation for this: docs