+ sendPhoneNumberToApp(data?.data?.applicant_phone_number)
+ }
+ >
diff --git a/src/router.tsx b/src/router.tsx
index 77858b17..ab542716 100644
--- a/src/router.tsx
+++ b/src/router.tsx
@@ -53,7 +53,6 @@ import EmployerEditPostPage from './pages/Employer/Post/EmployerEditPostPage';
const Layout = () => {
const location = useLocation();
const { account_type } = useUserStore();
-
// Nav bar 컴포넌트가 랜딩되는 페이지
const showNavbarPaths = () => {
if (account_type === UserType.OWNER) {
diff --git a/src/store/user.ts b/src/store/user.ts
index 6031666c..819e44bb 100644
--- a/src/store/user.ts
+++ b/src/store/user.ts
@@ -22,3 +22,18 @@ export const useUserStore = create(
},
),
);
+
+type UserFcmTokenStore = {
+ token: string;
+ updateToken: (newToken: string) => void;
+};
+
+export const useUserFcmTokenStore = create(
+ persist
(
+ (set) => ({
+ token: '',
+ updateToken: (token) => set(() => ({ token })),
+ }),
+ { name: 'UserFcmTokenStore' },
+ ),
+);
diff --git a/src/utils/reactNativeMessage.ts b/src/utils/reactNativeMessage.ts
new file mode 100644
index 00000000..506e72d0
--- /dev/null
+++ b/src/utils/reactNativeMessage.ts
@@ -0,0 +1,47 @@
+import { isMobile, isAndroid, isIOS } from 'react-device-detect';
+
+// 메시지 데이터 인터페이스
+interface MessageData {
+ type: string;
+ payload?: string;
+}
+
+interface Message {
+ type: string;
+ payload?: string;
+}
+
+export const getReactNativeMessage = () => {
+ if (!isMobile) {
+ return;
+ }
+
+ // MessageEvent로 타입 캐스팅을 사용
+ const listener: EventListener = ((event: Event) => {
+ // MessageEvent로 타입 캐스팅
+ const messageEvent = event as MessageEvent;
+ try {
+ const parsedData: MessageData = JSON.parse(messageEvent.data);
+ if (parsedData?.type === "FCMTOKEN") { // parsedData.type은 메시지의 용도에 맞게 재정의 필요
+ console.log(parsedData.payload)
+ }
+ } catch (error) {
+ console.error('Failed to parse message data:', error);
+ }
+ });
+
+ if (window.ReactNativeWebView) {
+ if (isAndroid) {
+ document.addEventListener('message', listener);
+ }
+ if (isIOS) {
+ window.addEventListener('message', listener);
+ }
+ }
+};
+
+export const sendReactNativeMessage = ({ type, payload }: Message) => {
+ if (window.ReactNativeWebView) {
+ window.ReactNativeWebView.postMessage(JSON.stringify({ type, payload }));
+ }
+};
\ No newline at end of file
diff --git a/tsconfig.app.json b/tsconfig.app.json
index 4c212c2a..c1ab574e 100644
--- a/tsconfig.app.json
+++ b/tsconfig.app.json
@@ -25,5 +25,5 @@
},
"types": ["node"]
},
- "include": ["src"]
+ "include": ["src", "global.d.ts"]
}
diff --git a/vite.config.ts b/vite.config.ts
index e69e7419..a48991f2 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
-import svgr from "vite-plugin-svgr"
+import svgr from 'vite-plugin-svgr';
// https://vitejs.dev/config/
export default defineConfig({
@@ -11,4 +11,8 @@ export default defineConfig({
'@': path.resolve(__dirname, './src'), // src 폴더를 @로 절대 경로 설정
},
},
+ server: {
+ host: true,
+ port: 5173,
+ },
});