attach method
Start mirroring. Also picks up a native Accept that launched the app.
Implementation
Future<void> attach() async {
_subs.add(ui.actions.listen(_onNative));
_subs.add(agent.onIncoming.listen(_onIncoming));
_subs.add(agent.onCallEnded.listen((e) => _closeScreen(e.call)));
for (final c in agent.ringingCalls) {
_onIncoming(c);
}
// Cold start: the user accepted on the native screen, which launched the app.
try {
for (final shown in await ui.active()) {
if (shown.accepted) _remember(NativeActionType.accept, shown.uuid, shown.callId.isEmpty ? null : shown.callId);
}
} catch (_) {/* the plugin isn't available (tests, desktop) */}
agent.sync();
}