2. Run the Notification operation through Fission
A visible action requests permission and then schedules the chosen reminder
through the host's real capability path. Completion actions are bound by the
requesting reducer; they read returned values from cx.input. The request
snapshot is owned data, so a later rebuild cannot change its title or body.
The browser preview installs no replacement provider. It may report Unsupported;
that is the actual host outcome, not permission to display a fake success.
The configured delay is 15 minutes (900,000 milliseconds), matching the label.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/state.rs","value":"src-state-rs"},{"index":1,"label":"src/reducers.rs","value":"src-reducers-rs"},{"index":2,"label":"src/app.rs","value":"src-app-rs"},{"index":3,"label":"src/lib.rs","value":"src-lib-rs"},{"index":4,"label":"src/translations.rs","value":"src-translations-rs"},{"index":5,"label":"preview/lib.rs","value":"preview-lib-rs"},{"index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;
#[derive(Debug, Default)]
pub struct ShiftReminderState {
pub pending: bool,
pub scheduled: Option<bool>,
pub failed: bool,
pub request: Option<NotificationRequest>,
}
impl GlobalState for ShiftReminderState {}
{"id":"fission-tabs-1","index":1,"label":"src/reducers.rs","value":"src-reducers-rs"}
use fission::prelude::*;
use crate::state::ShiftReminderState;
#[fission_reducer(RunCapability)]
pub fn run_capability(state: &mut ShiftReminderState, request: NotificationRequest, cx: &mut ReducerContext<ShiftReminderState>) {
if state.pending { return; }
state.pending = true;
state.failed = false;
state.request = Some(request);
let ok = cx.effects.bind(PermissionChecked, reduce!(permission_checked));
let err = cx.effects.bind(CapabilityFailed, reduce!(capability_failed));
cx.effects.notifications().request_permission(NotificationPermissionRequest {
alerts: true, badge: false, sound: true, provisional: false,
}).on_ok(ok).on_err(err);
}
#[fission_reducer(PermissionChecked)]
fn permission_checked(state: &mut ShiftReminderState, cx: &mut ReducerContext<ShiftReminderState>) {
let permitted = cx.input.capability_ok(REQUEST_NOTIFICATION_PERMISSION)
.is_some_and(|settings| matches!(settings.permission, NotificationPermission::Granted | NotificationPermission::Provisional) && settings.scheduling);
if !permitted {
state.pending = false;
state.failed = true;
state.request = None;
return;
}
let Some(request) = state.request.take() else {
state.pending = false;
state.failed = true;
return;
};
let ok = cx.effects.bind(CapabilitySucceeded, reduce!(capability_succeeded));
let err = cx.effects.bind(CapabilityFailed, reduce!(capability_failed));
cx.effects.notifications().schedule(request).on_ok(ok).on_err(err);
}
#[fission_reducer(CapabilitySucceeded)]
fn capability_succeeded(state: &mut ShiftReminderState, cx: &mut ReducerContext<ShiftReminderState>) {
state.pending = false;
state.scheduled = cx.input.capability_ok(SCHEDULE_NOTIFICATION).map(|receipt| receipt.scheduled);
state.failed = state.scheduled != Some(true);
}
pub fn cancel_reminder(state: &mut ShiftReminderState, cx: &mut ReducerContext<ShiftReminderState>) {
if state.pending || state.scheduled != Some(true) { return; }
state.pending = true;
state.failed = false;
let ok = cx.effects.bind(ReminderCancelled, reduce!(reminder_cancelled));
let err = cx.effects.bind(CapabilityFailed, reduce!(capability_failed));
cx.effects.notifications().cancel(CancelNotificationRequest {
id: NotificationId::new("WO-1048-reminder"),
}).on_ok(ok).on_err(err);
}
#[fission_reducer(ReminderCancelled)]
fn reminder_cancelled(state: &mut ShiftReminderState, cx: &mut ReducerContext<ShiftReminderState>) {
state.pending = false;
if cx.input.capability_ok(CANCEL_NOTIFICATION).is_some() {
state.scheduled = Some(false);
state.failed = false;
} else { state.failed = true; }
}
#[fission_reducer(CapabilityFailed)]
fn capability_failed(state: &mut ShiftReminderState) {
state.pending = false;
state.request = None;
state.failed = true;
// Keep a prior scheduling receipt: failed cancellation does not prove cancellation.
}
{"id":"fission-tabs-1","index":2,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
use crate::{state::ShiftReminderState, reducers::{RunCapability, run_capability, cancel_reminder}};
fission_component! {
pub ShiftReminderScreen<ShiftReminderState> {}
view(_screen, state, cx) {
let tokens = &cx.view.env().theme.tokens;
let request = NotificationRequest {
id: NotificationId::new("WO-1048-reminder"),
title: cx.tr("reminder.notification_title"),
body: cx.tr("reminder.notification_body"),
subtitle: Some(cx.tr("reminder.notification_subtitle")),
badge: Some(1),
sound: NotificationSound::Default,
deep_link: Some("field-inspector://work-orders/WO-1048".into()),
actions: Vec::new(),
schedule: NotificationSchedule::AfterMillis(900_000),
};
let action = with_reducer!(cx.build, RunCapability(request), run_capability);
let status = if state.pending {
cx.tr("reminder.waiting")
} else if state.failed {
cx.tr("reminder.error")
} else {
match state.scheduled {
Some(true) => cx.tr("reminder.scheduled"),
Some(false) => cx.tr("reminder.unscheduled"),
None => cx.tr("reminder.ready"),
}
};
} =>
SemanticsRegion(
identifier: Some("shift-reminder-schedule".to_string()),
label: Some(cx.tr("reminder.title")),
child: Container(
Column(gap: tokens.spacing.m, children: [
Text(cx.tr("reminder.site"))
.weight(tokens.typography.font_weight_bold),
Text(cx.tr("reminder.title"))
.size(tokens.typography.heading2_size),
Text(cx.tr("reminder.schedule"))
.color(tokens.colors.text_secondary),
Text(cx.tr("reminder.context")),
Button(
child: Text(cx.tr("reminder.action")),
key: "run-capability",
variant: ButtonVariant::Primary,
disabled: state.pending || state.scheduled == Some(true),
loading: state.pending,
on_press: action,
),
if state.pending { Spinner(motion: SpinnerMotion::Default, label: Some(cx.tr("reminder.waiting"))) },
if state.scheduled == Some(true) {
Button(child: Text(cx.tr("reminder.cancel")), key: "cancel-reminder", disabled: state.pending,
on_press: reduce { cancel_reminder(state, cx); })
},
Container(Text(status))
.padding_all(tokens.spacing.m)
.bg(tokens.colors.background)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.medium),
])
)
.padding_all(tokens.spacing.l)
.bg(tokens.colors.surface)
.border(tokens.colors.border, 1.0)
.border_radius(tokens.radii.large),
)
}
{"id":"fission-tabs-1","index":3,"label":"src/lib.rs","value":"src-lib-rs"}
mod app;
mod translations;
mod state;
mod reducers;
use fission::prelude::*;
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
DesktopApp::<state::ShiftReminderState, _>::new(app::ShiftReminderScreen)
.with_env(translations::create_env()).with_title("Shift reminder").run()
}
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> {
MobileApp::<state::ShiftReminderState, _>::new(app::ShiftReminderScreen)
.with_env(translations::create_env()).with_title("Shift reminder").run()
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
WebApp::<state::ShiftReminderState, _>::new(app::ShiftReminderScreen)
.with_env(translations::create_env()).with_title("Shift reminder").run()
.map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":4,"label":"src/translations.rs","value":"src-translations-rs"}
use fission::prelude::*;
fn load_bundle(locale: &str, source: &str) -> TranslationBundle {
TranslationBundle {
locale: Locale::from(locale),
messages: serde_yaml::from_str(source).expect("valid shift reminder tutorial translations"),
}
}
pub fn create_env() -> Env {
let mut env = Env::default();
env.locale = Locale::from("en-US");
env.i18n.add_bundle(load_bundle("en-US", include_str!("../i18n/en-US.yaml")));
env.i18n.add_bundle(load_bundle("es-ES", include_str!("../i18n/es-ES.yaml")));
env
}
{"id":"fission-tabs-1","index":5,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod state;
mod reducers;
use fission::prelude::*;
use wasm_bindgen::prelude::*;
fn load_bundle(locale: &str, source: &str) -> TranslationBundle {
TranslationBundle {
locale: Locale::from(locale),
messages: serde_yaml::from_str(source).expect("valid shift reminder tutorial translations"),
}
}
fn preview_env() -> Env {
let mut env = Env::default();
env.locale = Locale::from("en-US");
env.i18n.add_bundle(load_bundle("en-US", include_str!("../i18n/en-US.yaml")));
env.i18n.add_bundle(load_bundle("es-ES", include_str!("../i18n/es-ES.yaml")));
env
}
#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
WebApp::<state::ShiftReminderState, _>::new(app::ShiftReminderScreen)
.with_env(preview_env())
.with_title("iOS shift reminder")
.mount("#fission-web-mount")
.run()
.map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
reminder.site: "Northbank Receiving · evening shift"
reminder.title: "Compressor recheck reminder"
reminder.schedule: "WO-1048 · in 15 minutes"
reminder.context: "Request the real host operation. A receipt is not proof of delivery; unsupported and denied outcomes remain visible."
reminder.preview_enabled: "Reminder preview is on. No notification has been scheduled."
reminder.preview_disabled: "No reminder is selected."
reminder.enable_preview: "Preview the reminder choice"
reminder.disable_preview: "Turn off the reminder preview"
reminder.waiting: "Scheduling the shift reminder…"
reminder.error: "The reminder could not be scheduled. The work order is still available."
reminder.scheduled: "The host accepted the reminder schedule."
reminder.unscheduled: "The host did not schedule the reminder."
reminder.ready: "No notification has been scheduled."
reminder.cancel: "Request cancellation"
reminder.action: "Schedule this reminder"
reminder.notification_title: "Compressor recheck"
reminder.notification_body: "Recheck compressor CMP-7A-2219 before the shift ends."
reminder.notification_subtitle: "Northbank Receiving · WO-1048"
{"id":"fission-tabs-1","index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
reminder.site: "Recepción Northbank · turno de tarde"
reminder.title: "Recordatorio para revisar el compresor"
reminder.schedule: "OT-1048 · en 15 minutos"
reminder.context: "Solicita la operación real al host. Un recibo no demuestra la entrega; se muestran los resultados no admitidos o denegados."
reminder.preview_enabled: "La vista previa del recordatorio está activada. No se ha programado ninguna notificación."
reminder.preview_disabled: "No se ha elegido ningún recordatorio."
reminder.enable_preview: "Previsualizar la opción de recordatorio"
reminder.disable_preview: "Desactivar la vista previa del recordatorio"
reminder.waiting: "Programando el recordatorio del turno…"
reminder.error: "No se pudo programar el recordatorio. La orden sigue disponible."
reminder.scheduled: "El host aceptó la programación del recordatorio."
reminder.unscheduled: "El host no programó el recordatorio."
reminder.ready: "No se ha programado ninguna notificación."
reminder.cancel: "Solicitar cancelación"
reminder.action: "Programar este recordatorio"
reminder.notification_title: "Revisión del compresor"
reminder.notification_body: "Revisa el compresor CMP-7A-2219 antes de que termine el turno."
reminder.notification_subtitle: "Recepción Northbank · OT-1048"
{"id":"fission-tabs-1"}
The preview uses the configured host, not a memory implementation. An unsupported result must remain an error. On iOS, a scheduling receipt is not evidence of permission, actual delivery or working cancellation.
Show the app previewHide the app preview
Show the app preview
Hide the app preview