1

After launching app from tapping on push notification, app is showing white blank screen when quit app with hardware back button. Logged react navigation stack but showing only 1 route in the stack.

I've tried to override the back function by using BackHandler.exitApp() but getting white screen as well. Same goes to the launchMode in AndroidManifest.xml. Tried all possible types but still getting same behaviour. When launch app normally, this issue doesn't happen. Any idea?

Launch normally:

Launch -> Go to MainScreen -> Press back button -> Quit app

Launch from push notification:

Launch -> Go to MainScreen -> Press back button -> Show white screen -> Press back button -> Quit app

//App.tsx
<SafeAreaProvider>
   <AuthContext setLoggedInState={setLoggedIn}>
      <NavigationContainer>
         <MainBottomTabNav isLoggedIn={isLoggedIn} />
         <DropdownAlert />
      </NavigationContainer>
   </AuthContext>
</SafeAreaProvider>
//AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.myapp">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.front" android:required="false" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
      android:networkSecurityConfig="@xml/network_security_config">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleInstance"
        android:exported="true"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="myapp" />
        </intent-filter>
      </activity>
    </application>
</manifest>

Update:

  1. So I tried to remove the myapp intent-filter, change to other launchMode but still returned white screen.
  2. Checked out the adb logcat and notice that OpenNotificationActivity is attached before MainActivity. Suspecting this was the cause but still not sure how to disable/bypass the notification activity directly to main
  3. Tried adding android:noHistory="true" to MainActivity and error still persist. Added logcat for reference.

Logcat

//press back once - show empty screen
2023-01-10 16:46:00.312 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: ViewPostIme key 0
2023-01-10 16:46:00.542 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: ViewPostIme key 1
2023-01-10 16:46:00.567 19681-19681/com.myapp D/SensorManager: unregisterListener :: com.facebook.react.common.ShakeDetector@f13d4ca
2023-01-10 16:46:00.568 19681-19681/com.myapp I/PUSHER_WRAPPER: onPause: MainActivity
2023-01-10 16:46:00.581 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: stopped(false) old=true
2023-01-10 16:46:00.584 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: stopped(false) old=false
2023-01-10 16:46:00.601 19681-19681/com.myapp I/SurfaceControl: assignNativeObject: nativeObject = 0 Surface(name=null)/@0x7104eed / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1824 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
2023-01-10 16:46:00.603 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)0 dur=11 res=0x7 s={true -5476376619252260592} ch=true fn=-1
2023-01-10 16:46:00.613 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546288864]
2023-01-10 16:46:00.613 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546288864]
2023-01-10 16:46:00.613 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546335504]
2023-01-10 16:46:00.613 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546335504]
2023-01-10 16:46:00.614 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546261408]
2023-01-10 16:46:00.614 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546261408]
2023-01-10 16:46:00.616 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
2023-01-10 16:46:00.641 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
2023-01-10 16:46:00.641 19681-19681/com.myapp D/InputMethodManager: prepareNavigationBarInfo() DecorView@a0792d4[OpenNotificationActivity]
2023-01-10 16:46:00.641 19681-19681/com.myapp D/InputMethodManager: getNavigationBarColor() -16711423
2023-01-10 16:46:00.642 19681-19681/com.myapp D/InputMethodManager: prepareNavigationBarInfo() DecorView@a0792d4[OpenNotificationActivity]
2023-01-10 16:46:00.642 19681-19681/com.myapp D/InputMethodManager: getNavigationBarColor() -16711423
2023-01-10 16:46:00.642 19681-19681/com.myapp V/InputMethodManager: Starting input: tba=com.myapp ic=null mNaviBarColor -16711423 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
2023-01-10 16:46:00.643 19681-19681/com.myapp D/InputMethodManager: startInputInner - Id : 0
2023-01-10 16:46:00.643 19681-19681/com.myapp I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2023-01-10 16:46:00.647 19681-19681/com.myapp D/InputTransport: Input channel constructed: 'ClientS', fd=171
2023-01-10 16:46:00.647 19681-19681/com.myapp D/InputTransport: Input channel destroyed: 'ClientS', fd=163
2023-01-10 16:46:00.660 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546263872]
2023-01-10 16:46:00.660 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546263872]
2023-01-10 16:46:00.669 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546277072]
2023-01-10 16:46:00.669 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546277072]
2023-01-10 16:46:00.669 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546240816]
2023-01-10 16:46:00.669 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546240816]
2023-01-10 16:46:00.968 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546329520]
2023-01-10 16:46:00.968 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546329520]
2023-01-10 16:46:00.969 19681-19681/com.myapp I/SurfaceControl: assignNativeObject: nativeObject = 0 Surface(name=null)/@0x4dd8fc / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1814 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
2023-01-10 16:46:00.969 19681-19681/com.myapp I/SurfaceControl: assignNativeObject: nativeObject = 0 Surface(name=null)/@0xc5f1f73 / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1824 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
2023-01-10 16:46:00.970 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=9 res=0x5 s={false 0} ch=true fn=103
2023-01-10 16:46:00.972 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: stopped(true) old=false
2023-01-10 16:46:00.984 19681-19681/com.myapp I/PUSHER_WRAPPER: onDestroy: MainActivity
2023-01-10 16:46:00.984 19681-19681/com.myapp E/unknown:ReactNative: Tried to remove non-existent frame callback
2023-01-10 16:46:00.986 19681-19681/com.myapp I/ViewRootImpl@2bf2385[MainActivity]: dispatchDetachedFromWindow
2023-01-10 16:46:00.991 19681-19681/com.myapp D/InputTransport: Input channel destroyed: 'd04450c', fd=168
2023-01-10 16:46:01.028 19681-26631/com.myapp W/unknown:ReactNative: StatusBarModule: Ignored status bar change, current activity is null.
2023-01-10 16:46:01.028 19681-26631/com.myapp W/unknown:ReactNative: StatusBarModule: Ignored status bar change, current activity is null.
2023-01-10 16:46:01.028 19681-26631/com.myapp W/unknown:ReactNative: StatusBarModule: Ignored status bar change, current activity is null.

//press back twice - quit app
2023-01-10 16:46:30.821 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: ViewPostIme key 0
2023-01-10 16:46:31.018 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: ViewPostIme key 1
2023-01-10 16:46:31.089 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
2023-01-10 16:46:31.116 19681-26629/com.myapp I/ReactNativeJNI: Memory warning (pressure level: TRIM_MEMORY_UI_HIDDEN) received by JS VM, ignoring because it's non-severe
2023-01-10 16:46:31.129 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546259120]
2023-01-10 16:46:31.129 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546259120]
2023-01-10 16:46:31.130 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546216000]
2023-01-10 16:46:31.130 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546216000]
2023-01-10 16:46:31.130 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546263872]
2023-01-10 16:46:31.130 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546263872]
2023-01-10 16:46:31.187 19681-19681/com.myapp D/InputTransport: Input channel destroyed: 'ClientS', fd=171
2023-01-10 16:46:31.201 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546206672]
2023-01-10 16:46:31.201 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546206672]
2023-01-10 16:46:31.459 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject s[-5476376623546209664]
2023-01-10 16:46:31.459 19681-19681/com.myapp I/SurfaceControl: nativeRelease nativeObject e[-5476376623546209664]
2023-01-10 16:46:31.460 19681-19681/com.myapp I/SurfaceControl: assignNativeObject: nativeObject = 0 Surface(name=null)/@0xae285e1 / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1814 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
2023-01-10 16:46:31.461 19681-19681/com.myapp I/SurfaceControl: assignNativeObject: nativeObject = 0 Surface(name=null)/@0x7104eed / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1824 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
2023-01-10 16:46:31.463 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=9 res=0x5 s={false 0} ch=true fn=2
2023-01-10 16:46:31.464 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: stopped(true) old=false
2023-01-10 16:46:31.470 19681-19681/com.myapp I/ViewRootImpl@e02686c[OpenNotificationActivity]: dispatchDetachedFromWindow
2023-01-10 16:46:31.474 19681-19681/com.myapp D/InputTransport: Input channel destroyed: '772477 ', fd=134
Annie Tan
  • 259
  • 4
  • 14

1 Answers1

0

I think there are two scenarios in which this can happen

  1. the MainScreen is not defined as lunchable activity in androidManifest file (so check that out)

  2. react native is adding an other activity to open your MainScreen

anyways I think the best way is to close the app yourself when user presses the backButton in android you can use this:

import React, { BackHandler } from 'react-native';

BackHandler.exitApp();

this is for android only

if this didn't help please share your androidManifest file here because I am sure the problem is there somewhere

EDIT

based on comments I understand this is happening because

it seems to be causing from b8ne/react-native-pusher-push-notifications library. I noticed that OpenNotificationActivity is attached before MainActivity. Hence when first backPress is triggered, it's destroying MainActivity leaving white screen from OpenNotificationActivity

so please add noHistory attribute to your MainActivity in your AndroidManifest file for more information please take a look at the no history flag docs

Pouya Danesh
  • 1,557
  • 2
  • 19
  • 36
  • Thanks for the suggestion. However, like I mentioned earlier in my question, I've tried this approach but it's still showing the white screen. I've updated my question with `AndroidManifest.xml` code – Annie Tan Jan 06 '23 at 00:49
  • seems like a problem within react native itself, seems like it doesn't understand `android:name="android.intent.action.VIEW"` but if you really are curious see what activity appears after back by showing a log after backPress so we can know what is happening exactly – Pouya Danesh Jan 07 '23 at 09:31
  • After checking out the adb logcat, it seems to be causing from `b8ne/react-native-pusher-push-notifications` library. I noticed that `OpenNotificationActivity` is attached before `MainActivity`. Hence when first backPress is triggered, it's destroying `MainActivity` leaving white screen from `OpenNotificationActivity`. But I still have no idea on how to prevent the push notification activity from attaching – Annie Tan Jan 09 '23 at 01:54
  • so I will update my answer – Pouya Danesh Jan 09 '23 at 11:47
  • Tried that too but still persist. Added logcat for reference. – Annie Tan Jan 10 '23 at 08:52