@@ -5,7 +5,7 @@ import type { EventPayload } from '@telegram-apps/bridge';
55import type { Computed } from '@telegram-apps/signals' ;
66
77import { defineMountFn } from '@/scopes/defineMountFn.js' ;
8- import { request } from '@/globals.js' ;
8+ import { postEvent , request } from '@/globals.js' ;
99import { createWrapComplete } from '@/scopes/wrappers/createWrapComplete.js' ;
1010import { createWrapSupported } from '@/scopes/wrappers/createWrapSupported.js' ;
1111import { NotAvailableError } from '@/errors.js' ;
@@ -16,6 +16,7 @@ import { createComputed, createSignal } from '@/signals-registry.js';
1616
1717const COMPONENT_NAME = 'locationManager' ;
1818const CHECK_LOCATION_METHOD = 'web_app_check_location' ;
19+ const OPEN_SETTINGS_METHOD = 'web_app_open_location_settings' ;
1920
2021export interface State {
2122 /**
@@ -70,7 +71,6 @@ export const isAccessRequested = fromState('accessRequested');
7071 * @see location_checked
7172 */
7273function eventToState ( event : EventPayload < 'location_checked' > ) : State {
73- console . log ( event ) ;
7474 let available = false ;
7575 let accessRequested : Maybe < boolean > ;
7676 let accessGranted : Maybe < boolean > ;
@@ -159,10 +159,28 @@ const [
159159 * const location = await requestLocation();
160160 * }
161161 */
162- export const requestLocation = wrapComplete ( 'getLocation ' , reqLocationFn ) ;
162+ export const requestLocation = wrapComplete ( 'requestLocation ' , reqLocationFn ) ;
163163export const [ , requestLocationPromise , isRequestingLocation ] = tReqLocationPromise ;
164164export const [ , requestLocationError ] = tReqLocationError ;
165165
166+ /**
167+ * Opens the location access settings for bots. Useful when you need to request location access
168+ * from users who haven't granted it yet.
169+ *
170+ * Note that this method can be called only in response to user interaction with the Mini App
171+ * interface (e.g., a click inside the Mini App or on the main button).
172+ * @since Mini Apps v8.0
173+ * @throws {FunctionNotAvailableError } The environment is unknown
174+ * @throws {FunctionNotAvailableError } The SDK is not initialized
175+ * @throws {FunctionNotAvailableError } The function is not supported
176+ * @example
177+ * if (openSettings.isAvailable()) {
178+ * openSettings();
179+ * }
180+ */
181+ export const openSettings = wrapSupported ( 'openSettings' , ( ) => {
182+ postEvent ( OPEN_SETTINGS_METHOD ) ;
183+ } , OPEN_SETTINGS_METHOD ) ;
166184
167185/**
168186 * Unmounts the component.
0 commit comments