Getting Started - Android
Installation
Add the SDK dependencies to your project
Configure the Maven code repository in the app-level "build.gradle" file
Modify your "settings.gradle" file by adding/changing these lines:
repositories {
String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
maven {
url = uri("s3://tixngo-artifact/sdk/android/[Version]")
credentials(AwsCredentials) {
accessKey = "AKIA2CRJXJWBM6ZSPCXW"
secretKey = "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"
}
}
maven {
url "$storageUrl/download.flutter.io"
}
}
Configure for Gradle 7.0 or later
In Gradle 7.0 or later, configuration under allprojects > repositories is migrated to the project-level settings.gradle file.
The following is a configuration example of the settings.gradle file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
repositories {
maven {
url = uri("s3://tixngo-artifact/sdk/android/[Version]")
credentials(AwsCredentials) {
accessKey = "AKIA2CRJXJWBM6ZSPCXW"
secretKey = "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"
}
}
maven {
url "$storageUrl/download.flutter.io"
}
}
}
Add the following dependencies to the gradle file in the app directory of the project.
debugImplementation 'io.tixngo.sdk:flutter_debug:[Version]'
releaseImplementation 'io.tixngo.sdk:flutter_release:[Version]'
debugImplementation 'io.tixngo.sdkUtils:sdkUtils-debug:[Version]'
releaseImplementation 'io.tixngo.sdkUtils:sdkUtils-release:[Version]'
Permission configuration
Android – AndroidManifest.xml
Working with TIXNGO in Android app requires some permissions (bluetooth & location is define inside sdk). Need to add contact permission for your app.
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
android.permission.READ_CONTACTS: Used to access the user's contact list
This permission allows the app to retrieve the user's contacts in order to support ticket transfers and display pending transfers involving people from their contact list.
android.permission.READ_MEDIA_IMAGES: Used to detect when a user captures a new image or video.
This permission allows the app to monitor image and video captures on the device to help prevent screenshots or screen recordings while using the SDK, and to send relevant mobile logs to the TIXNGO backend if needed.
android.permission.READ_EXTERNAL_STORAGE: Used to detect when a user captures a new image or video (for Android 12 and below).
This permission enables the app to access media files on the device in order to detect new photo or video captures, helping to prevent screenshots or screen recordings while the SDK is active, and to support mobile log reporting to the TIXNGO backend.
android.permission.POST_NOTIFICATIONS: Used to send notifications to the user
This permission allows the app to display important updates, such as ticket status changes, event reminders, and transfer notifications.
Add more activity to work with flutter (TIXNGO SDK based on flutter)
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<service
android:name="com.kontakt.sdk.android.ble.service.ProximityService"
android:exported="false" />
Initialization
Firstly, we need to initialize the TIXNGO SDK, we do that in MainActivity or MainFragment by call below function
TixngoManager.instance.initialize(
context = this,
appIconId = R.mipmap.ic_launcher,
config = TixngoConfiguration(
isEnableScreenshotSSK = true,
isEnableDebug = true,
defaultEnv = TixngoEnv.PREPROD,
isEnableWallet = false,
supportLanguages = arrayOf(
TixngoLanguage.EN,
TixngoLanguage.EN_US,
TixngoLanguage.FR,
TixngoLanguage.FR_CA,
TixngoLanguage.ES_ES,
TixngoLanguage.ES_MX,
TixngoLanguage.PT_PT,
),
defaultLanguage = TixngoLanguage.EN,
themeMode = SDKThemeMode.System,
theme = ThemeConstants.LightTheme1,
darkTheme = ThemeConstants.DarkTheme1,
appIds = CustomAppId(
valId = "mobile_app_key_val_environment",
preProdId = "mobile_app_key_preProd_environment",
prodId = "mobile_app_key_prod_environment"
),
config = TixngoSDKConfig(
isHaveMenu = false,
isHaveSignOut = false,
),
customDomain = TixngoCustomDomain(
valDomain = "api_domain_val_environment",
preProdDomain = "api_domain_preProd_environment",
prodDomain = "api_domain_prod_environment",
),
tokenType = SDKTokenType.IdToken,
),
delegate = this
)
config: Set config for sdk (environment, language, appIds, theme…)
Detail configs:
Security & Debugging
Parameter | Description |
---|---|
| Enables or disables screenshot protection within the SDK. When enabled, the SDK prevents screen captures and screen recordings to enhance security (e.g., during ticket display). |
| Defines where screenshot protection applies:
|
| Enables debug logging during development. When set to |
Environment & Domains
Parameter | Description |
---|---|
| Specifies the SDK environment to use:
|
| Allows overriding the default API domain per environment. Useful for testing against custom or isolated endpoints. |
Ticketing & UI Behavior
Parameter | Description |
---|---|
| Controls the "Wallet Suppression" feature. When enabled, it prevents popups (such as install prompts or over |
| Unique App ID(s) provided by TIXNGO. Required for SDK to request and access ticket data. Contact TIXNGO to obtain valid credentials. |
Language & Localization
Parameter | Description |
---|---|
| Sets the initial language of the SDK interface (e.g., |
| Defines a list of supported language codes (ISO 639-1 format). The SDK will restrict language switching to this list. |
Theming & Appearance
Parameter | Description |
---|---|
| Defines the SDK's light mode color palette using a |
| (Optional) Defines the SDK's dark mode color palette using a |
When both theme
and darkTheme
are provided, the SDK automatically adapts based on the device's current appearance settings (light/dark/system)
TIXNGO SDK pages (exposed functions)
/*
This method is call one time to setup default config and listen callback from the TIXNGO SDK
*/
fun initialize(context: Context, config: TixngoConfiguration? = null, delegate: TixngoSDKDelegate? = null,)
/*
This method to sign out SDK when user do signout in app
*/
fun signOut(completionHandler: (TixngoSDKError?) -> Unit)
/*
This method should be call after login successfully in the FanApp (sync data to SDK and signin to SDK)
*/
fun updateToken(token: String?, completionHandler: (TixngoSDKError?) -> Unit)
/*
This method should be call after SDK initialized
*/
fun updateFCMToken(fcmToken: String?, completionHandler: (TixngoSDKError?) -> Unit)
/*
This method is call when the Fan App want to change theme in SDK
*/
fun changeTheme(themeMode: SDKThemeMode = SDKThemeMode.System, theme: SDKTheme?, darkTheme: SDKTheme?)
/*
This method is call when the Fan App want to change language in SDK.
*/
fun changeLanguage(language: TixngoLanguage, completionHandler: (TixngoSDKError?) -> Unit)
/*
This method is call when the Fan App want to change environment in SDK.
*/
fun changeEnv(env: TixngoEnv, completionHandler: (TixngoSDKError?) -> Unit)
/*
Get authentication status of sdk, when call this method, sdk will ask jwt token from app. If jwt is nil, sdk will always sent false
*/
fun getAuthStatus(completion: ((Boolean) -> Unit))
/*
Get currentLanguage using in sdk, when call this method, sdk will return language code (en, de, fr...) using in sdk
*/
fun getCurrentLanguage(completion: ((String) -> Unit))
/*
This method call to send push notification payload to SDK
message: notification payload
*/
fun processFcmMessageIfNeed(data: Map<String, Any?>?)
/*
This method to get SDKWidget fragment (Home, Transfer Center, more, support...). to use in the Fan App activity/fragment
Redirect functions
- type: screens from SDK (myTickets, transferCenter, deletedTicket, support)
- presentType:
+ present: show SDK with fullscreen (include close button)
+ embed: embed SDK UI in another UIViewController (hide close button)
*/
fun getSDKWidgetFragment(type: SDKWidget,
presentType: SDKPresentType = SDKPresentType.Present,
completionHandler: (TixngoSDKError?, FlutterFragment?) -> Unit)
/*
This method to get SDKWidget (Home, Transfer Center, more, support...).
Redirect functions
- type: screens from SDK (myTickets, transferCenter, deletedTicket, support)
- presentType:
+ present: show SDK with fullscreen (include close button)
+ embed: embed SDK UI in another UIViewController (hide close button)
*/
fun openSDKWidget(activity: Activity,
type: SDKWidget,
presentType: SDKPresentType = SDKPresentType.Present,
completionHandler: (TixngoSDKError?) -> Unit)
SDK Delegates
interface TixngoSDKDelegate {
// Notify to Native app after initialized SDK
// isAuthenticated: this param to return exist last session
fun onInitialized(isAuthenticated: Boolean)
// Notify to Native app whenever change aut fun didChangedAuthenticatedStatus(isAuthenticated: Boolean)
// Notify to Native app whenever jwttoken expired
fun onJWTTokenExpired(completion: (Boolean) -> Unit)
// Notify to Native app whenever SDK resused (max active session...)
fun onSDKDeviceRefused()
// Notify to Native app whenever SDK error
fun onSDKError(error: TixngoSDKError?)
// Notify to Native app tap on close SDK
fun onClosedSDK()
// Notify to Native app after changing frozen mode
fun didChangedFrozenMode(isFrozen: Boolean)
}
Demo for TIXNGO SDK
Check demo here: https://github.com/tixngo-mobile-github/tixngoAndroidDemo
How to change App ID and Environment
Change "appIds" to mobile app id (provided by TIXNGO)
Change "defaultEnv" to TixngoEnv.preprod or use TixngoManager.instance.setEnv(TixngoEnv.PREPROD)
Change OIDC configuration
AuthManager.initialize(applicationContext,
OIDCConfig(
authEndpoint = "authorization_end_point",
tokenEndpoint = "token_end_point",
clientID = "clientId",
redirectUri = "tixngo://auth",
grantType = "authorization_code",
clientSecret = "clientSecret",
scope = "scopes_list",
)
)
© TIXNGO 2023 - Login