Telegram Unity Networking

This package is a implementation of Telegram client library, for Unity. Also included: A setup wizard, demo scenes and documentation.

Based on the Telegram API and the MTProto protocol, Telegram Unity Networking make it very easy to add chat in your app.

Supported platforms: Standalone, Android.

Initial Setup...

TUN Setup

Telegram Unity Networking (TUN) is really easy to setup. Import TUN into a new project and the TUN Wizard will pop up. For (if you have not already) api_id and api_hash, you need to register (free of charge) on "API development tools". After this enter existing api_id and api_hash into the fields. Done.

Getting Started

To connect, you only have to call TelegramNetwork.Connect in your code.

MonoBehaviour Callbacks

Telegram Unity Network uses several callbacks to let your game know about state changes, like "authenticated", "joined a chat", "received new message",... As usual for Unity, the callbacks can be implemented in any script.
In MonoBehaviour, you can call each of the callbacks individually.

public void OnAuthenticated()
  var name = TelegramNetwork.User.first_name + " " + TelegramNetwork.User.last_name;
  Debug.Log("OnAuthenticated() called by TUN. Username: " + name);

Sending Request

After connected you are able to send requests on telegram server. Sending requests can be done using static methods TelegramRequest
The names of these methods are equivalent to the corresponding requests Telegram API. For example, to use a method checkPhone you need call TelegramRequest.checkPhone.
The parameter of the called method, you can specify callback-function that will answer.

Sample using

This is a simple example of checking whether the phone number is registered.

void Awake ()
void OnConnected()
  TelegramRequest.CheckPhone("453463757", OnResponse);
private void OnResponse(TLCheckedPhone checkedPhone)
  Debug.Log(checkedPhone.phone_registered ? "This number is registered" : "This number is not registered");

It is important to know that most methods require authorization before using them.
To authorization, you need to get auth-сode using call TelegramRequest.Auth, and then send it via call TelegramRequest.SignIn.

Demo Videos

Game-server in 10 min

How write server multiplayer game Tic-tac-toe, in 10 minutes, using one of the public libraries Telegram Bot API?
You can write in any language (C#, PHP, Java, Node.js, Python, Ruby, Go, Lua, Haskell, Scala, ...)
Learn how

Who's Online

Сейчас 80 гостей и ни одного зарегистрированного пользователя на сайте