diff --git a/package.json b/package.json index 931699a7a9..bf06c410fb 100644 --- a/package.json +++ b/package.json @@ -241,6 +241,7 @@ "react-hook-form": "7.53.1", "react-intersection-observer": "9.5.2", "react-lottie": "1.2.4", + "react-onesignal": "3.0.1", "react-qr-code": "2.0.12", "react-redux": "9.1.2", "react-router-dom": "6.26.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4ac5e0cea..69dac45ee7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -332,6 +332,9 @@ importers: react-lottie: specifier: 1.2.4 version: 1.2.4(react@18.3.1) + react-onesignal: + specifier: 3.0.1 + version: 3.0.1(react@18.3.1) react-qr-code: specifier: 2.0.12 version: 2.0.12(react-native-svg@15.11.1(react-native@0.74.1(@babel/core@7.26.0)(@babel/preset-env@7.26.0(@babel/core@7.26.0))(@types/react@18.3.10)(encoding@0.1.13)(react@18.2.0))(react@18.3.1))(react@18.3.1) @@ -13606,6 +13609,12 @@ packages: '@types/react': optional: true + react-onesignal@3.0.1: + resolution: {integrity: sha512-AfAtGdXRcuMhVf+9OXehGcQeiJIYl1ihAByvfVNa3RCA1Vnn19tBha4XQB+o3ukUh2IQn0yiflRO4vXgI9nOng==} + engines: {node: '>=8', npm: '>=5'} + peerDependencies: + react: '>= 16.8' + react-qr-code@2.0.12: resolution: {integrity: sha512-k+pzP5CKLEGBRwZsDPp98/CAJeXlsYRHM2iZn1Sd5Th/HnKhIZCSg27PXO58zk8z02RaEryg+60xa4vyywMJwg==} peerDependencies: @@ -32948,6 +32957,10 @@ snapshots: - supports-color - utf-8-validate + react-onesignal@3.0.1(react@18.3.1): + dependencies: + react: 18.3.1 + react-qr-code@2.0.12(react-native-svg@15.11.1(react-native@0.74.1(@babel/core@7.26.0)(@babel/preset-env@7.26.0(@babel/core@7.26.0))(@types/react@18.3.10)(encoding@0.1.13)(react@18.2.0))(react@18.3.1))(react@18.3.1): dependencies: prop-types: 15.8.1 diff --git a/src/app/features/container/container.tsx b/src/app/features/container/container.tsx index bc819ce393..fb32dfa752 100644 --- a/src/app/features/container/container.tsx +++ b/src/app/features/container/container.tsx @@ -20,6 +20,7 @@ import { useAppDispatch, useHasStateRehydrated } from '@app/store'; import { stxChainSlice } from '@app/store/chains/stx-chain.slice'; import { useRestoreFormState } from '../popup-send-form-restoration/use-restore-form-state'; +import { useInitPushNotifications } from '../push-notifications/push-notifications'; export function Container() { const { pathname: locationPathname } = useLocation(); @@ -29,6 +30,8 @@ export function Container() { const hasStateRehydrated = useHasStateRehydrated(); + useInitPushNotifications(); + useOnWalletLock(() => closeWindow()); useOnSignOut(() => closeWindow()); useRestoreFormState(); diff --git a/src/app/features/push-notifications/push-notifications.ts b/src/app/features/push-notifications/push-notifications.ts new file mode 100644 index 0000000000..9e8a016c1b --- /dev/null +++ b/src/app/features/push-notifications/push-notifications.ts @@ -0,0 +1,16 @@ +import { useEffect } from 'react'; +import OneSignal from 'react-onesignal'; + +import { WALLET_ENVIRONMENT } from '@shared/environment'; + +export function useInitPushNotifications() { + useEffect(() => { + void OneSignal.init({ + appId: 'YOUR_APP_ID', + notifyButton: { + enable: true, + }, + allowLocalhostAsSecureOrigin: WALLET_ENVIRONMENT === 'development', + }); + }, []); +}