All Projects β†’ leoMehlig β†’ Tdlib Ios

leoMehlig / Tdlib Ios

Licence: mit
An iOS Library to work with Telegram's tdlib.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Tdlib Ios

Aiva
AIVA (A.I. Virtual Assistant): General-purpose virtual assistant for developers.
Stars: ✭ 693 (+2913.04%)
Mutual labels:  telegram
Chatistics
πŸ’¬ Python scripts to parse Messenger, Hangouts, WhatsApp and Telegram chat logs into DataFrames.
Stars: ✭ 814 (+3439.13%)
Mutual labels:  telegram
Mypackbot
πŸ€– Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-21.74%)
Mutual labels:  telegram
Diun
Receive notifications when an image is updated on a Docker registry
Stars: ✭ 704 (+2960.87%)
Mutual labels:  telegram
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+3139.13%)
Mutual labels:  telegram
Sensu Plugins Telegram
Telegram handler for sensu
Stars: ✭ 7 (-69.57%)
Mutual labels:  telegram
Telegram Api
Complete async capable Telegram bot API implementation for PHP7
Stars: ✭ 650 (+2726.09%)
Mutual labels:  telegram
Telegram Standup Bot
Very simple telegram bot for submitting daily standups
Stars: ✭ 20 (-13.04%)
Mutual labels:  telegram
Inventory Hunter
⚑️ Get notified as soon as your next CPU, GPU, or game console is in stock
Stars: ✭ 778 (+3282.61%)
Mutual labels:  telegram
Tlsharp
Telegram client library implemented in C#
Stars: ✭ 895 (+3791.3%)
Mutual labels:  telegram
Octobot
Cryptocurrency trading bot: high frequency, daily trading, social trading, ...
Stars: ✭ 706 (+2969.57%)
Mutual labels:  telegram
Notify
A dead simple Go library for sending notifications to various messaging services.
Stars: ✭ 727 (+3060.87%)
Mutual labels:  telegram
Telegraphist
πŸ€– Telegram Bot API on Go
Stars: ✭ 16 (-30.43%)
Mutual labels:  telegram
Zabbix In Telegram
Zabbix Notifications with graphs in Telegram
Stars: ✭ 710 (+2986.96%)
Mutual labels:  telegram
Micha
Client lib for Telegram bot api
Stars: ✭ 18 (-21.74%)
Mutual labels:  telegram
Flowerss Bot
A telegram bot for rss reader. δΈ€δΈͺζ”―ζŒεΊ”η”¨ε†…ι˜…θ―»ηš„ Telegram RSS Bot。
Stars: ✭ 660 (+2769.57%)
Mutual labels:  telegram
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+3460.87%)
Mutual labels:  telegram
Pyrobot
Telegram Userbot powered by Pyrogram
Stars: ✭ 23 (+0%)
Mutual labels:  telegram
Torpedo
Pluggable, multi-network asynchronous chat bot written in Go
Stars: ✭ 19 (-17.39%)
Mutual labels:  telegram
Docker Dante Telegram
dante config builder for Telegram SOCKS-proxy & Dockerfile for building image with such proxy
Stars: ✭ 16 (-30.43%)
Mutual labels:  telegram

Anyone wants to take over

I'm no longer using this library myself and currently don't have the time to maintain it. If anyone wants to take over, please let me know.

TBLib-iOS

Carthage compatible Documentation Build Status

TDLib-iOS is a wrapper around Telegram's tdlib to interact with the Telegram API using Swift.

This library depends on TDJSON, a build of tdlib for iOS, and PromiseKit for better async programming.

TDLib-iOS provides a nativ Swift interface, that is generated from the td_api.tl using the a custom parser. A full documentation of the generated Swift API can be found here.

Installation

Carthage:

Just add github "leoMehlig/TDLib-iOS" to your Cartfile and do the usual Carthage stuff.

Other options:

Other options are not supported right now, but PR are more then welcome.

Usage

Setup

Create the coordinator, this instance will take care of sending request, receiving responses and handling all the inital setup.

let coordinator = Coordinator(client: TDJsonClient(), apiId: <Telegram API ID>, apiHash: <Telegram API Hash>)

You can get an api key from Telegram.

Loging in

You can subscribe to the Coordinator.authorizationState for updates about the current Auth State of the API. Here is an example of how to handle the sign in flow:

 coordinator.authorizationState.subscribe(on: .main) { event in
            guard let state = event.value else {
                return
            }
            switch state {
            case .waitTdlibParameters, .waitEncryptionKey:
                // Ignore these! TDLib-iOS will handle them.
            case .waitPhoneNumber:
                // Show sign in screen.
            case .waitCode(let isRegistered, let tos, let codeInfo):
                // Show code input screen.
            case .waitPassword(let passwordHint, _, _):
                // Show passoword screen (will only happen when the user has setup 2FA).
            case .ready:
                // Show main view
            case .loggingOut, .closing, .closed:
                break
            }

Stream

The Stream is a custom implementation of a data stream that calls a subscribing function every time a new value is assigned the the Stream.current field.

As a user of the library you never have to create a stream and only use them to get respond to changes in the authorizationState and when downloading images/documents.

You can subscribe to stream by adding yourself as an observer using the Stream.subscribe method. The method take an token (optional) to later unsubscribe, a queue (defaults to DispatchQueue.global()) and a callback that provided you with the new events. There is also a convience methos to avoid reference cycles, called subscribeStrong.

Sending a request

To send a request to tdlib use the Coordinator.send method.

coordinator.send(GetChats(offsetOrder: offsetOrder, offsetChatId: offsetChatId, limit: limit)).done { ids in
    print("Got chat ids: \(ids)")
}

The send method takes a TDFunction and returns a Promise of the Result of the function. Of cause this request can also fail!!!

For more infos about Promises see the PromiseKit documentation.

How it works

The Coordinator wraps an instance of a TDJsonClient with in turn is just an interface to the c++ api of tdlib. TDLib-iOS communicates with tdlib via a json interface, which is very error prone when using directly. To prevent typos and wrong json format the library provides a generated Swift version of all avaiable functions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].