about summary refs log tree commit diff
path: root/src/platform/urls.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-06-15 20:26:41 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-06-15 20:26:41 -0500
commit07b92a2180ca6600f09e03a85c8ca7a06d24cbfc (patch)
tree1f7fd65f7cbaf59ff93c92595dc04a22b0a079a7 /src/platform/urls.tsx
parent81441c3c265ae6e733365dcba01f7da650f5b1f9 (diff)
downloadvoidsky-07b92a2180ca6600f09e03a85c8ca7a06d24cbfc.tar.zst
Implement full auth flow in iOS
Diffstat (limited to 'src/platform/urls.tsx')
-rw-r--r--src/platform/urls.tsx27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/platform/urls.tsx b/src/platform/urls.tsx
index 958b5232d..048c92f2e 100644
--- a/src/platform/urls.tsx
+++ b/src/platform/urls.tsx
@@ -1,4 +1,5 @@
-import {isIOS, isAndroid} from './detection'
+import {Linking} from 'react-native'
+import {isIOS, isAndroid, isNative, isWeb} from './detection'
 
 export function makeAppUrl(path = '') {
   if (isIOS) {
@@ -10,3 +11,27 @@ export function makeAppUrl(path = '') {
     return `${window.location.origin}${path}`
   }
 }
+
+export function extractHashFragment(url: string): string {
+  return url.split('#')[1] || ''
+}
+
+export async function getInitialURL(): Promise<string> {
+  if (isNative) {
+    const url = await Linking.getInitialURL()
+    if (url) {
+      return url
+    }
+    return makeAppUrl()
+  } else {
+    // @ts-ignore window exists -prf
+    return window.location.toString()
+  }
+}
+
+export function clearHash() {
+  if (isWeb) {
+    // @ts-ignore window exists -prf
+    window.location.hash = ''
+  }
+}