Skip to content

Commit

Permalink
demo/extension: Expand iPad check to work for iPadOS 13+
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Nov 15, 2023
1 parent b196c8d commit ffdb248
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion web/packages/demo/www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ reloadSwf.addEventListener("click", () => {
window.addEventListener("load", () => {
if (
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPhone/i)
navigator.userAgent.match(/iPhone/i) ||
(navigator.platform === "MacIntel" &&
typeof navigator.standalone !== "undefined")
) {
localFileInput.removeAttribute("accept");
}
Expand Down
14 changes: 13 additions & 1 deletion web/packages/extension/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import type {
URLLoadOptions,
} from "ruffle-core";

declare global {
interface Navigator {
/**
* iPadOS sends a User-Agent string that appears to be from macOS.
* navigator.standalone is not defined on macOS, so we use it for iPad detection.
*/
standalone?: boolean;
}
}

const api = PublicAPI.negotiate(window.RufflePlayer!, "local");
window.RufflePlayer = api;
const ruffle = api.newest()!;
Expand Down Expand Up @@ -216,7 +226,9 @@ reloadSwf.addEventListener("click", () => {
window.addEventListener("load", () => {
if (
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPhone/i)
navigator.userAgent.match(/iPhone/i) ||
(navigator.platform === "MacIntel" &&
typeof navigator.standalone !== "undefined")
) {
localFileInput.removeAttribute("accept");
}
Expand Down

0 comments on commit ffdb248

Please sign in to comment.