Files
oott/frontend/lib/utils/local_network_permission.dart
T
rzuastiandClaude Opus 4.8 40a7f3a432 Request iOS local-network permission at app launch
The iOS local-network permission prompt fires on the first local-network
access. That used to be the user's "Test" tap in settings, so the prompt
appeared mid-request and the first connection attempt always failed.

Provoke the prompt at launch instead via an mDNS multicast datagram, so the
permission is settled before the user reaches settings. Platform exclusion is
handled with a conditional import: web gets a no-op stub (keeping dart:io out
of web builds) and the native path no-ops off iOS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 15:33:06 -04:00

18 lines
915 B
Dart

/// Provokes iOS's local-network access prompt at app launch.
///
/// iOS shows the "allow access to devices on your local network" prompt the
/// first time an app touches the local network. Until this ran at startup, that
/// first touch was the user's "Test" tap in settings — so the prompt appeared
/// mid-request and the very first connection attempt always failed while the
/// user was still deciding. Triggering it here means the permission is settled
/// before the user ever reaches the settings screen.
///
/// The real work lives in the `_io` implementation, which depends on `dart:io`
/// and is therefore only compiled on native platforms. Web gets the `_stub`
/// no-op, so `dart:io` never reaches a web build. Android, while native, also
/// no-ops since only iOS has this prompt.
library;
export 'local_network_permission_stub.dart'
if (dart.library.io) 'local_network_permission_io.dart';