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

Check if browser is an iOS uiWebView #432

Merged
merged 3 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/assets/translations.data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"entry.screen-prefix": "Enter on ",
"entry.desktop-screen": "Screen",
"entry.mobile-screen": "Phone",
"entry.mobile-safari": "Safari",
"entry.generic-prefix": "Enter in ",
"entry.generic-medium": "VR",
"entry.generic-subtitle-desktop": "Oculus or SteamVR",
Expand Down
11 changes: 11 additions & 0 deletions src/react-components/entry-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ export const DaydreamEntryButton = props => {
return <EntryButton {...entryButtonProps} />;
};

export const SafariEntryButton = props => {
const entryButtonProps = {
...props,
iconSrc: MobileScreenEntryImg,
prefixMessageId: "entry.screen-prefix",
mediumMessageId: "entry.mobile-safari"
};

return <EntryButton {...entryButtonProps} />;
};

export const DeviceEntryButton = props => {
const entryButtonProps = {
...props,
Expand Down
30 changes: 30 additions & 0 deletions src/react-components/info-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class InfoDialog extends Component {
slack: Symbol("slack"),
email_submitted: Symbol("email_submitted"),
invite: Symbol("invite"),
safari: Symbol(""),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well use Symbol("safari") here. It makes for nicer debugging at least.

updates: Symbol("updates"),
report: Symbol("report"),
help: Symbol("help"),
Expand Down Expand Up @@ -155,6 +156,35 @@ class InfoDialog extends Component {
</div>
);
break;
case InfoDialog.dialogTypes.safari:
dialogTitle = "Open in Safari";
dialogBody = (
<div>
<div>
Hubs is not supported in your current browser on iOS. Copy and paste this link directly in Safari.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I think I'd prefer: "Hubs does not support your current browser on iOS."

</div>
<div className="invite-form">
<input
type="text"
readOnly
onFocus={e => e.target.select()}
value={document.location}
className="invite-form__link_field"
/>
<div className="invite-form__buttons">
{navigator.share && (
<button className="invite-form__action-button" onClick={this.shareLinkClicked}>
<span>Share</span>
</button>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually show in Chrome? I would remove it.

<button className="invite-form__action-button" onClick={this.copyLinkClicked}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyLinkClicked will not include query parameters

<span>{this.state.copyLinkButtonText}</span>
</button>
</div>
</div>
</div>
);
break;
case InfoDialog.dialogTypes.updates:
dialogTitle = "";
dialogBody = (
Expand Down
17 changes: 15 additions & 2 deletions src/react-components/ui-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import screenfull from "screenfull";

import { lang, messages } from "../utils/i18n";
import AutoExitWarning from "./auto-exit-warning";
import { TwoDEntryButton, DeviceEntryButton, GenericEntryButton, DaydreamEntryButton } from "./entry-buttons.js";
import {
TwoDEntryButton,
DeviceEntryButton,
GenericEntryButton,
DaydreamEntryButton,
SafariEntryButton
} from "./entry-buttons.js";
import { ProfileInfoHeader } from "./profile-info-header.js";
import ProfileEntryPanel from "./profile-entry-panel";
import InfoDialog from "./info-dialog.js";
Expand Down Expand Up @@ -260,6 +266,10 @@ class UIRoot extends Component {
await this.performDirectEntryFlow(false);
};

linkSafari = async () => {
this.setState({ infoDialogType: InfoDialog.dialogTypes.safari });
};

enterVR = async () => {
if (this.props.availableVREntryTypes.generic !== VR_DEVICE_AVAILABILITY.maybe) {
await this.performDirectEntryFlow(true);
Expand Down Expand Up @@ -612,9 +622,12 @@ class UIRoot extends Component {
this.state.entryStep === ENTRY_STEPS.start ? (
<div className="entry-panel">
<div className="entry-panel__button-container">
{this.props.availableVREntryTypes.screen !== VR_DEVICE_AVAILABILITY.no && (
{this.props.availableVREntryTypes.screen === VR_DEVICE_AVAILABILITY.yes && (
<TwoDEntryButton onClick={this.enter2D} />
)}
{this.props.availableVREntryTypes.safari === VR_DEVICE_AVAILABILITY.maybe && (
<SafariEntryButton onClick={this.linkSafari} />
)}
{this.props.availableVREntryTypes.generic !== VR_DEVICE_AVAILABILITY.no && (
<GenericEntryButton onClick={this.enterVR} />
)}
Expand Down
12 changes: 10 additions & 2 deletions src/utils/vr-caps-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@ export async function getAvailableVREntryTypes() {
const isDaydreamCapableBrowser = !!(isWebVRCapableBrowser && browser.name === "chrome" && !isSamsungBrowser);
const isIDevice = ["iPhone", "iPad", "iPod"].indexOf(deviceDetect.device) > -1;
const isFirefoxBrowser = browser.name === "firefox";
const isUIWebView = typeof navigator.mediaDevices === "undefined";

const safari = isIDevice
? !isUIWebView ? VR_DEVICE_AVAILABILITY.yes : VR_DEVICE_AVAILABILITY.maybe
: VR_DEVICE_AVAILABILITY.no;

const screen = isInHMD
? VR_DEVICE_AVAILABILITY.no
: isIDevice && isUIWebView ? VR_DEVICE_AVAILABILITY.maybe : VR_DEVICE_AVAILABILITY.yes;

const screen = isInHMD ? VR_DEVICE_AVAILABILITY.no : VR_DEVICE_AVAILABILITY.yes;
let generic = mobiledetect.mobile() ? VR_DEVICE_AVAILABILITY.no : VR_DEVICE_AVAILABILITY.maybe;
let cardboard = VR_DEVICE_AVAILABILITY.no;

Expand Down Expand Up @@ -107,5 +115,5 @@ export async function getAvailableVREntryTypes() {
}
}

return { screen, generic, gearvr, daydream, cardboard, isInHMD };
return { screen, generic, gearvr, daydream, cardboard, isInHMD, safari };
}