start method

Future<void> start()

Wire automatic install/open reporting. Called by Nexus.init when linksEnabled; idempotent.

Implementation

Future<void> start() async {
  if (_started) return;
  _started = true;
  final platform = NexusPlatform.instance;
  // Live links first, then drain the cold-start queue: native switches to
  // live delivery the moment the queue is taken, so nothing falls between.
  platform.onLinkOpened((url) => unawaited(_handleUrl(url)));
  unawaited(platform.linksConfigure(_hosts.toList()));
  final pending = List<String>.of(await platform.linksTakePending());

  final install = await _newInstall();
  if (install != null) {
    // A link that launched the very first open IS the install's click.
    await _reportInstall(install, pending.isEmpty ? null : pending.removeAt(0));
  }
  for (final url in pending) {
    await _handleUrl(url);
  }
}