Deliver server notifications from the Android app itself
A native foreground service keeps an authenticated websocket to the connected server (handed over by the app on every connect), subscribes with a replay cursor, shows each notification with kind-based channels and grouping, opens pipelines:// links on tap, and clears taps, dismissals and cross-device clears. It starts at boot and app launch, backs off and follows network changes. Settings gains the delivery switch, status, notification and battery-exemption actions, and the server's optional ntfy_enabled toggle.
This commit is contained in:
@@ -13,6 +13,8 @@ import '../shell/destination.dart';
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/attention/notify/chat_question_notices.dart';
|
||||
import '../features/attention/notify/notification_store.dart';
|
||||
import '../features/notification_service/notification_service_bridge.dart';
|
||||
import '../features/notification_service/notification_service_handoff.dart';
|
||||
import '../features/attention/runtime/attention_ack_queue.dart';
|
||||
import '../features/attention/runtime/attention_ack_sync.dart';
|
||||
import '../features/attention/runtime/attention_controller.dart';
|
||||
@@ -147,6 +149,11 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
/// The count the shell's Runs tab shows; only a changed count rebuilds it.
|
||||
final ValueNotifier<int> _attentionCount = ValueNotifier<int>(0);
|
||||
|
||||
/// Android background delivery (no service elsewhere).
|
||||
final NotificationServiceBridge _deliveryService =
|
||||
createNotificationServiceBridge();
|
||||
NotificationServiceHandoff? _deliveryHandoff;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -157,6 +164,12 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
knownServer: widget.knownServer,
|
||||
addresses: widget.serverAddresses,
|
||||
);
|
||||
// The service authenticates like the app: hand over each proven server.
|
||||
_deliveryHandoff = NotificationServiceHandoff(
|
||||
bridge: _deliveryService,
|
||||
client: _session.client,
|
||||
serverId: widget.serverId,
|
||||
);
|
||||
bindServerIdentity(_session.gateway, widget.serverId);
|
||||
_ownsProvider = widget.routeInformationProvider == null;
|
||||
_provider =
|
||||
@@ -228,6 +241,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_deliveryHandoff?.dispose();
|
||||
_session.removeListener(_attentionSessionChanged);
|
||||
unawaited(_attentionFrames?.cancel());
|
||||
_attention.removeListener(_attentionChanged);
|
||||
@@ -552,6 +566,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
),
|
||||
onOpenTemplates: _delegate.openTemplates,
|
||||
notifications: _notifications,
|
||||
deliveryService: _deliveryService,
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user