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 keeps the first configuration, but still validates the new one and throws if it is invalid.

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
readerOpening an issue, or an article, in the reader

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
fun reader(): Reader

The reader: an issue rendered page by page, or an article rendered as text, each opened as a full-screen Activity of its own.

Link copied to clipboard
fun shutdown()

Shuts the SDK down: cancels its in-flight content requests and leaves it uninitialized.