Interface IRegistrationService
- Namespace
- Signal.Application.Abstractions
- Assembly
- Signal.Application.dll
Registers a phone number as the container's primary Signal device, as an alternative to linking the container to an existing account (GetLinkQrCodeAsync(string, CancellationToken)).
public interface IRegistrationService
Remarks
Typical flow: RegisterAsync(PhoneNumber, RegistrationOptions?, CancellationToken) sends a code by SMS or voice, then VerifyAsync(PhoneNumber, string, string?, CancellationToken) completes the registration with that code. Registering a number that is active on a phone moves the account to the container: the phone's Signal app is signed out.
Calls are never retried (they are POST requests): a retry would request another code and can run into Signal's rate limits.
Methods
RegisterAsync(PhoneNumber, RegistrationOptions?, CancellationToken)
Requests a verification code for number (POST /v1/register/{number}).
Task RegisterAsync(PhoneNumber number, RegistrationOptions? options = null, CancellationToken cancellationToken = default)
Parameters
numberPhoneNumberThe number to register.
optionsRegistrationOptionsVoice instead of SMS, and an optional captcha token; defaults to SMS without captcha.
cancellationTokenCancellationTokenCancels the request.
Returns
- Task
A task that completes when the code was requested.
Exceptions
- SignalApiException
The API rejected the request, e.g. because a captcha is required (retry with Captcha).
UnregisterAsync(PhoneNumber, bool, bool, CancellationToken)
Unregisters a number from the container (POST /v1/unregister/{number}).
Task UnregisterAsync(PhoneNumber number, bool deleteAccount = false, bool deleteLocalData = false, CancellationToken cancellationToken = default)
Parameters
numberPhoneNumberThe registered number.
deleteAccountboolAlso delete the Signal account on Signal's servers. This cannot be undone.
deleteLocalDataboolAlso delete the account's local data (keys, messages) from the container.
cancellationTokenCancellationTokenCancels the request.
Returns
- Task
A task that completes when the number is unregistered.
VerifyAsync(PhoneNumber, string, string?, CancellationToken)
Completes a registration with the received code (POST /v1/register/{number}/verify/{code}).
Task VerifyAsync(PhoneNumber number, string verificationCode, string? pin = null, CancellationToken cancellationToken = default)
Parameters
numberPhoneNumberThe number being registered.
verificationCodestringThe code from the SMS or call; separators such as
123-456are removed.pinstringThe registration lock PIN, if the account has one.
cancellationTokenCancellationTokenCancels the request.
Returns
- Task
A task that completes when the number is registered.
Exceptions
- ArgumentException
verificationCodeis empty.- SignalApiException
The code is wrong or expired, or the PIN is missing or wrong.