CGS

object CGS

The SDK's entry point: initialize it here, then reach every service from here.

Initialization

init must run once, before anything else — typically from Application.onCreate:

CGS.init(
SdkConfig.Builder(applicationContext)
.environment(CgsEnvironment.PRODUCTION)
.apiKey("YOUR_LICENSE_KEY") // or via the manifest
.productName("YOUR_PRODUCT_NAME")
.build()
)

Calling it a second time is a no-op: the first configuration stands.

License resolution

The license is looked up in this order:

  1. SdkConfig.Builder.apiKey, if you set one

  2. the co.cafeyn.cgs.license <meta-data> entry in your AndroidManifest.xml

Neither found means MissingLicenseException. To declare it in the manifest:

<application ... >
<meta-data
android:name="co.cafeyn.cgs.license"
android:value="YOUR_LICENSE_KEY" />
</application>

The services

authOpening a session and choosing the active profile
contentPublications, issues, articles, videos, media
downloadFetching issues for offline reading
readingsHow far into each issue the reader got
readingListIssues saved for later

Each returns the same instance every time, so there is nothing to hold on to:

val publications = CGS.content().publications

Reaching for any of them before init throws InitializationException.

Functions

Link copied to clipboard
fun auth(): CgsAuth

The authentication service: opening a session from your own backend token, and choosing the active profile.

Link copied to clipboard

The content service: publications, issues, articles, videos and media, scoped to the active profile.

Link copied to clipboard

The download service: fetching issues for offline reading, and following their progress.

Link copied to clipboard
fun init(config: SdkConfig)

Initializes the SDK. Call once, as early as possible — Application.onCreate is the natural place.

Link copied to clipboard

Whether init has already run.

Link copied to clipboard

The reading-list service: issues the user saved for later.

Link copied to clipboard

The reading-progress service: how far into each issue the reader got.

Link copied to clipboard
fun shutdown()

Shuts the SDK down: cancels its in-flight work, releases what it holds, and leaves it uninitialized.