Configuring the SDK
Initialize the Rovenue SDK once at startup before making any other calls.
configure is the single entry point for the SDK. Call it once at app startup,
before any other Rovenue method. Every other method is invalid until
configure has run.
Calling any other SDK method before configure has run is a programming error,
not a runtime condition to catch — on iOS it's a hard crash (not a throwable
error), and on Android it throws a plain, non-RovenueException
IllegalStateException. See Calling the SDK before
configure() for the
full per-platform breakdown. Put configure at the earliest possible entry
point — App.tsx on React Native, AppDelegate.application(_:didFinishLaunchingWithOptions:)
on iOS, or Application.onCreate() on Android — to make this impossible to get wrong.
Types on this page
type RovenueConfig = {
apiKey: string; // your public SDK key (rov_pk_live_… or rov_pk_test_…)
baseUrl?: string; // optional — defaults to https://api.rovenue.io
logLevel?: 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace'; // default 'warn'
appVersion?: string; // overrides the platform manifest value
};| Field | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your public SDK key (rov_pk_test_…). Never use the secret key in the app. |
baseUrl | string | No | Your Rovenue API base URL. Defaults to the hosted endpoint https://api.rovenue.io; override only when self-hosting. |
logLevel | 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | No | Verbosity of SDK logs. Defaults to 'warn' — turn up to 'info'/'debug' locally, never ship 'debug'/'trace' in production. |
appVersion | string | No | App version string. Auto-read from the platform manifest — only override for standalone JVM builds. |
Swift and Kotlin mirror these with platform-idiomatic parameter labels. See Types.
Setting up
Find your API key
Open your Rovenue dashboard, navigate to your
project, and copy the public SDK key. It starts with rov_pk_live_ for Production or rov_pk_test_ for Sandbox.
Never embed your secret key (rov_sk_…) in the app binary. Secret keys
are for server-to-server calls only. See Methods — Configuration.
Use a Sandbox key (rov_pk_test_…) in debug builds, Xcode StoreKit testing and store sandbox testing, and a Production key (rov_pk_live_…) in release builds. The examples on this page use a Sandbox key. A release build configured with a Sandbox key fails configure with a SandboxKeyInRelease error (SANDBOX_KEY_IN_RELEASE on Kotlin) on iOS, Android, React Native and Flutter; the web SDK logs a console warning instead. For an internal or TestFlight-style build that deliberately talks to Sandbox, Swift and Kotlin accept dangerouslyAllowSandboxKeyInRelease: true.
Call configure at startup
Pass a RovenueConfig object (React Native) or named parameters (Swift /
Kotlin) at the very first line of your app's lifecycle hook.
import { Rovenue } from '@rovenue/react-native-sdk';
Rovenue.configure({
apiKey: 'rov_pk_test_...',
logLevel: 'info', // optional — turn up from the 'warn' default in dev
appVersion: '1.2', // optional — inferred from app.json by default
});import Rovenue
// AppDelegate.application(_:didFinishLaunchingWithOptions:)
Rovenue.configure(
apiKey: "rov_pk_test_...",
logLevel: .info, // optional — turn up from the .warn default
appVersion: "1.2" // optional — inferred from CFBundleShortVersionString
)For the Sandbox-key guard, a build is not release when the package
was compiled with DEBUG, when it runs on the simulator, or when the app
is development-signed (its embedded.mobileprovision grants
get-task-allow, as a build run from Xcode does). Xcode compiles a Swift
package without DEBUG under any build configuration not named "Debug",
so a custom configuration (Staging, Dev) whose app is not
development-signed (ad-hoc, enterprise, TestFlight) counts as release. If
such a build must talk to Sandbox, pass
dangerouslyAllowSandboxKeyInRelease: true.
import dev.rovenue.sdk.Rovenue
// Application.onCreate()
Rovenue.configure(
apiKey = "rov_pk_test_...",
logLevel = LogLevel.INFO, // optional — turn up from the LogLevel.WARN default
appVersion = "1.2", // optional — inferred from versionName
context = this, // Play Billing and the Sandbox-key guard read it
)The Sandbox-key guard reads the app's FLAG_DEBUGGABLE from context, so
it cannot run without one: a configure call with no context counts as
debug and lets a Sandbox key through even in a release build. Always pass
context in an Android app.
Self-hosting? Pass baseUrl to point the SDK at your own deployment, e.g. RN Rovenue.configure({ apiKey: 'rov_pk_test_...', baseUrl: 'https://api.acme.com' }), Swift Rovenue.configure(apiKey: "rov_pk_test_...", baseUrl: "https://api.acme.com"), Kotlin Rovenue.configure(apiKey = "rov_pk_test_...", baseUrl = "https://api.acme.com"). The host must use https:// — plain http:// is accepted only for localhost during local development.
Verify the singleton is ready
After configure, all SDK methods become available. On iOS and Android,
subsequent calls go through the shared singleton (Rovenue.shared). On React
Native they go directly through the Rovenue namespace.
import { Rovenue } from '@rovenue/react-native-sdk';
// Smoke-check: log the SDK version
console.log('Rovenue SDK', Rovenue.getVersion());// Smoke-check: log the SDK version
print("Rovenue SDK", Rovenue.shared.getVersion())// Smoke-check: log the SDK version
println("Rovenue SDK ${Rovenue.shared.getVersion()}")configure is a static entry point. On iOS and Android it initialises
the shared singleton; every method afterwards is called on that instance
(Rovenue.shared.entitlement(…) in Swift/Kotlin), or directly on Rovenue
in React Native.
(Optional) Attach a log handler
Set a custom log handler immediately after configure to route SDK logs into
your own logging infrastructure.
import { Rovenue } from '@rovenue/react-native-sdk';
Rovenue.setLogHandler((entry) => {
myLogger.log(entry.level, entry.message);
});Rovenue.shared.setLogHandler { entry in
myLogger.log(level: entry.level, message: entry.message)
}Rovenue.shared.setLogHandler { entry ->
myLogger.log(entry.level, entry.message)
}Platform defaults for appVersion
| Platform | Source |
|---|---|
| iOS / Expo | CFBundleShortVersionString / app.json |
| Android | versionName in build.gradle |
| Standalone JVM SDK | No manifest — provide the value explicitly |
Next steps: After configuring the SDK, identify the logged-in user with
identify() and check their entitlements
with entitlement(). See also:
Methods — Configuration.
Core Concepts
The mental model behind the Rovenue SDK — two IDs, cache-first reads, the change stream, and how purchases flow.
Server-side API
Call Rovenue from your own backend with the project's secret key — authentication, which routes need which key, addressing a subscriber, errors, rate limits, retries, and verifying project webhooks.