getBoolean

open fun getBoolean(key: String, defaultValue: Boolean): Boolean

Retrieves a boolean tag value by name, with a fallback default value.

Returns the boolean value associated with the given key. If the tag doesn't exist or is not a boolean type, returns the provided default value. Use this for feature flags, subscription status, or any true/false attribute.

Example (Feature Access Control):


TagsBundle tags = getUserTags();

boolean isPremium = tags.getBoolean("premium_member", false);
boolean pushEnabled = tags.getBoolean("push_notifications", true);
boolean emailSubscribed = tags.getBoolean("email_subscribed", false);
boolean betaAccess = tags.getBoolean("beta_features_enabled", false);

// Control feature access
if (isPremium) {
    unlockPremiumFeatures();
}

// Respect notification preferences
if (pushEnabled) {
    scheduleNotification();
}

Return

tag value as boolean, or defaultValue if tag is not found or not a boolean

Parameters

key

tag name (e.g., "premium_member", "push_enabled", "trial_active")

defaultValue

value to return if tag doesn't exist or is not a boolean