diff --git a/src/main.tsx b/src/main.tsx index 1619030..2b9b765 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -27,6 +27,16 @@ import { getCachedFullscreenEnabled, isTelegramMobile } from './hooks/useTelegra import './i18n'; import './styles/globals.css'; +// Polyfill Object.hasOwn for older iOS/Android WebViews (Safari < 15.4, old Chrome). +// @telegram-apps/sdk v3 depends on valibot which uses Object.hasOwn internally. +// Without this, init() throws LaunchParamsRetrieveError on affected devices. +// See: https://github.com/Telegram-Mini-Apps/tma.js/issues/683 +if (typeof (Object as { hasOwn?: unknown }).hasOwn !== 'function') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (Object as any).hasOwn = (obj: object, prop: PropertyKey): boolean => + Object.prototype.hasOwnProperty.call(obj, prop); +} + // Only initialize Telegram SDK when running inside Telegram const isTelegramEnv = !!(window as unknown as Record).TelegramWebviewProxy ||