@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
92 lines (91 loc) • 3.96 kB
TypeScript
import { AbortablePromise } from 'better-promises';
import { Computed } from '@telegram-apps/signals';
import { AsyncOptions } from '../../../types.js';
export interface State {
/**
* If true, indicates that location data tracking is available on the current device.
*/
available: boolean;
/**
* Indicates whether the app has previously requested permission to track location data.
*/
accessRequested: boolean;
/**
* Indicates whether the user has granted the app permission to track location data.
*
* If false and `accessRequested` is true may indicate that:
*
* - The user has simply canceled the permission popup.
* - The user has denied the app permission to track location data.
*/
accessGranted: boolean;
}
/**
* Signal indicating whether the location data tracking is currently supported.
*/
export declare const isSupported: Computed<boolean>;
/**
* Signal indicating whether the location data tracking is currently available.
*/
export declare const isAvailable: Computed<boolean>;
/**
* Signal indicating whether the user has granted the app permission to track location data.
*/
export declare const isAccessGranted: Computed<boolean>;
/**
* Signal indicating whether the app has previously requested permission to track location data.
*/
export declare const isAccessRequested: Computed<boolean>;
/**
* Mounts the location manager component.
* @since Mini Apps v8.0
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (mount.isAvailable()) {
* await mount();
* }
*/
export declare const mount: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: AsyncOptions | undefined) => AbortablePromise<void>, true, never>;
export declare const mountPromise: Computed<AbortablePromise<any> | undefined>, isMounting: Computed<boolean>;
export declare const mountError: Computed<Error | undefined>;
export declare const _isMounted: import('@telegram-apps/signals').Signal<boolean>, isMounted: Computed<boolean>;
/**
* Requests location data.
* @since Mini Apps v8.0
* @returns Promise with location data.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @throws {ConcurrentCallError} Location request is currently in progress
* @throws {NotAvailableError} Location data tracking is not available
* @example
* if (requestLocation.isAvailable()) {
* const location = await requestLocation();
* }
*/
export declare const requestLocation: import('../../wrappers/wrapSafe.js').SafeWrapped<(options?: AsyncOptions) => AbortablePromise<any>, true, never>;
export declare const requestLocationPromise: Computed<AbortablePromise<any> | undefined>, isRequestingLocation: Computed<boolean>;
export declare const requestLocationError: Computed<Error | undefined>;
/**
* Opens the location access settings for bots. Useful when you need to request location access
* from users who haven't granted it yet.
*
* Note that this method can be called only in response to user interaction with the Mini App
* interface (e.g., a click inside the Mini App or on the main button).
* @since Mini Apps v8.0
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (openSettings.isAvailable()) {
* openSettings();
* }
*/
export declare const openSettings: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, true, never>;
/**
* Unmounts the component.
*/
export declare function unmount(): void;