React-native: StatusBar is not translucent when app opened from notification

Created on 7 Jun 2018  路  3Comments  路  Source: facebook/react-native

Environment

  • OS : Android/Didn't try on IOS
  • React Native version : 0.51.0
  • Node : 8.9.3
  • Android Studio : 3.0.1
  • Device : Wiko Tommy 2
  • RNFirebase Version : 4.0.0

Description

My app is coded to draw under the StatusBar at the top of the device :
<StatusBar translucent backgroundColor='rgba(0,0,0,0)' barStyle='light-content' />

It works perfectly when I open the app. But however, when the app is opened from a notification sent from Firebase Cloud Functions, the StatusBar is not translucent, and my app does not draw under the StatusBar anymore, even if it renders a screen with :
<StatusBar translucent backgroundColor='rgba(0,0,0,0)' barStyle='light-content' /> set in it.

I tried also to not set translucent, but a color to the StatusBar , and exactly the same, the StatusBar code is ignored when opened from a notification

I'm rendering <StatusBar translucent backgroundColor='rgba(0,0,0,0)' barStyle='light-content' /> in App.js , with my StackNavigation, so at the very begining of the app launching.

I have tried to put it in a component which mounts later, and it doesn't do anything, exactly the same problem.

Locked

Most helpful comment

Try using the statusbar API directly outside the components or on constructor/componentWillMount:

https://facebook.github.io/react-native/docs/statusbar.html#methods

import {StatusBar} from 'react-native';

StatusBar.setBackgroundColor("rgba(0,0,0,0)")
StatusBar.setBarStyle("light-content")
StatusBar.setTranslucent(true)

All 3 comments

It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Try using the statusbar API directly outside the components or on constructor/componentWillMount:

https://facebook.github.io/react-native/docs/statusbar.html#methods

import {StatusBar} from 'react-native';

StatusBar.setBackgroundColor("rgba(0,0,0,0)")
StatusBar.setBarStyle("light-content")
StatusBar.setTranslucent(true)

Thank you ! It worked !

Was this page helpful?
0 / 5 - 0 ratings