Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: only show mobile banner on Android

thecodrr0c23456fb042
diff --git a/apps/web/src/components/banner/index.js b/apps/web/src/components/banner/index.js
index 84779c48e..964bd16bf 100644
--- a/apps/web/src/components/banner/index.js
+++ b/apps/web/src/components/banner/index.js
@@ -1,14 +1,43 @@
-import React from "react";
+import React, { useMemo } from "react";
import { Flex, Text } from "rebass";
function Banner() {
+ const link = useMemo(() => {
+ const os = getOS();
+ if (os === "Android")
+ return "https://play.google.com/store/apps/details?id=com.streetwriters.notesnook";
+ return null;
+ }, []);
+ if (link === null) return null;
return (
<Flex alignItems="center" justifyContent="center" bg="primary" py={1}>
<Text color="static" textAlign="center" fontSize="title">
- Use our <a href="https://notesnook.com/mobile">mobile app</a> for a
- better experience.
+ Use our <a href={link}>mobile app</a> for a better experience.
</Text>
</Flex>
);
}
export default Banner;
+
+function getOS() {
+ var userAgent = window.navigator.userAgent,
+ platform = window.navigator.platform,
+ macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"],
+ windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"],
+ iosPlatforms = ["iPhone", "iPad", "iPod"],
+ os = null;
+
+ if (macosPlatforms.indexOf(platform) !== -1) {
+ os = "Mac OS";
+ } else if (iosPlatforms.indexOf(platform) !== -1) {
+ os = "iOS";
+ } else if (windowsPlatforms.indexOf(platform) !== -1) {
+ os = "Windows";
+ } else if (/Android/.test(userAgent)) {
+ os = "Android";
+ } else if (!os && /Linux/.test(platform)) {
+ os = "Linux";
+ }
+
+ return os;
+}