Getting Started - iOS
Install and first steps
TIXNGO iOS SDK is a library written in Flutter & Swift. It a perfect fit for apps written in Swift as well.
It is distributed as a precompiled framework available on our GitHub repository, but it's possible to integrate iOS SDK using dependency managers like CocoaPods. If you prefer to do this manually, you will find instructions below as well.
Please be aware that if you want to use our SDK in your project, the minimum deployment target must be set to iOS 13.
CocoaPods
CocoaPods is currently one of the easiest ways to add TIXNGO iOS SDK to your project. If you haven't used it before, this tutorial from AppCoda should give you a good intro.
To integrate TIXNGO iOS SDK into your project, modify your Podfile
by adding/changing these lines:
# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'TIXNGODemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'sdk', :git => 'https://github.com/tixngo-mobile-github/tixngo_sdk_ios.git', :tag => '3.2515.2'
pod 'sdk-debug', :git => 'https://github.com/tixngo-mobile-github/tixngo_sdk_ios pod 'sdk-release', :git => 'https://github.com/tixngo-mobile-github/tixngo_sdk_ios.git', :tag => '3.2515.2', :configurations => ['Release']
pod 'FirebaseCore'
pod 'FirebaseMessaging'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
After that it's only a matter of running the pod install
command. The new Xcode Workspace will have TIXNGO iOS SDK already included.
Swift Package
In Xcode, add a package dependency and search for the package URL:
Copy
https://github.com/tixngo-mobile-github/tixngo_sdk_ios
For the Dependen4.2524.2
.
Finally, when asked, add the tixngo_sdk_debug
to your app debug target & tixngo_sdk_release
to your app release target.
tixngo_sdk_release
and tixngo_sdk_debug
must different target, need to use tixngo_sdk_release for make ipa or publish your app.
Now, you are all set to define your first Tixngo entities.
For using the SDK, please import Tixngo to call to the SDK
import Tixngo
Install the SDK manually
Add flutter dependency to project (drag and drop all .xcframework to “Framework, Libraries and Embedded Content” of project) as below
Please set FlutterPluginRegistrant.xcframework to 'Do not embed'
In the target’s build settings add Dir-To-Debug folder for Debug and Dir-To-Release folder for Release to Framework Search Paths
Add class utils files in folder Tixngo to Project (TixngoChannel, TixngoModel, TixngoManager, TixngoSDKError, TixngoTheme)
Permission configuration
iOS – Info.plist
Working with TIXNGO in iOS app requires an access to some resources that provide sensitive user data. In order to protect user privacy, an app needs to explicitly ask a permission to use them.
Location service: Use to ask permission for bluetooth ticket activation feature (if needed)
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysUsageDescription
Bluetooth service: Use to ask permission for bluetooth ticket activation feature (if needed)
NSBluetoothAlwaysUsageDescription
NSBluetoothPeripheralUsageDescription
Contact: Use to ask permission to get contact list (pick email for ticket transfer feature)
NSContactsUsageDescription
Initialization
In your AppDelegate: initialize TIXNGO SDK by calling TixngoManager.shared.initialize (call once time)
private func configTixngoSDK() {
let config = TixngoConfiguration(isEnableScreenshotSSK: true,
sskScope: SSPScope.sdk,
isEnableDebug: true,
defaultEnv: TixngoEnv.preprod,
isEnableWallet: false,
supportLanguages: [.en,
.ar],
defaultLanguage: .en,
theme: customLightTheme,
darkTheme: customDarkTheme,
appIds: CustomAppId(val: "mobile_app_key_val_environment",
preProd: "mobile_app_key_preProd_environment",
prod: "mobile_app_key_prod_environment"),
config: TixngoSDKConfig(isHaveMenu: false),
customDomain: TixngoCustomDomain(
valDomain: "api_domain_val_environment",
preProdDomain: "api_domain_preProd_environment",
prodDomain: "api_domain_prod_environment"),
tokenType: .idToken,
deeplinkPathPrefix: "sdk",
deeplinkHost: "https://r.tixngo.io"
)
TixngoManager.shared.initialize(config: config,
appIcon: UIImage(named: "AppIcon"),
renewalTokenTimeout: 30,
delegate: self)
}
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 overlays) from obscuring the QR code on ticket details. |
| 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)
To config fonts for TIXNGO from Native app, please follow this function
private func configFont() {
NativeFontPlugin.fontDataHandler = {familyName, weight, isItalic, callback in
if (familyName == "Qatar2022") {
var fileName: String = "Qatar2022-Regular.otf"
if (weight == FlutterFontWeight.weight700) {
fileName = "Qatar2022-Bold.otf"
} else if (weight == FlutterFontWeight.weight500) {
fileName = "Qatar2022-Medium.otf"
}
let data = NSData(contentsOf: URL(fileURLWithPath: Bundle.main.path(forResource: fileName, ofType: nil)!)) as? Data
callback(data)
return
}
callback(nil)
}
}
SDK delegate
extension AppDelegate: TixngoSDKDelegate {
func onInitialized(isAuthenticated: Bool) {
// SDK initialized
debugPrint("SDK => delegate => onInitialized => \(isAuthenticated)")
if (isAuthenticated) {
// push valid IDToken to the SDK
}
}
func didChangedAuthenticatedStatus(isAuthenticated: Bool) {
debugPrint("SDK => delegate => didChangedAuthenticatedStatus => \(isAuthenticated)")
}
func onJWTTokenExpired(completion: @escaping ExpiredTokenCompletionHandler)
debugPrint("SDK => delegate => onJWTTokenExpired")
AuthManager.shared.requestToken {[weak self] credential, error in
guard let `self` = self else { return }
if let newCredential = credential {
TixngoManager.shared.updateToken(token: newCredential.idToken) { error in
completion(true)
}
} else {
handleErrorForTokenFlow(error: error)
completion(true)
}
}
}
func onSDKDeviceRefused() {
debugPrint("SDK => onSDKDeviceRefused => SecurityToken refused")
}
func onSDKError(error: TixngoSDKError?) {
debugPrint("SDK => delegate => didChangedAuthenticatedStatus => \(String(describing: error?.code)) - \(String(describing: error?.message))")
}
func onClosedSDK() {
debugPrint("SDK => delegate => onClosedSDK")
}
func didChangedFrozenMode(isFrozen: Bool) {
debugPrint("SDK => delegate => didChangedFrozenMode => \(isFrozen)")
if isFrozen, let topController = TixngoAppContext.topViewController() {
UIAlertController.show(topController,
title: "Frozen Mode!!!",
message: "The ticket service is currently unavailable due to ongoing maintenance or system updates.")
}
}
}
TIXNGO SDK page (exposed functions)
/*
This method is call one time to setup default config and listen callback from the TIXNGO SDK
*/
public final func initialize(config: TixngoConfiguration?,
delegate: TixngoSDKDelegate?)
/*
This method to sign out SDK when user do signout in app
*/
public final func signOut(_ completionHandler: SDKCompletionHandler? = nil)
/*
This method should be call after login successfully in the FanApp (sync data to SDK and signin to SDK)
*/
public final func updateToken(token: String?, _ completionHandler: SDKCompletionHandler? = nil)
/*
This method should be call after SDK initialized
*/
public final func updateFCMToken(fcmToken: String?, _ completionHandler: SDKCompletionHandler? = nil)
/*
This method is call when the Fan App want to change theme in SDK
*/
public final func changeTheme(themeMode: SDKThemeMode = .system, lightTheme: SDKTheme?, darkTheme: SDKTheme?)
/*
This method is call when the Fan App want to change language in SDK.
*/
public final func changeLanguage(language: TixngoLanguage, _ completionHandler: SDKCompletionHandler? = nil)
/*
This method is call when the Fan App want to change environment in SDK.
*/
public final func changeEnv(env: TixngoEnv, _ completionHandler: SDKCompletionHandler? = nil)
/*
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
*/
public final func getAuthStatus(_ completion: @escaping ((_ isAuthenticated: Bool) -> Void))
/*
Get currentLanguage using in sdk, when call this method, sdk will return language code (en, de, fr...) using in sdk
*/
public final func getCurrentLanguage(_ completion: @escaping ((_ lang: String) -> Void))
/*
This method call to send push notification payload to SDK
message: notification payload
*/
public final func processFcmMessageIfNeed(_ message: [String: Any])
/*
This method to get current widget in SDK
*/
public final func getCurrentPage() -> UIViewController
/*
This method to get SDKWidget (Home, Transfer Center, more, support...). discuss more
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)
- completionHandler: result with error or UIViewController*/
public final func getSDKScreen(type: SDKWidget, presentType: SDKPresentType = .present, completionHandler: SDKViewControllerHandler?)
Demo for TIXNGO SDK
Check demo at: https://github.com/tixngo-mobile-github/tixngo_ios_demo
*** Note: Before use TixngoSDK, the existing app needed to register BundleID (ios) and appBundle(android) with tixngo team. We use it in order to get configs.
How to change App ID and Environment (To Fanapp)
Change "appIds" to [specific_appid: provided by TIXNGO]
Change "defaultEnv" to TixngoEnv.preprod or use TixngoManager.instance.setEnv(.preprod) (or TixngoEnv.prod)
With this version we applied ping SSO for Login (please
© TIXNGO 2023 - Login