Skip to Content

Quickstart

Add the API key to your manifest:

<application> <meta-data android:name="app.onesygnal.API_KEY" android:value="YOUR_API_KEY" /> </application>

Then, from an Activity (or anywhere with a Context):

import io.onesygnal.sdk.api.OneSygnal OneSygnal.initialize(this) { success -> if (!success) return@initialize // key missing/blank, or init failed — see Troubleshooting OneSygnal.track("page_viewed") OneSygnal.identify("user_123") { identified -> // identified reflects whether identify() actually succeeded } }

That’s it — surveys matching your active trigger rules render automatically as a window overlay above your app’s content.

Pass the Activity, not applicationContext, if you call initialize() after the Activity has already resumed (e.g. from a button tap rather than Application.onCreate()) — the SDK seeds its activity tracker from whatever Context you pass, and a plain applicationContext gives it nothing to seed from, silently breaking every survey trigger until the Activity happens to pause and resume again.

initialize()’s completion fires once config/user/surveys are fully fetched and settled — not immediately on call. If you’re already inside a coroutine, use the suspend variant instead:

val success = OneSygnal.initializeAwait(context)

See Configuration for setApiKey()/setLocale(), and API Reference for every method and its suspend counterpart.