From eb685b42ca8d8ad1158f644a976d8ed8bf36a548 Mon Sep 17 00:00:00 2001 From: sravan Date: Sat, 22 Aug 2026 11:36:48 +0530 Subject: [PATCH] iOS "Share Screen": route to a screen-share meeting (remote-support on iPhone) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The remote-support Share/Connect tabs use P2P WebRTC (screen + voice + chat) that WKWebView can't capture, so "Share Screen" never worked on iPhone. Rather than rebuild the whole P2P session on LiveKit, route iOS "Share Screen" to a screen-share MEETING (chosen with the user): tapping Share Screen on iOS starts an instant meeting, auto-starts the native ReplayKit screen share (the path just verified on device), and toasts the join code. A helper joins by code (Meeting) to watch — and gets voice + chat for free. Viewing already works in the webview, so only the SHARE side is rerouted; desktop keeps the full P2P remote-support flow, and iOS Safari (no app) is unchanged. Web-only, no new build (reuses the shipped startMeetingScreenShare native method). Co-Authored-By: Claude Opus 4.8 --- server/public/home.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/public/home.html b/server/public/home.html index bd00d87..3930d39 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -6153,6 +6153,9 @@ async function onMeetMsg(e){ if(_pendingJoinMic){ _pendingJoinMic=false; if(!meetMic){ try{ await toggleMic(); }catch(_){} } } if(_pendingJoinCam){ _pendingJoinCam=false; if(!meetCam){ try{ await toggleCam(); }catch(_){} } } refreshMeetPanel(); updateHostControls(); + // iOS "Share Screen" entry: auto-start the native screen broadcast now that we have a peerId + room, and + // surface the code so the user can hand it to whoever should watch. + if(_autoShareOnJoin){ _autoShareOnJoin=false; setTimeout(()=>{ try{ toggleScreen(); }catch(_){} if(meetRoom) toast('Share code '+meetRoom+' so others can watch your screen.'); }, 800); } return; } // The room is gone (host ended it / code expired). Say so plainly instead of hanging on "Connecting…" @@ -6311,7 +6314,20 @@ const panels=document.querySelectorAll('.panel'); const chatcol=document.getElementById('chatcol'); let loaded={share:false,connect:false}; function currentTab(){ const b=document.querySelector('.railbtn.active'); return b?b.dataset.tab:'chat'; } +let _autoShareOnJoin=false; +// iOS "Share Screen": WKWebView can't capture the P2P remote-support flow, so route it to a screen-share +// MEETING — the native ReplayKit path publishes into LiveKit, and a helper joins by code to watch (+ talk/chat). +// (Viewing a shared screen already works in the webview; only capture is blocked, so only the SHARE side moves.) +function startIosScreenShareMeeting(){ + const NC=nativeCallPlugin(); + if(!NC || typeof NC.startMeetingScreenShare!=='function'){ switchTab('meeting'); toast('Update the app to share your screen'); return; } + if(meetState==='call'){ switchTab('meeting'); toast('You’re already in a meeting — tap Share screen there.'); return; } + _autoShareOnJoin=true; + switchTab('meeting'); + enterMeeting(null); // start an instant meeting; the auto-share fires once meeting-joined gives us a peerId +} function switchTab(tab){ + if(tab==='share' && SFU.on && bzIsIOS()){ startIosScreenShareMeeting(); return; } // iOS: screen-share via a meeting, not the P2P iframe railBtns.forEach(b=>b.classList.toggle('active',b.dataset.tab===tab)); panels.forEach(p=>p.classList.toggle('active',p.dataset.panel===tab)); chatcol.classList.toggle('hidden', tab!=='chat');