Settings: test alert notification button
Fires a local notification shaped exactly like a real price alert (uses the currently configured alerts fuel + radius), with permission-gated handling: prompts on first use, guides to Settings when denied. Tapping it opens FuelBoard, same as a real alert.
This commit is contained in:
@@ -172,4 +172,19 @@ final class ProximityMonitor: NSObject, ObservableObject, @preconcurrency CLLoca
|
||||
|
||||
lastAlert = "\(brand) · \(String(format: "%.1fp", price)) · \(unit.format(radiusKM)) radius"
|
||||
}
|
||||
|
||||
/// Fires a sample local notification shaped exactly like a real price
|
||||
/// alert, for the Settings "test" button. Uses a placeholder station so
|
||||
/// the user can see the alert format without a real entry event. Tapping
|
||||
/// it does what tapping any FuelBoard alert does — opens the app.
|
||||
static func sendTestNotification(fuel: FuelType, radiusKM: Double) {
|
||||
let unit = FuelStore.loadDistanceUnit()
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = "Cheapest \(fuel.displayName) nearby: Sample Filling Station"
|
||||
content.body = "Sample Filling Station is the cheapest within \(unit.format(radiusKM)) at 132.9p. Tap to open."
|
||||
content.sound = .default
|
||||
|
||||
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
|
||||
UNUserNotificationCenter.current().add(request)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user