Telegram | Register Telegram User

The process to register a new user in Telegram is very simple, you need your API Id and API Hash, and the phone number of the new account.

 

Configure the telegram client:

 

Start the client and a new code will be sent to the phone, the client will ask for the telegram code and if it's correct, the event OnRegisterUser will be called. In this event set the First Name and Last Name of the user and the registration will be completed.

 


oTelegram := TsgcTDLib_Telegram.Create(nil);
oTelegram.Telegram.API.ApiHash := 'ABCDEFGHIJKLMN';
oTelegram.Telegram.API.ApiId := '1234';
oTelegram.PhoneNumber := '008745744155';
oTelegram.Active := true;

procedure OnTelegramAuthenticationCode(Sender: TObject; var Code: string);
begin
  Code := 'code sent to phone';
end;

procedure OnTelegramRegisterUser(Sender: TObject; var FirstName, LastName: string);
begin
  FirstName := 'first name';
  LastName := 'last name';
end;