Android Telegram Client

· Components

From sgcWebSockets 4.4.1 Telegram is supported for Android devices, which means that you can build your own telegram client. TDLib takes care of all network implementation details, encryption and local data storage. TDLib supports all Telegram features.

TDLib (Telegram Database Library) Advantages

Configuration 

Deploy the library libtdjsonandroid.so to your device and configure your Remote Path depending of your Android Version:

Android 32: set Remote Path to library\lib\armeabi-v7a\

Android 64: set Remote Path to library\lib\arm64-v8a\

Create your Telegram 

In order to obtain an API id and develop your own application using the Telegram API you need to do the following:

These values must be set in Telegram.API property of Telegram component. In order to authenticate, you must set your phone number (with international code), example: 34699123456

The following parameters can be configured:

Once you have configured Telegram Component, you can set Active property to true and program will try to connect to Telegram. 

Android Sample Code

oTelegram := TsgcTDLib_Telegram.Create(nil);
oTelegram.Telegram.API.ApiHash := 'your api hash';
oTelegram.Telegram.API.ApiId := 'your api id';
oTelegram.PhoneNumber := 'your phone number';
oTelegram.ApplicationVersion := '1.0';
oTelegram.DeviceModel := 'Desktop';
oTelegram.LanguageCode := 'en';
oTelegram.SystemVersion := 'Android';
oTelegram.Active := true;
procedure OnAuthenticationCode(Sender: TObject; var Code: string);
begin
  InputBox('Telegram', 'Introduce Telegram Code', '',
    procedure(const AResult: TModalResult; const AValue: string)
    begin
      sgcTelegram.SetAuthenticationCode(AValue);
    end
    );
end;
procedure OnMessageText(Sender: TObject; MessageText: TsgcTelegramMessageText);
begin
  Log('Message Received: ' + MessageText.Text);
end;
procedure OnConnectionStatus(Sender: TObject; const Status: string);
begin
  if Status = 'connectionStateReady' then
    oTelegram.SendTextMessage('1234', 'Hello Telegram!');
end; 

 Android Telegram Client Screenshots