Skip to content

ivk1800/tdlib-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tdlib-dart

A Dart wrapper for tdlib. Contains generated schema classes of td_api.tl and a client that interacts with lib through ffi.

Actual version of tdlib: 1.8.4 d489014

Table of Contents

Getting started with example

  1. Obtain api_id and api_hash at https://my.telegram.org
  2. Build tdlib for your operating system following the guide below.
  3. Open example/lib/main.dart and place obtained api_id and api_hash to appropriate methods getApiId and getApiHash.
  4. Specify phone number and code in getPhoneNumber and getCode methods. Attention, the phone number must be specified from the test DC. If you don't want to use the test DC and want to authenticate with your account, change useTestDc to false in TdlibParameters.
  5. cd <repo folder>/example
  6. flutter run

Build tdlib

The official repository contains instructions on how to build tdlib. https://github.com/tdlib/td#building

  1. git clone [email protected]:tdlib/td.git
  2. git checkout d489014

Android

Instruction: tdlib/td#77 (comment)

  1. Download libtdjsonandroid.zip tdlib/td#77 (comment)
  2. Unpack the archive to td/example directory.
  3. Then download the latest OpenSSL 1.1.1 source code as a .tar.gz archive from OpenSSL 1.1.1 release page and place it in the third_party/crypto subfolder.
  4. Edit example/third_party/crypto/build.sh. Set your ANDROID_NDK path, export ANDROID_NDK=/Users/arseny30/Library/Android/sdk/ndk-bundle replace by own path to ndk.
  5. chmod +x build.sh and build-all.sh in example/third_party/crypto/ folder.
  6. chmod +x export.sh in example
  7. Setup ANDROID_NDK path in example/build.sh. Replace ...=${ANDROID_SDK_ROOT}/ndk-bundle/... by own path to ndk.
  8. chmod +x build.sh and build-all.sh in example/ folder.
  9. Fix cmake path in CMakeLists.txt, replace set(TD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) by set(TD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..).
  10. Run example/third_party/crypto/build-all.sh
  11. Run example/export.sh
  12. Copy .so files from example/libs to example/android/app/main/jniLibs:
└── example 
    └── android 
        └── app 
            └── main 
                └── jniLibs 
                    └── arm64-v8a
                    │   └── libtdjsonandroid.so
                    │   └── libtdjsonandroid.so.debug
                    └── armeabi-v7a
                    │   └── libtdjsonandroid.so
                    │   └── libtdjsonandroid.so.debug
                    └── x86
                    │   └── libtdjsonandroid.so
                    │   └── libtdjsonandroid.so.debug
                    └── x86_64
                        └── libtdjsonandroid.so
                        └── libtdjsonandroid.so.debug
  1. Open file example/android/app/build.gradle

replace

sourceSets {
  main.java.srcDirs += 'src/main/kotlin'
}

by

sourceSets {
  main {
    java.srcDirs += 'src/main/kotlin'
    jniLibs.srcDirs = ['src/main/jniLibs']
  }
}

iOS and macOS

Instruction: https://github.com/tdlib/td/tree/master/example/ios

  1. Remove watchOS and tvOS in example/ios/build-openssl.sh and example/ios/build.sh: replace platforms="macOS iOS watchOS tvOS" by platforms="macOS iOS".
  2. Build following the guide.
  3. Copy example/ios/tdjson/iOS/lib/libtdjson.dylib to example/ios
  4. Copy example/ios/tdjson/macOS/lib/libtdjson.dylib to example/macos
└── example 
    └── ios 
    │   └── libtdjson.dylib
    └── macos
        └── libtdjson.dylib
  1. Open Runner.xcworkspace in Xcode.
  2. Add .dylib file to project.
  3. Find Frameworks, Libraries, and EmbeddedContent.
  4. Against libtdjson.dylib choose Embed & Sign.
  5. Find Signing & Capabilities.
  6. In Section App Sandbox (Debug and Profile) set true Outgoing Connections (Client).

Windows

Instruction: https://tdlib.github.io/td/build.html

  1. Choose language C++
  2. Choose operating system Windows
  3. Build following the guide.
  4. Copy files from /tdlib/bin to example/windows/tdlib
└── example 
    └── windows 
        └── tdlib 
            └── libcrypto-1_1.dll
            └── libssl-1_1.dll
            └── tdjson.dll
            └── zlib1.dll
  1. Rename libcrypto-1_1-(x64|x32).dll to libcrypto-1_1.dll and libssl-1_1-(x64|x32).dll to libssl-1_1.dll
  2. Open example/windows/CMakeLists.txt.
  3. Add below line set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}"):
# begin td
set(dll_path "${CMAKE_CURRENT_SOURCE_DIR}/tdlib")
set(libcrypto "libcrypto-1_1.dll")
set(libcrypto_path "${dll_path}/${libcrypto}")
install(CODE "file(REMOVE_RECURSE \"${INSTALL_BUNDLE_LIB_DIR}/${libcrypto}\")" COMPONENT Runtime)
install(FILES "${libcrypto_path}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)

set(libssl "libssl-1_1.dll")
set(libssl_path "${dll_path}/${libssl}")
install(CODE "file(REMOVE_RECURSE \"${INSTALL_BUNDLE_LIB_DIR}/${libssl}\")" COMPONENT Runtime)
install(FILES "${libssl_path}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)

set(tdjson "tdjson.dll")
set(tdjson_path "${dll_path}/${tdjson}")
install(CODE "file(REMOVE_RECURSE \"${INSTALL_BUNDLE_LIB_DIR}/${tdjson}\")" COMPONENT Runtime)
install(FILES "${tdjson_path}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)

set(zlib "zlib1.dll")
set(zlib_path "${dll_path}/${zlib}")
install(CODE "file(REMOVE_RECURSE \"${INSTALL_BUNDLE_LIB_DIR}/${zlib}\")" COMPONENT Runtime)
install(FILES "${zlib_path}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)
# end td

Linux

TBD

Web

TBD

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages