fix: 토스판도 처음 들어오면 위치 권한을 물어 내 동네로 맞춤 (기본값 마포구에 머물던 것)

This commit is contained in:
minaChoi committed 2026-10-13 16:52:06 +09:00
1 parent 07290597a0
commit 7dcb40df78
2 files changed
+4 -5

No files matched your search

+3 -4
View File
@@ -49,10 +49,9 @@ export function RegionProvider({ children }: { children: ReactNode }) {
.catch(() => setLocateStatus('error'))
}, [setRegion])
// ask=false 는 처음 들어왔을 때: 토스에서는 권한 창을 띄우지 않고, 이미 허용한 사람만 위치로 맞춘다
const findNearest = useCallback((onFound?: () => void, ask = true) => {
const findNearest = useCallback((onFound?: () => void) => {
if (IS_TOSS) {
tossLocation(ask).then(
tossLocation(true).then(
(loc) => {
if (loc === null) setLocateStatus('idle')
else if (loc === 'denied') setLocateStatus('denied')
@@ -83,7 +82,7 @@ export function RegionProvider({ children }: { children: ReactNode }) {
// 처음 온 사람만 위치 권한을 물어 가장 가까운 구로 맞춘다
useEffect(() => {
if (!stored && canLocate) findNearest(undefined, false)
if (!stored && canLocate) findNearest()
}, [stored, canLocate, findNearest])
const api = useMemo(() => ({ region, setRegion, locate, locateStatus }), [region, setRegion, locate, locateStatus])
+1 -1
View File
@@ -33,7 +33,7 @@ export async function tossShare(image: Blob, fileName: string, title: string): P
export type TossLocation = { lat: number; lon: number } | 'denied'
/** 토스: 권한이 이미 있을 때만 위치를 읽는다. ask 면 권한 창을 띄운다 (앱에 들어오자마자 띄우지 않으려고) */
/** 토스: 위치를 읽는다. 권한이 없으면 ask 일 때만 권한 창을 띄운다 */
export async function tossLocation(ask: boolean): Promise<TossLocation | null> {
const { Accuracy, Device } = await sdk()
let status = await Device.getLocation.getPermission()