diff --git a/packages/editor/src/client/components/DeepLink/index.js b/packages/editor/src/client/components/DeepLink/index.js index 786ca03bcf..b1f716f8a2 100644 --- a/packages/editor/src/client/components/DeepLink/index.js +++ b/packages/editor/src/client/components/DeepLink/index.js @@ -5,7 +5,7 @@ import Button from "@docspace/components/button"; import Link from "@docspace/components/link"; import { getLogoFromPath } from "@docspace/common/utils"; -import { getDeepLink } from "../../helpers/deepLinkHelper"; +import { getDeepLink, DL_URL } from "../../helpers/deepLinkHelper"; import { StyledSimpleNav, @@ -15,10 +15,6 @@ import { StyledActionsWrapper, } from "./StyledDeepLink"; -const DL_ANDROID = "com.onlyoffice.documents"; -const DL_IOS = "944896972"; -const DL_URL = "oodocuments://openfile"; - const DeepLink = ({ fileInfo, logoUrls, userEmail, setIsShowDeepLink }) => { const [isRemember, setIsRemember] = useState(false); diff --git a/packages/editor/src/client/components/Editor.js b/packages/editor/src/client/components/Editor.js index f4ad9a7f3e..f6e94a807c 100644 --- a/packages/editor/src/client/components/Editor.js +++ b/packages/editor/src/client/components/Editor.js @@ -1,4 +1,5 @@ import React, { useEffect, useState } from "react"; +import styled from "styled-components"; import { isMobile, isIOS, deviceType, isMobileOnly } from "react-device-detect"; import combineUrl from "@docspace/common/utils/combineUrl"; import { FolderType, EDITOR_ID } from "@docspace/common/constants"; @@ -23,9 +24,15 @@ import { assign } from "@docspace/common/utils"; import toastr from "@docspace/components/toast/toastr"; import { DocumentEditor } from "@onlyoffice/document-editor-react"; import ErrorContainer from "@docspace/common/components/ErrorContainer"; -import styled from "styled-components"; import DeepLink from "./DeepLink"; +import { + getDeepLink, + DL_URL, + DL_IOS, + DL_ANDROID, +} from "../helpers/deepLinkHelper"; + toast.configure(); const onSDKInfo = (event) => { @@ -112,6 +119,29 @@ function Editor({ if (isMobileOnly && !defaultOpenDocument) { setIsShowDeepLink(true); } + + if (isMobileOnly && defaultOpenDocument === "app") { + const nav = navigator.userAgent; + const storeUrl = + nav.includes("iPhone;") || nav.includes("iPad;") + ? `https://apps.apple.com/app/id${DL_IOS}` + : `https://play.google.com/store/apps/details?id=${DL_ANDROID}`; + + window.location = getDeepLink( + window.location.origin, + user.email, + fileInfo, + DL_URL + ); + + setTimeout(() => { + if (document.hasFocus()) { + window.location.replace(storeUrl); + } else { + history.goBack(); + } + }, 3000); + } }, []); useEffect(() => { diff --git a/packages/editor/src/client/helpers/deepLinkHelper.js b/packages/editor/src/client/helpers/deepLinkHelper.js index 08ff17b770..24949848db 100644 --- a/packages/editor/src/client/helpers/deepLinkHelper.js +++ b/packages/editor/src/client/helpers/deepLinkHelper.js @@ -1,3 +1,7 @@ +export const DL_ANDROID = "com.onlyoffice.documents"; +export const DL_IOS = "944896972"; +export const DL_URL = "oodocuments://openfile"; + export const getDeepLink = (location, email, file, url) => { const jsonData = { portal: location,