withAndroidStorage

fun TrustPinConfiguration.withAndroidStorage(context: ERROR CLASS: Symbol not found for Context): TrustPinConfiguration

Programmatic Android setup — wires this configuration to the Android Context and returns the same instance.

This is one of the two recommended Android setup paths. Use it when you build the configuration in code (credentials come from runtime config, an MDM channel, A/B-test routing, etc.) instead of from a bundled trustpin.json. The other recommended Android path is TrustPinConfiguration.fromAssets, which calls this function internally.

Skipping this call (or fromAssets(context)) on Android still works but degrades the security profile of the instance. The SDK records this via a one-shot info log. Always chain this on Android.

⚠️ Single-use contract — do not reuse a decorated configuration

A configuration decorated with withAndroidStorage(context) MUST be passed to exactly one TrustPin.setup call. The decoration is bound to this exact configuration instance and is consumed by the first setup. Reusing the same configuration for a second setup silently downgrades that subsequent instance.

// ✓ Correct — one configuration per setup, each decorated separately.
val payments = TrustPinConfiguration(orgId, projId, publicKey)
.withAndroidStorage(context)
TrustPin.instance("payments").setup(payments)

val analytics = TrustPinConfiguration(orgId, projId, publicKey)
.withAndroidStorage(context)
TrustPin.instance("analytics").setup(analytics)

// ✗ Wrong — second setup silently downgrades.
val shared = TrustPinConfiguration(orgId, projId, publicKey)
.withAndroidStorage(context)
TrustPin.default.setup(shared)
TrustPin.instance("payments").setup(shared) // <- downgraded!

The same rule applies to TrustPinConfiguration.fromAssets: each call returns a freshly decorated configuration suitable for one setup. Call fromAssets again to get a fresh configuration for a second instance.

Usage

From Kotlin:

val config = TrustPinConfiguration(orgId, projId, publicKey)
.withAndroidStorage(context)
TrustPin.setup(config)

From Java:

TrustPinConfiguration config = TrustPinConfigurationAndroid.withAndroidStorage(
new TrustPinConfiguration(orgId, projId, publicKey, TrustPinMode.STRICT, null),
context
);
TrustPin.getDefault().setupBlocking(config);

Return

The same TrustPinConfiguration instance, decorated and ready for one setup call.

Parameters

context

Any Android Context; context.applicationContext is captured.