- 안드로이드 알림 설정 AppBridge 추가
- KeyIn Request 필드 수정
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { appBridge } from '@/utils/appBridge';
|
||||
import { DeviceInfo, ShareContent } from '@/types';
|
||||
import { DeviceInfo, NotificationSettingResponse, ShareContent } from '@/types';
|
||||
import { LoginResponse } from '@/entities/user/model/types';
|
||||
|
||||
interface UseAppBridgeReturn {
|
||||
@@ -8,23 +8,23 @@ interface UseAppBridgeReturn {
|
||||
isAndroid: boolean;
|
||||
isIOS: boolean;
|
||||
deviceInfo: DeviceInfo | null;
|
||||
|
||||
|
||||
// 네비게이션
|
||||
navigateBack: () => Promise<void>;
|
||||
navigateTo: (path: string) => Promise<void>;
|
||||
navigateToLogin: () => Promise<void>;
|
||||
closeWebView: () => Promise<void>;
|
||||
|
||||
|
||||
// 알림
|
||||
showToast: (message: string, duration?: number) => Promise<void>;
|
||||
showAlert: (title: string, message: string) => Promise<void>;
|
||||
showConfirm: (title: string, message: string) => Promise<boolean>;
|
||||
|
||||
|
||||
// 저장소
|
||||
setStorage: (key: string, value: unknown) => Promise<void>;
|
||||
// getStorage: <T = unknown>(key: string) => Promise<T | null>;
|
||||
removeStorage: (key: string) => Promise<void>;
|
||||
|
||||
|
||||
/*
|
||||
// 미디어
|
||||
openCamera: (options?: { quality?: number; allowEdit?: boolean }) => Promise<string>;
|
||||
@@ -62,11 +62,15 @@ interface UseAppBridgeReturn {
|
||||
|
||||
// 로그인 방식 설정 조회
|
||||
getLoginType: () => Promise<string>;
|
||||
|
||||
getNotificationSetting: () => Promise<boolean>;
|
||||
|
||||
setNotificationSetting: (enabled: boolean) => Promise<NotificationSettingResponse>;
|
||||
}
|
||||
|
||||
export const useAppBridge = (): UseAppBridgeReturn => {
|
||||
const [deviceInfo, setDeviceInfo] = useState<DeviceInfo | null>(null);
|
||||
|
||||
|
||||
const isNativeEnvironment = appBridge.isNativeEnvironment();
|
||||
const isAndroid = appBridge.isAndroid();
|
||||
const isIOS = appBridge.isIOS();
|
||||
@@ -124,7 +128,7 @@ export const useAppBridge = (): UseAppBridgeReturn => {
|
||||
toast.className = 'fixed top-4 right-4 bg-gray-800 text-white px-4 py-2 rounded-md z-50 animate-fade-in';
|
||||
toast.textContent = message;
|
||||
document.body.appendChild(toast);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(toast);
|
||||
}, duration);
|
||||
@@ -207,7 +211,7 @@ export const useAppBridge = (): UseAppBridgeReturn => {
|
||||
}
|
||||
return appBridge.safeCall(() => appBridge.closeBiometricRegistrationPopup());
|
||||
}, [isNativeEnvironment]);
|
||||
|
||||
|
||||
const shareContent = useCallback(async (content: ShareContent): Promise<void> => {
|
||||
if (!isNativeEnvironment) {
|
||||
// 웹 환경에서는 Web Share API 사용 (지원되는 경우)
|
||||
@@ -261,6 +265,35 @@ export const useAppBridge = (): UseAppBridgeReturn => {
|
||||
return result || 'ID';
|
||||
}, [isNativeEnvironment]);
|
||||
|
||||
const getNotificationSetting = useCallback(async (): Promise<boolean> => {
|
||||
if (!isAndroid) {
|
||||
console.log('getNotificationSetting: Not Android, skipping');
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await appBridge.safeCall(() => appBridge.getNotificationSetting(), { enabled: true });
|
||||
return result?.enabled ?? true;
|
||||
} catch (error) {
|
||||
console.error('Failed to get notification setting:', error);
|
||||
return true;
|
||||
}
|
||||
}, [isAndroid]);
|
||||
|
||||
const setNotificationSetting = useCallback(async (enabled: boolean): Promise<any> => {
|
||||
if (!isAndroid) {
|
||||
console.log('setNotificationSetting: Not Android, skipping');
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const result = await appBridge.safeCall(() => appBridge.setNotificationSetting(enabled));
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Failed to set notification setting:', error);
|
||||
return null;
|
||||
}
|
||||
}, [isAndroid]);
|
||||
|
||||
return {
|
||||
isNativeEnvironment,
|
||||
isAndroid,
|
||||
@@ -284,6 +317,8 @@ export const useAppBridge = (): UseAppBridgeReturn => {
|
||||
closeBiometricRegistrationPopup,
|
||||
isPushNotificationEnabled,
|
||||
openAppSettings,
|
||||
getLoginType
|
||||
getLoginType,
|
||||
getNotificationSetting,
|
||||
setNotificationSetting
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user