Janus SDK Mobile Documentation
Introduction
Janus SDK enables mobile applications to implement privacy consent management features with minimal development effort. The SDK is available for Android, iOS, and Flutter, providing a consistent API across platforms while respecting platform-specific conventions.
With the Janus SDK, you can:
- Show privacy notices and consent experiences to your users
- Manage and track user consent decisions
- Integrate consent management with web content
- Handle region-specific privacy requirements
- Simplify privacy compliance for your mobile app
This documentation covers common concepts that apply across all platforms, as well as links to platform-specific implementation details.
Common Concepts
Core Features
All Janus SDK implementations provide the following core features:
- Privacy Experience Display: Show a user-friendly interface for privacy preferences, similar to Fides' web-based consent management
- Consent Management: Store and retrieve user consent choices
- Region Detection: Automatically determine the user's region for regulatory compliance
- WebView Integration: Synchronize consent preferences with web content
- Event System: Listen for and respond to consent-related events
- Helper Methods: Utility methods that allow for more customized approaches to managing consent
Installation
Each platform has a specific installation process. Please refer to the platform-specific implementation guides for detailed instructions:
- iOS Implementation Guide (opens in a new tab)
- Android Implementation Guide (opens in a new tab)
- Flutter Implementation Guide (opens in a new tab)
Initialization
Before using any Janus SDK features, you must initialize the SDK early in your app's lifecycle. The initialization process requires:
Required Configuration Values:
apiHost
: The base URL of your FidesPlus API serverpropertyId
: Your app's property identifier
Optional Configuration Values:
privacyCenterHost
: Privacy Center host URL (defaults to apiHost if not provided)ipLocation
: Whether to use IP-based geolocation (default: true)region
: Fallback region code (format: "US-CA")fidesEvents
: Whether to map Janus events to FidesJS events in WebViews (default: true)autoShowExperience
: Whether to automatically show the privacy experience after initialization (default: true)
You can obtain the apiHost
, propertyId
, and privacyCenterHost
from your Ethyca account manager, if you don't have them already.
For platform-specific initialization code, please refer to the implementation guides linked above.
Privacy Experience Management
By default, Janus automatically shows the privacy experience after successful initialization, given you have a privacy experience configured for the given region.
If you wish to customize the user experience flow outside of this default, the SDK provides helpful methods to manage when and how the privacy experience is displayed to users.
Refer to the platform-specific implementation guides for details on how to manage the privacy experience display.
Consent Management
The SDK provides methods to access and manage user consent choices:
- Get consent values for specific categories
- Access all consent choices
- Get the Fides string for integration with ad networks
- Subscribe to consent events for updates
Region Detection
The SDK provides region detection capabilities for privacy compliance:
- IP-based region detection
- Manual region override
- Region format following ISO 3166-2 standard (e.g., "US-CA" for California, United States)
WebView Integration
The SDK provides specialized WebView integration to synchronize consent preferences with web content:
- Create WebView instances with consent management integration
- Automatic consent synchronization
- Resource management utilities
Advanced Usage
Consent Event Handling
Subscribe to consent events to be notified when the user updates their preferences:
Android Example:
// Listen for consent events
listenerId = Janus.addConsentEventListener { event ->
when (event.eventType) {
JanusEventType.EXPERIENCE_SELECTION_UPDATED -> {
// Do something
}
// Handle other events...
}
}
// Remove listener when no longer needed
Janus.removeConsentEventListener(listenerId)
Full list of event.type
:
EXPERIENCE_SHOWN
EXPERIENCE_INTERACTION
EXPERIENCE_CLOSED
EXPERIENCE_SELECTION_UPDATING
EXPERIENCE_SELECTION_UPDATED
WEBVIEW_FIDES_INITIALIZING
WEBVIEW_FIDES_INITIALIZED
WEBVIEW_FIDES_UI_SHOWN
WEBVIEW_FIDES_UI_CHANGED
WEBVIEW_FIDES_MODAL_CLOSED
WEBVIEW_FIDES_UPDATING
WEBVIEW_FIDES_UPDATED
CONSENT_UPDATED_FROM_WEBVIEW
Manual Experience Control
If you want to manually control when the privacy experience is shown:
-
Disable automatic display in the configuration:
autoShowExperience: false
-
Check if the experience should be shown and display it at the appropriate time:
// Android if (Janus.shouldShowExperience) { Janus.showExperience(activity) }
SDK Interface Reference
Key Methods/Properties:
initialize(config, callback)
: Configures the SDK and provides platform-specific callbacks for when Janus is initialized or aJanusError
. After inititialization, any privacy experience that matches the region and property ID will automatically be shown.currentExperience
: Gets the current privacy experience.hasExperience
: True when there is an experience available for the current region and propertyId.shouldShowExperience
: A boolean indicating whether the privacy experience should be shown to the user. Returns true if a valid experience exists and the users consent is not present or not valid.showExperience()
: Display the consent management interface to the user ifhasExperience
is true.getLocationByIPAddress(callback)
: Performs IP-based location detection and provides the resulting location data through the callback.region
: Returns the region code currently being used by the SDK after initialization.listenerId = addConsentEventListener(listener)
: Attaches to events emitted during key user interactions.removeConsentEventListener(listenerId)
: Removes an event listener.createConsentWebView()
: Creates a platform-specific webview that synchronizes consent state with your mobile application as well as bidirectional support of Events with FidesJS.releaseConsentWebView(webView)
: Properly releases a WebView created withcreateConsentWebView()
to prevent memory leaks. Always call this when you're done with a WebView.consent
: Provides the current state of the user's current consent preferences.consentMetadata
: An object containing metadata about the consent, including:createdAt
: A timestamp indicating when the consent was created.updatedAt
: A timestamp indicating when the consent was last updated.consentMethod
: A string indicating how the consent was provided (e.g., "save", "dismiss").fides_string
: The user's current consent string(s) combined into a single value.clearConsent(clearMetadata)
: Clears all consent data. The optionalclearMetadata
parameter (default: false) determines whether to also clear consent metadata.