Yalantis: iOS, Android And Web App Development Company

What's Wrong With Open Source Telegram?

Everything about Telegram is cool. No, seriously. It’s free, heavily encrypted, cloud-based, and powerful. The only thing which might confuse app developers is Telegram saying it’s open source.

I investigated the Telegram source code and wrote this post because one of our clients asked me to clarify whether he could use it to develop his messaging application. My response was “You can, but we don’t recommend it.” Telegram does offer free and open source code, but that will barely help app developers build their own messaging apps. Here is why:

You can’t use Telegram API to build an independent messaging app

In order to use Telegram’s API, you will have to register an app here. All you need to do is enter your phone number, and then you will receive a password in your Telegram app account. After you have received the password, you can register an app on Telegram’s website. You will receive a unique api_id and api_hash that is necessary to work with the Telegram API.

When I entered my phone number in the messaging app I created using the Telegram API, I got all the messages I previously sent in the Telegram app (both desktop and Android). In other words, all the data associated with a user is tied to their phone number, which they enter when they authorize with Telegram.

My conclusion is that the Telegram API allows you to work with Telegram’s data only. In other words, it’s impossible to store your data on a separate server or a database and use Telegram API at the same time. Telegram API will let you create an app that interacts with the Telegram messaging app, but is unable to live a life of its own.

A lot of apps have open APIs and let other developers use them. TweetCaster is a great example of an app that works like that. They use open Twitter APIs, and all the tweets published in TweetCaster published on Twitter as well.

On one hand, this solution is not bad if you don’t mind your data being stored in Telegram. But on the other hand, Telegram is not Twitter and there is one issue that you might not feel happy about. Keep reading to learn what I am talking about.

Telegram API

Read also: How to develop a social app

Source code isn’t reusable

Telegram’s source code is not an SDK or a library. Using it will likely expand your development time, rather than speed it up. I looked at their code and found out some terrifying issues. It has lots of hardcode and no constants, nor system constants, nor constants in the app itself. Other major issues include:

1. Strange pieces of code, like setTextColor(0xff757575).

Such code makes it too complicated to change anything along the way. You should normally make a separate XML called “color”. When you need to change the main color of the action bar title, for example, you can do it in one place – color.xml – and it will change the color everywhere else in the code. But in Telegram’s case you’ll have to search for that exact place in the code defined as setTextColor(0xff757575) and only there can you change the color. Honestly, you don’t need this headache unless you want to boost the development time and love to complicate your life for no reason.

2. Magic numbers for int values like “42540” which are passed as flag values. This made me think their code is obfuscated, but most likely, this isn’t the case.

3. “If-Else” statements that are too long and too, and really long methods (i.e. 300 lines of code in one method). This made me curious what sort of a developer wrote this.

4. Spaghetti code and copy-paste. I haven’t met anyone who likes spaghetti, unless it’s Italian.

5. Only three Activities in such a huge project. There are many classes *activity, which extend BaseFragment, which is not actually a Fragment. Sounds crazy, right? BaseFragment is a custom layout with custom methods. According to common sense, *Activity should extend Activity to which you add Fragments.

But to be fair, Telegram doesn’t state they have an SDK. All they did is showed their source code.

Telegram messaging app API

If you develop an app with Telegram license, it should go on GitHub

Even if you make an app based on Telegram, you have to publish the source code. Telegram’s License states: “Please remember to publish your code as well in order to comply with the License”.

If you commit your time and money on developing a messaging app using Telegram source code, you probably won’t be happy about having to publish your code for everyone else to use.

As you can see, Telegram is not the best option for building messaging applications. They provide neither an SDK nor a comprehensible source code. All the elements in Telegram are custom. I have no idea why they decided to make it like that, but from my point of view as a developer, Telegram’s source code is no good for building similar projects.

At the end of the day, it’s not a big deal that the Telegram source can’t help your app. Yalantis has plenty of experience designing and building messaging services. We will make sure you get the best product by building it ourselves!

Check this out:

Insights

How Much Does It Cost to Develop WhatsApp?

Insights

Messaging App Development

Insights

5 Best AI-Powered Chatbot Apps

Insights

What You Need to Know About Chatbot Development

Tech

What I Learned Developing SMS/MMS Messenger for Android

Want to know more about social apps?

Check out how we developed Halaa, an Instagram for voice and video with sound effects

Read the case study