For AI agents: visit https://docs.fansunitedmedia.com/llms.txt for an index of all pages formatted in Markdown and endpoints in OpenAPI.
- Initialize the SDK once in your app's lifecycle (AppDelegate or App struct)
- Store the SDK instance for reuse throughout the app
- Handle initialization errors gracefully
- Use
[weak self] in completion handlers to avoid retain cycles
- Properly manage SDK instances and avoid creating multiple instances
- Always update UI on the main thread
- SDK callbacks may come on background threads
- Use
DispatchQueue.main.async for UI updates
- Use the
disableCache parameter appropriately
- Enable caching for frequently accessed data
- Disable caching for real-time data
- Always handle errors in completion handlers
- Provide user-friendly error messages
- Implement retry mechanisms for network failures
- Use filters to limit data requests
- Implement pagination for large datasets
- Cache responses when appropriate
class AuthProvider: IFUSDKTokenProvider {
func getToken() async throws -> String? {
// Implement your authentication logic
// Return JWT token or similar
}
func logout() async throws {
// Handle logout cleanup
}
}
let config = FUSDKConfig(
apiKey: "your-api-key",
clientId: "your-client-id",
lang: "en",
idSchema: IDSchema.sportal365,
environment: "prod",
authProvider: AuthProvider()
)
let sdk = FansUnitedSDK.Companion.shared.doInit(config: config)
// Create filters
let filters = MatchFilters(
countryIds: nil,
competitionIds: nil,
matchIds: nil,
status: nil,
teamIds: nil,
fromDate: todayInstant,
toDate: nil,
limit: 50,
page: nil,
sortField: nil,
sortOrder: nil
)
// Fetch data directly from SDK
let matches = try await sdk.football().getMatches(filters: filters, disableCache: false)?.data