Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@capacitor/status-bar sometimes work, sometimes not #1720

Closed
SvenBudak opened this issue Aug 6, 2023 · 4 comments
Closed

@capacitor/status-bar sometimes work, sometimes not #1720

SvenBudak opened this issue Aug 6, 2023 · 4 comments

Comments

@SvenBudak
Copy link

Hi! I struggle with @capacitor/status-bar

In my Ionic Angular App i added to app.component this code:

ngOnInit() {
  this.appStart();
}

appStart() {
    if (isPlatform('capacitor')) {
      console.log('App is running on Capacitor!');
      this.platform.ready().then(() => {
        console.log('Platform ready');
        StatusBar.setStyle({style: Style.Light}).then(r => console.log(r));
        StatusBar.setBackgroundColor({color: '#F2D492'}).then(r => console.log(r));
        setTimeout(() => {
          console.log('1 sec is done');
          // StatusBar.setStyle({style: Style.Light}).then(r => console.log(r)); With a timeout it works better
          // StatusBar.setBackgroundColor({color: '#F2D492'}).then(r => console.log(r)); With a timeout it works better
        }, 1000);
      });
    }
  }

For some reason in the emulator it works mostly well. but when i create a build with android studio and upload the app to my real android device, the statusbar dont change anything. When i add a TimeOut of 1 second, then it is also working in my builded App on my real device.

I debugged with my chrome inspector tool and saw that my real android device returns undefined

image

This is my versioning:

Capacitor Plugins

@capacitor

Cordova Plugins

Dependencies

@Angular-devkit

@angular-eslint

@angular

@capacitor

@directus

@Ionic

@types

@typescript-eslint

Other Dependencies

@Ionitron
Copy link
Collaborator

This issue needs more information before it can be addressed.
In particular, the reporter needs to provide a minimal sample app that demonstrates the issue.
If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks!
Ionitron 💙

@SvenBudak
Copy link
Author

how should i provide a example? the statusbar works only natively.

I can copy paste the code from my opening post into a new app, build a apk and send you the file if you want.
but i am not sure if this will help you.

I saw on discord 2 other people they have the same problem.

@jcesarmobile
Copy link
Member

Most likely it's the same problem as #1160
On Android 13 you can't do any device UI changes during the splash screen is being shown, or if you do them, they get restored once the splash is hidden.
So the setTimeout will work if it's longer than the time the splash is being displayed.

You can also try adding launchFadeOutDuration config option with 0 value so there is no animation as that's what seem to be messing with the device UI changes.
https://capacitorjs.com/docs/apis/splash-screen#configuration

@jcesarmobile jcesarmobile closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2023
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 27, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants