RelayRemoteSettingsClientProtocol
public protocol RelayRemoteSettingsClientProtocol : AnyObject, Sendable
Client for fetching Relay data from Remote Settings
This struct holds separate Remote Settings clients for the allowlist and denylist collections. It follows the same pattern as SuggestRemoteSettingsClient.
-
Determines whether Firefox Relay should be offered for a given site.
This function implements the Relay visibility decision logic based on three factors:
- Whether the site is on the denylist
- Whether the user is an existing Relay user
- Whether the site is on the allowlist
# Decision Logic (in order)
- If the site is on the denylist, don’t show Relay (regardless of user status)
- If the site is NOT on the denylist and the user is a Relay user, show Relay
- If the site is NOT on the denylist and the user is not a Relay user, check the allowlist:
- If the site is on the allowlist, show Relay (to promote Relay to new users)
- Otherwise, don’t show Relay
# Fail-Safe Behavior
If Remote Settings is unavailable:
- If denylist fetch fails: don’t show Relay (conservative: avoid showing on potentially blocked sites)
- If allowlist fetch fails for non-Relay users: assume empty (conservative: don’t promote without data)
# Arguments
host- The full hostname (e.g., “mail.google.com”, “www.example.com”)domain- The registrable domain from PSL (e.g., “google.com”, “example.co.uk”)is_relay_user- Whether the user already has a Relay account
# Public Suffix List (PSL)
Mobile clients should use PSL to extract the domain:
- Host: Full hostname like “mail.google.com”
- Domain: Registrable domain (eTLD+1) like “google.com”
- Swift: Use
URL.hostand extract domain via PSL library - Kotlin: Use
URL.hostand extract domain via PSL library
# Returns
trueif Relay should be shown for this site,falseotherwise# Determining if User is a Relay User
Mobile clients should check if the user is a Relay user by calling
FirefoxAccount.getAttachedClients()and checking if Relay is in the list of attached clients.# Example
val url = URL("https://mail.google.com/inbox") val host = url.host // "mail.google.com" val domain = PublicSuffixList.getRegistrableDomain(host) // "google.com" val rsClient = RelayRemoteSettingsClient(remoteSettingsService) val attachedClients = fxAccount.getAttachedClients() val isRelayUser = attachedClients.any { it.clientId == RELAY_CLIENT_ID } if (rsClient.shouldShowRelay(host, domain, isRelayUser)) { // Show Relay UI }Declaration
Swift
func shouldShowRelay(host: String, domain: String, isRelayUser: Bool) -> Bool