Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
691 stars 191 forks source link

[Bug]: "Method: web_app_set_bottom_bar_color not supported" #528

Closed vaughn-xyz closed 1 week ago

vaughn-xyz commented 2 weeks ago

Telegram Application

Other

Describe the Bug

Using the latest @telegram-apps/sdk-react when we call init() for our Telegram mini-app this causes older/outdated Telegram clients (Web, Mobile) to crash.

My suspicion is under the hood of that init() call source it must be attempting to set some default functionalities without wrapping those calls in safety try/catch or using the appropriate X.isSupported() calls internally.

We are able to fix this by wrapping the init() call in a try/catch as we noticed that this error was still bubbling up even after wrapping our own theme sets in try/catch

try {
        console.info('[TG::App] Attempting to apply theme');
        const barColor: RGB = '#000000';
        if (app.setHeaderColor.isSupported()) {
          app.setHeaderColor(barColor);
        }

        if (app.setBackgroundColor.isSupported()) {
          app.setBackgroundColor(barColor);
        }

        // TODO investigate why this breaks
        if (app.setBottomBarColor.isSupported()) {
          app.setBottomBarColor(barColor);
        }
      } catch (error: any) {
        console.error('[TG::App] Theme error', error?.message || 'unknown');
      }

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Behavior

We can safely call init() without having to wrap it in a try/catch

heyqbnk commented 2 weeks ago

I don't see the init function usage in your code.

And what the error do you have in console?

tang123qi commented 3 days ago

my code does not use related methods: web_app_set_bottom_bar_color also reports an error; how to solve this?

vaughn-xyz commented 3 days ago

@tang123qi I discovered this is called within the init() or miniApp initialize function.

To fix this for my project I had to wrap the unit call with try/catch