Closed Amurmurmur closed 1 year ago
Please, try opening your app in the different Telegram application. I assume, problem is specific to the Telegram app for macOS only. It is probably a bug in the platform, not in the package, but it seems like I know the solution
As I found out with some other external developer, problem occurs due to the incorrect behaviour of the Telegram app for macOS. The reason is the native application is not responding to web_app_request_theme
method, but it must.
The other important note here, that I could not reproduce this problem using the same native application version. I will release the solution today and will notify you about that.
@twa.js/sdk and @twa.js/sdk-react were updated. Try using the latest versions and let me know if my solution doesn't solve the problem.
I also added project you could use to test the functionality. Just clone the repo and do the following:
cd apps/react-sdk-example
pnpm i
pnpm run dev
Just tested worked like a charm! 🚀🚀🚀🚀🚀🚀 however another issues from the example
import { useBackButton, useWebApp } from "@twa.js/sdk-react";
import { useEffect } from "react";
export const Root = () => {
const backButton = useBackButton();
const webApp = useWebApp();
// When App is attached to DOM, lets show back button and
// add "click" event handler, which should close current application.
useEffect(() => {
const listener = () => {
console.log("CLICK")
webApp.close();
};
backButton.on('click', listener);
backButton.show();
return () => {
backButton.off('click', listener);
backButton.hide();
};
// We know, that backButton and webApp will never change,
// but let's follow React rules.
}, [backButton, webApp]);
return (
<div style={{ color: 'red' }}>Root</div>
)
}
The listener doesnt get triggered. The back button appears but once I click one it, it doesnt fire an event.
EDIT: the sdk doesnt get initialised on iOS, using the latest Telegram app
ok solution is found I had
<script src="https://telegram.org/js/telegram-web-app.js"></script>
in my index.html, removing it solved initialisation problems.
GG to @heyqbnk for resolving a matter so quickly !
Describe the bug Just copy pasted what was in the docs to setup a minimul Webapp
When I call this: in my App const webApp = useWebApp();
useEffect(() => { webApp.ready(); }, [webApp]);
To Reproduce Steps to reproduce the behavior: Follow the guide here: https://docs.twa.dev/docs/libraries/twa-js-sdk-react
Expected behavior A clear and concise description of what you expected to happen.
My main.tsx:
my app.tsx
my root.tsx
Loader gets stuck at Warming up SDK. When console logging the sdk: {components: null, didInit: true, error: null}