TWSFactory

@Singleton
object TWSFactory

A factory for creating and managing instances of TWSManager.

This factory uses a WeakHashMap to cache instances of TWSManager associated with specific tags. Instances are stored as weak references, meaning they will be automatically cleared by the garbage collector when they are no longer in use, ensuring memory efficiency.

Prerequisite: tws-service.json

To use the TWSManager, ensure you have the required tws-service.json configuration file.

  1. Generate tws-service.json and associate it with your TWS account

  2. Place the tws-service.json file in the app module's root directory or the root directory of your desired flavor.

Example Directory Structure:

/app
├── src
│ ├── main
│ │ ├── tws-service.json
│ │ └── AndroidManifest.xml
│ └── flavorName
│ ├── tws-service.json
│ └── AndroidManifest.xml

Functions

Link copied to clipboard
fun get(context: Context): TWSManager

Retrieves a TWSManager instance for the default configuration, which is created using metadata from the application's manifest.

fun get(tag: String): TWSManager?

Retrieves an existing TWSManager instance by its tag, if available.

fun get(context: Context, configuration: TWSConfiguration.Basic): TWSManager

Retrieves a TWSManager instance for a custom TWSConfiguration.Basic.

fun get(context: Context, configuration: TWSConfiguration.Shared): TWSManager

Retrieves a TWSManager instance for a custom TWSConfiguration.Shared.