about summary refs log tree commit diff
path: root/src/view/shell/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/shell/index.tsx')
-rw-r--r--src/view/shell/index.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx
index 5562af9ac..18042c7ed 100644
--- a/src/view/shell/index.tsx
+++ b/src/view/shell/index.tsx
@@ -31,6 +31,7 @@ import {
 import {isAndroid} from 'platform/detection'
 import {useSession} from '#/state/session'
 import {useCloseAnyActiveElement} from '#/state/util'
+import * as notifications from 'lib/notifications/notifications'
 
 function ShellInner() {
   const isDrawerOpen = useIsDrawerOpen()
@@ -52,7 +53,7 @@ function ShellInner() {
     [setIsDrawerOpen],
   )
   const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
-  const {hasSession} = useSession()
+  const {hasSession, currentAccount} = useSession()
   const closeAnyActiveElement = useCloseAnyActiveElement()
 
   React.useEffect(() => {
@@ -67,6 +68,19 @@ function ShellInner() {
     }
   }, [closeAnyActiveElement])
 
+  React.useEffect(() => {
+    if (currentAccount) {
+      notifications.requestPermissionsAndRegisterToken(currentAccount)
+    }
+  }, [currentAccount])
+
+  React.useEffect(() => {
+    if (currentAccount) {
+      const unsub = notifications.registerTokenChangeHandler(currentAccount)
+      return unsub
+    }
+  }, [currentAccount])
+
   return (
     <>
       <View style={containerPadding}>