Files
buzz/mobile/ios/BuzzPushKit/Sources/BuzzPushKit/BuzzAgeSignalPayload.swift
Tom Brow 779af8886c fix(mobile): fail open when age checks are unavailable (#7714)
Age-check errors previously blocked Buzz startup. Normal app startup now
proceeds immediately; only a valid under-18 response from the current
launch request can restrict access.

Age check enforcement remains disabled at compile time by default.
Builds can opt in with `--dart-define=BUZZ_AGE_GATING_ENABLED=true`.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-09-17 16:44:08 -07:00

14 lines
673 B
Swift

import Foundation
/// Converts Apple's age gates to the inclusive upper age used by Flutter.
public enum BuzzAgeSignalPayload {
/// Apple's upper bound is the gate the person is under; nil means unbounded.
public static func sharing(exclusiveUpperBound: Int?, lowerBound: Int? = nil) -> [String: Any] {
// Buzz requests only the 18-year gate. Unexpected bounds are not evidence
// of minority; never subtract an unvalidated integer (including Int.min).
let validLower = lowerBound.map { $0 >= 0 && $0 < 18 } ?? true
let ageUpper: Any = exclusiveUpperBound == 18 && validLower ? 17 : NSNull()
return ["status": "signal", "ageUpper": ageUpper]
}
}