Configuration
  • 17 Aug 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Configuration

  • Dark
    Light

Article summary

Android

Configure TMAuthentication first, then TMTickets.

Example Kotlin code:

authentication = TMAuthentication.Builder()
    .apiKey(consumer_key)
    .clientName(client_name) // Team name to be displayed
    .colors(createTMAuthenticationColors(brandingColor))
    .environment(TMXDeploymentEnvironment.Production) // Environment that the SDK will use. Default is Production
    .region(TMXDeploymentRegion.US) // Region that the SDK will use. Default is US
    .build(activity)
    
TicketsSDKClient
    .Builder()
    .authenticationSDKClient(authentication) //Authentication object
    //Optional value to define the colors for the Tickets page
    .colors(TicketsColors(LightColorPalette, DarkColorPalette))
    //Function that generates a TicketsSDKClient object
    .build(Activity)
    .apply {
        //After creating the TicketsSDKClient object, add it into the TicketsSDKSingleton
        TicketsSDKSingleton.setTicketsSdkClient(this)
}
    
private fun createTMAuthenticationColors(color: Int):    TMAuthentication.ColorTheme =
    TMAuthentication.ColorTheme(
    // The Color class is part of the Compose library
        lightColors(
            primary = Color(color),
            primaryVariant = Color(color),
            secondary = Color(color),
            onPrimary = Color.White // Color used for text and icons displayed on top of the primary color.
        ),
        darkColors(
            primary = Color(color),
            primaryVariant = Color(color),
            secondary = Color(color),
            onPrimary = Color.White // Color used for text and icons displayed on top of the primary color.
        )
    )

iOS

Configure TMAuthentication first, then TMTickets.

Example Swift code:

import Foundation
import TicketmasterAuthentication
import TicketmasterTickets

class Example: NSObject {

    func configure() {
        // build a combination of Settings and Branding
        let tmxServiceSettings = TMAuthentication.TMXSettings(apiKey: "12345",
                                                              region: .US)
        
        let branding = TMAuthentication.Branding(displayName: "My Team",
                                                 backgroundColor: .red,
                                                 theme: .light)
        
        let brandedServiceSettings = TMAuthentication.BrandedServiceSettings(tmxSettings: tmxServiceSettings,
                                                                             branding: branding)
        
        // configure TMAuthentication with Settings and Branding
        print("Authentication SDK Configuring...")
        TMAuthentication.shared.configure(brandedServiceSettings: brandedServiceSettings) { backendsConfigured in
            // your API key may contain configurations for multiple backend services
            // the details are not needed for most common use-cases
            print(" - Authentication SDK Configured: \(backendsConfigured.count)")
            
            // TMTickets inherits it's configuration and branding from TMAuthentication
            print("Tickets SDK Configuring...")
            TMTickets.shared.configure {
                // Tickets is configured, now we are ready to present TMTicketsViewController or TMTicketsView
                print(" - Tickets SDK Configured")
                
            } failure: { error in
                // something went wrong, probably TMAuthentication was not configured correctly
                print(" - Tickets SDK Configuration Error: \(error.localizedDescription)")
            }
            
        } failure: { error in
            // something went wrong, probably the wrong apiKey+region combination
            print(" - Authentication SDK Configuration Error: \(error.localizedDescription)")
        }
    }
}

Important Note

Many Apps use a single API Key because the App only supports a single Team, Artist, or Venue.
However, you may want your App to support multiple API keys (for example a Venue App with multiple Home Teams, or an App that covers many Team in the league).
If so, you must enable ephemeral browsing for login.
see Switching Teams without Logging Out


Was this article helpful?

What's Next