Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.1 KB
Raw Blame
// Android intents only foreground Piik. App-owned pending requests still own
// permission, and the normal loopback approval/health checks own Site access.
export function androidAppIntent(action: unknown, userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent): string | null {
  if (action !== "piik://app" && action !== "piik://media") return null;
  // A connected App supplies its own media action. Android tablets can report
  // a desktop UA; only an unconnected cold wake needs the browser OS hint.
  if (action === "piik://app" && !/Android/i.test(userAgent)) return null;
  return `intent://${action.slice("piik://".length)}#Intent;scheme=piik;package=tv.piik.android;end`;
}

// Called only after the pending picker request has been sent. A browser may
// decline the handoff; the existing confirmation control remains available.
export function activateNativePicker(action: unknown): void {
  const intent = androidAppIntent(action);
  if (!intent || !navigator.userActivation?.isActive) return;
  try { window.location.assign(intent); } catch { /* Continue with manual confirmation. */ }
}