Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Detect PWA mode and show notification when served inside iframe #10249

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fuzzy-frogs-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/core": minor
"gradio": minor
---

feat:[DO NOT MERGE] Detect PWA mode and show notification when served inside iframe
11 changes: 11 additions & 0 deletions js/core/src/Blocks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,17 @@
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);

if (window.top && window.self !== window.top) {
// This app is in an iframe
fetch("/manifest.json", { method: "GET" }).then((response) => {
if (response.ok) {
const self_url = new URL(window.self.location.href);
const bare_self_url = self_url.origin + self_url.pathname;
// TODO: Show a notification like `This app is served as PWA. Visit ${bare_self_url} to install it.`
}
});
}
});
</script>

Expand Down
Loading