Module Cafeyn Group SDK

Bring press content into an Android app: browse publications, issues, articles and videos, download issues for offline reading, and open them in a full reader — with or without the SDK's own screens.

Pick a module from the list at the bottom of this page to browse its API.

Modules

Module Artifact What it gives you
core co.cafeyn.cgs:core Content catalogue, authentication, downloads, reading state. No UI.
reader co.cafeyn.cgs:reader The issue and article reader, opened as an Activity.
ui co.cafeyn.cgs:ui Ready-made Jetpack Compose screens and the design system that themes them.

reader depends on core, and ui depends on both — depending on ui pulls the whole SDK in. Take core alone to build your own interface on top of the catalogue.

Getting started

1. Declare your license

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

You can pass the key to SdkConfig.Builder.apiKey instead if you would rather keep it out of the manifest.

2. Initialize once, at startup

class MyApp : Application() {
override fun onCreate() {
super.onCreate()
CGS.init(
SdkConfig.Builder(this)
.environment(CgsEnvironment.PRODUCTION)
.productName("YOUR_PRODUCT_NAME")
.onSessionLost { /* re-authenticate */ }
.build()
)
}
}

Calling any other entry point before this throws InitializationException.

3. Authenticate

CGS.auth().authenticate(hostToken = yourBackendToken)
CGS.auth().setCurrentProfile(profileId)

CgsAuth.state tells you where the session stands, and onSessionLost fires if it is ever dropped for good.

4. Read the catalogue

val publications = CGS.content().publications.all(scope = viewModelScope)

publications.state.collect { state ->
render(state.items)
if (state.canLoadMore) publications.loadNextPage()
}

Every accessor is scoped to the active profile and restarts on its own when that profile or the language changes — see Content in the core module.

5. Download and open an issue

val item = CGS.download().issue(issueId)
item.start()

item.state.collect { if (it is Download.Item.State.Downloaded) CGS.reader().open(activity, item) }

6. Or drop in a screen

CgsTheme(colorScheme = cgsColorScheme(isSystemInDarkTheme())) {
PublicationScreen(publicationId = id) { event ->
when (event) {
is PublicationEvent.ClickOnIssue -> CGS.reader().open(activity, download, event.page)
// …
}
}
}

Conventions across the API

  • One-shot calls that can fail return CgsResult — Success or Failure(CgsError). They do not throw.

  • Observed single items come back as a StateFlow of CgsStreamState, which can carry stale data alongside a refresh or a failure.

  • Lists come back as a PaginatedResource: observe state, call loadNextPage().

  • Exceptions are reserved for integration mistakes — a missing license, a call before init. They are meant to be fixed, not caught.

  • Anything under a .internal package, or marked @InternalCGSApi, is not part of this contract and is absent from these pages.

All modules:

Link copied to clipboard

The catalogue, the session and the downloads — everything the SDK does that isn't drawing.

Link copied to clipboard

The reading experience: an issue rendered page by page, or an article rendered as text.

Link copied to clipboard

Ready-made Jetpack Compose screens, and the design system that themes them.