Skip to content

Commit

Permalink
feat: push notifications with one signal
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Jan 28, 2025
1 parent bdde723 commit 9beee4b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/app/features/container/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -29,6 +30,8 @@ export function Container() {

const hasStateRehydrated = useHasStateRehydrated();

useInitPushNotifications();

useOnWalletLock(() => closeWindow());
useOnSignOut(() => closeWindow());
useRestoreFormState();
Expand Down
16 changes: 16 additions & 0 deletions src/app/features/push-notifications/push-notifications.ts
Original file line number Diff line number Diff line change
@@ -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',
});
}, []);
}

0 comments on commit 9beee4b

Please sign in to comment.