Installation
Prerequisites
Section titled “Prerequisites”- iOS: 15.0 or newer, Xcode 15 or newer
- Android: API 23+ (Android 6.0+)
- Flutter
>=3.3.0, Dart SDK^3.6.0 - A registered Telegram bot via @BotFather
Installation
Section titled “Installation”Add the package to your app’s pubspec.yaml:
dependencies: telegram_login: ^1.2.0Then run flutter pub get.
- iOS: On first build, CocoaPods / SwiftPM will resolve the underlying
telegram-login-iosSDK automatically. - Android: The Telegram Login SDK is automatically downloaded from Maven Central. No additional setup required.
1. Register your bot with BotFather
Section titled “1. Register your bot with BotFather”- Open @BotFather
- Send
/newbot(or pick an existing bot) - Go to Bot Settings → Login Widget
- Register your app:
- iOS: Provide Bundle ID and Apple Team ID
- Android: Provide package name and SHA-256 fingerprint
BotFather will give you a bot client ID (a numeric string) and provision a secure domain of the form app{CLIENT_ID}-login.tg.dev for universal/app links.
2. Configure your app
Section titled “2. Configure your app”iOS Setup
Section titled “iOS Setup”Pick one of the two URL delivery mechanisms.
Option A — Universal Links (recommended, iOS 17.4+)
Section titled “Option A — Universal Links (recommended, iOS 17.4+)”- In Xcode, select your app target → Signing & Capabilities
- Click + Capability → Associated Domains
- Add both entries for your login domain:
applinks:app{YOUR_CLIENT_ID}-login.tg.devwebcredentials:app{YOUR_CLIENT_ID}-login.tg.dev
- For development builds, you may append
?mode=developerto each entry.
Why
webcredentials:is required. On iOS 17.4 and newer,ASWebAuthenticationSession(used internally by the Telegram Login SDK) refuses to open an HTTPS callback unless the app is associated with the callback host via thewebcredentialsservice type. If you add onlyapplinks:, the session will immediately fail withSFAuthenticationSession was cancelled by userand the log will contain: “Using HTTPS callbacks requires Associated Domains using thewebcredentialsservice type for<host>.”
Use the https:// URL as your redirectUri:
redirectUri: 'https://app12345-login.tg.dev'Option B — Custom URL Scheme (fallback, also required on iOS < 17.4)
Section titled “Option B — Custom URL Scheme (fallback, also required on iOS < 17.4)”- Open your app’s
Info.plist - Add a URL Type:
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>myapp</string> </array> </dict></array>Then use your scheme as the redirectUri, and pass the same scheme as fallbackScheme:
TelegramLoginConfiguration( clientId: '12345', redirectUri: 'myapp://auth', scopes: ['profile'], fallbackScheme: 'myapp',)Android Setup
Section titled “Android Setup”-
Register your SHA-256 fingerprint with BotFather:
Terminal window keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass androidCopy the SHA256 value and provide it to BotFather.
-
Add an intent filter to your
AndroidManifest.xmlinside your main activity:
<activity android:name=".MainActivity"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="app{YOUR_CLIENT_ID}-login.tg.dev" /> </intent-filter></activity>Use the same https://app{CLIENT_ID}-login.tg.dev URL as your redirectUri.
3. URL callback forwarding
Section titled “3. URL callback forwarding”The plugin automatically registers itself as a delegate, so Telegram callbacks are forwarded to the native SDK without any code in your AppDelegate or MainActivity. If your app intercepts URLs somewhere else (for example from a router package), use handleUrl to hand them off.