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

[🐛] Bug Report - App displays nothing if receives a notification in quit state #8217

Open
aliceni81 opened this issue Jan 8, 2025 · 1 comment
Labels

Comments

@aliceni81
Copy link

aliceni81 commented Jan 8, 2025

Hi, I'm using react native v0.76.5 (new architecture is enabled) and react-native-firebase/messaging v21.6.2.

According to the documentation, I have the following code in index.js

messaging().setBackgroundMessageHandler(async remoteMessage => {
  //
});

const HeadlessCheck = ({ isHeadless }) => {
  if (isHeadless) return null;
  return <App />;
}

AppRegistry.registerComponent(appName, () => HeadlessCheck);

I have the the following code in AppDelegate.mm:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"gk_research_app_staging";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  // self.initialProps = @{};

  // return [super application:application didFinishLaunchingWithOptions:launchOptions];
  self.initialProps = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
  [FIRApp configure];
  [application registerForRemoteNotifications];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

I have a problem for iOS device - when the app is in quit state and receives a notification, after a few seconds, I click the notification which makes the app open, but nothing is shown. I know it's because of "if (isHeadless) return null;".

The following logs are in my console:
When the app is opened(foreground/background):
Running "test_app" with {"rootTag":1,"initialProps":{"concurrentRoot":true,"isHeadless":false},"fabric":true}
When the app is quit and receives a notification, the bundle is re-generated:
Running "test_app" with {"rootTag":1,"initialProps":{"concurrentRoot":true,"isHeadless":true},"fabric":true}
When re-open the app or open the app by the notification, the bundle is not regenerated and keep the last state:
Running "test_app" with {"rootTag":1,"initialProps":{"concurrentRoot":true,"isHeadless":true},"fabric":true}

This issue does not happen when the app is already open, no matter if it is in foreground or background state, because the bundle will not be re-generated.

To make the app UI display, I need to exit the app and open the app again which cause the bundle re-generated:
Running "test_app" with {"rootTag":1,"initialProps":{"concurrentRoot":true,"isHeadless":false},"fabric":true}

How can I solve this issue?
I need your help!!!

Related:
#5388

I've submitted a bug report in react native:
facebook/react-native#48551

@aliceni81 aliceni81 changed the title [🐛] Bug Report Title - CHANGE ME [🐛] Bug Report - App displays nothing if receives a notification in quit state Jan 8, 2025
@aliceni81
Copy link
Author

@mikehardy Can you please help? Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant