kadiraydinli / react-native-system-navigation-bar

React Native lets you customize the navigation bar for Android.
https://www.npmjs.com/package/react-native-system-navigation-bar
MIT License
265 stars 19 forks source link

Bug > When using with notifee the app crash #29

Closed TacticCoder closed 1 year ago

TacticCoder commented 1 year ago

Hi guys! FIrst of all thank you for this project! After integration with notifee and firebase cloud messaging background handler, i have found this bug:

2022-10-28 14:09:01.178 13660-13660/app.vidit E/AndroidRuntime: FATAL EXCEPTION: main
    Process: app.vidit, PID: 13660
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference
        at com.reactnativesystemnavigationbar.SystemNavigationBarModule.lambda$setSystemUIFlags$3$com-reactnativesystemnavigationbar-SystemNavigationBarModule(SystemNavigationBarModule.java:245)
        at com.reactnativesystemnavigationbar.SystemNavigationBarModule$$ExternalSyntheticLambda3.run(Unknown Source:6)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8751)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

i was easily fixed that with adding the following code to the native module(for every function that check for the view):

            if(getCurrentActivity() == null) {
              return;
            }
kadiraydinli commented 1 year ago

Hi @TacticCoder, thanks for reporting bug. Can you recheck issue in the latest version?

kadiraydinli commented 1 year ago

I added this in every function in the last version. It shouldn't be a problem anymore. If you encounter the problem again, feel free to turn it back on.