Android SDK

Overview of the Android SDK for Fans United platform

Welcome to the FansUnited Android SDK. This SDK is implemented on Kotlin programming language and it works for native Android apps written both in Java and/or Kotlin.

The SDK has complete coverage of the Fans United APIs and it's split into different namespaces depending on what you want to achieve.

Operations supported by the SDK:

  • Profile Operations
  • Football Operations
  • Predictor Operations
  • Top X Operations
  • Match Quiz Operations
  • Loyalty Operations
  • Activity Operations

Add FansUnited SDK to your app

From within Android Studio, open your app. In the app build.gradle file add the dependency.

dependencies {  
    ...  
    implementation  'com.fansunitedmedia.sdk:android:x.y.z'  
  	...
}

After adding the dependency, sync your Android project with Gradle files.

Use the SDK in your app

The SDK comes with a configuration and an interface. The client needs to implement this interface and pass the implementation in the config.

Important: This SDK is implemented using Kotlin coroutines on Android. All functions are suspendfunctions in other words such functions can be blocking. More information of how to invoke suspend functions from non-coroutines scope including examples can be found on Advanced coroutines concepts page.

Initialize the SDK

Initialize the sdk in your Android app by calling: FansUnitedSDK.init(config)

 
class MainActivity : AppCompatActivity() {  
      
        override fun onCreate(savedInstanceState: Bundle?) {  
            super.onCreate(savedInstanceState)  
      
            val tokenProvider = AuthenticationProvider()  
            CoroutineScope(Dispatchers.IO).launch {  
                val sdk = FansUnitedSDK.init(  
                    FUSDKConfig(  
                        apiKey = "your-api-key-here",  
                        clientId = "your-client-id-here",  
                        lang = "bg|en|ro", // default: en  
                        idSchema = "NATIVE|ENETPULSE|SPORTRADAR|SPORTAL365", // default: IDSchema.NATIVE,  
                        environment = "dev|staging|prod", // default: prod 
                        authProvider = tokenProvider
                        disabledIdsCaching = true/false // optional, default: false; If true - always fetch entities ids from backend without any caching 
                    )  
                )  
      
                val teamById = sdk.football().getTeamById(...)  
                val teams = sdk.football().getTeams()
              	val profile = sdk.profile().getOwn()

                ...
            }  
	    }  
      
        class AuthenticationProvider : IFUSDKTokenProvider {  
            override fun getToken() = ""  
            override fun logout() {}  
        }  
    }