-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[0.76] updating appProperties does not work on iOS #48551
Comments
Warning Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:
|
When I disable the new architecture, notifications works well. |
@aliceni81 thanks for opening the issue and sorry for the disruption this is causing. I believe that the problem might be in the AppDelegate code. Can you try to change it as it follows: 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];
+ BOOL appStarted = [super application:application didFinishLaunchingWithOptions:launchOptions];
[FIRApp configure];
[application registerForRemoteNotifications];
- return [super application:application didFinishLaunchingWithOptions:launchOptions];
+ return appStarted; A possible problem is that the the firebase app is starting before the React Native environment is started, and that's make the code not working fine. |
@cipolleschi Thanks for you reply. |
@aliceni81 can you prepare a small reproducer using this template? It will help me investigate the issue. |
@cipolleschi Honestly, I'm new to react native. Have no idea how to reproduce it with react-native-firebase as it requires complicated settings. |
It appears you need to give up on injecting appProperties values in the Instead it appears that the race needs to be avoided by implementing an observer for the [[NSNotificationCenter defaultCenter] addObserverForName:RCTJavaScriptDidLoadNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
// Goal: set appProperties here somehow?
// Unsure but inside Xcode the IDE should guide you to the right object and method to call...
// 1- it will involve getting a handle on RCTRootView somehow,
// - here is an example getting the RCTRootView https://github.com/invertase/react-native-firebase/blob/082a1e496cb1f8496f53869d9ab9e6f88ecbdc00/packages/messaging/ios/RNFBMessaging/RNFBMessaging%2BNSNotificationCenter.m#L79-L88
//
// 2- determining foreground or background state of the app,
// - here is example code getting that state https://github.com/invertase/react-native-firebase/blob/082a1e496cb1f8496f53869d9ab9e6f88ecbdc00/packages/messaging/ios/RNFBMessaging/RNFBMessaging%2BAppDelegate.m#L158
//
// - and then setting new appProperties value into RCTRootView.appProperties with the isHeadless state ?
// - example code adding a property https://github.com/facebook/react-native/blob/53ff6133a7da8a35128cbbef913793df4a5dea70/packages/rn-tester/RNTester/NativeExampleViews/UpdatePropertiesExampleView.mm#L76-L79
// - note that the property says it should be set on main thread only https://github.com/facebook/react-native/blob/53ff6133a7da8a35128cbbef913793df4a5dea70/packages/react-native/React/Base/RCTRootView.h#L99
// - here is an example of using main thread in a block: https://github.com/invertase/react-native-firebase/blob/082a1e496cb1f8496f53869d9ab9e6f88ecbdc00/packages/messaging/ios/RNFBMessaging/RNFBMessaging%2BAppDelegate.m#L166-L170
}];
|
@mikehardy Really appreciate your reply. The settings I have is refer to the react-native-firebase official documentation. https://rnfirebase.io/messaging/usage#background-application-state. |
@aliceni81 unsure if only old arch, or new, best way to get docs updated is to test the idea to make sure it works then post a PR with the edit for what you tested. I likely won't have time |
Description
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
I have the the following code in AppDelegate.mm:
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:
#20115
invertase/react-native-firebase#5388
Steps to reproduce
React Native Version
0.76.5
Affected Platforms
Runtime - iOS
Areas
Bridgeless - The New Initialization Flow
Output of
npx react-native info
Stacktrace or Logs
Reproducer
/
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: