Table of Contents

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

number PhoneNumber

The number to register.

options RegistrationOptions

Voice instead of SMS, and an optional captcha token; defaults to SMS without captcha.

cancellationToken CancellationToken

Cancels 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

number PhoneNumber

The registered number.

deleteAccount bool

Also delete the Signal account on Signal's servers. This cannot be undone.

deleteLocalData bool

Also delete the account's local data (keys, messages) from the container.

cancellationToken CancellationToken

Cancels 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

number PhoneNumber

The number being registered.

verificationCode string

The code from the SMS or call; separators such as 123-456 are removed.

pin string

The registration lock PIN, if the account has one.

cancellationToken CancellationToken

Cancels the request.

Returns

Task

A task that completes when the number is registered.

Exceptions

ArgumentException

verificationCode is empty.

SignalApiException

The code is wrong or expired, or the PIN is missing or wrong.