[🐛] "Usage of "messaging().registerDeviceForRemoteMessages()" is not required..." warning is always triggered on iOS Simulator
Issue
We have a fairly privacy and GDPR-focused app so we try and turn off as much of the Firebase auto connecting as possible. I noticed a small bug where the warning
Usage of "messaging().registerDeviceForRemoteMessages()" is not required. You only need to register if auto-registration is disabled in your 'firebase.json' configuration file via the 'messaging_ios_auto_register_for_remote_messages' property.
Will trigger even when that flag is set to false in your Firebase.json if you're running on an iOS simulator. My guess is it has something to do with the following check where this error message is logged:
@react-native-firebase/messaging/lib/index.js line 271
const autoRegister = this.firebaseJson['messaging_ios_auto_register_for_remote_messages'];
if (autoRegister === undefined || autoRegister === true) {
// eslint-disable-next-line no-console
console.warn(
`Usage of "messaging().registerDeviceForRemoteMessages()" is not required. You only need to register if auto-registration is disabled in your 'firebase.json' configuration file via the 'messaging_ios_auto_register_for_remote_messages' property.`,
);
}
But I'm honestly not sure. The exact code, setup, and build works fine on a physical iPhone.
Also, apologies for the barely filled out bug report but I figured most was not relevant. If you think any more info would be helpful I'm happy to further fill it out.
Appreciate all your work!
Project Files
Javascript
Click To Expand
package.json:
# N/A
firebase.json for react-native-firebase v6:
{
"$schema": "./node_modules/@react-native-firebase/app/firebase-schema.json",
"react-native": {
"analytics_auto_collection_enabled": false,
"google_analytics_automatic_screen_reporting_enabled": false,
"analytics_default_allow_ad_personalization_signals": false,
"app_data_collection_default_enabled": false,
"google_analytics_adid_collection_enabled": false,
"crashlytics_auto_collection_enabled": false,
"perf_auto_collection_enabled": false,
"crashlytics_debug_enabled": false,
"crashlytics_javascript_exception_handler_chaining_enabled": false,
"in_app_messaging_auto_collection_enabled": false,
"messaging_ios_auto_register_for_remote_messages": false,
"messaging_auto_init_enabled": false,
"android_task_executor_maximum_pool_size": 10,
"android_task_executor_keep_alive_seconds": 3,
"analytics_idfv_collection_enabled": false
}
}
iOS
Click To Expand
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
// N/A
android/app/build.gradle:
// N/A
android/settings.gradle:
// N/A
MainApplication.java:
// N/A
AndroidManifest.xml:
<!-- N/A -->
Environment
Click To Expand
react-native info output:
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- [x] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
react-native-firebaseversion you're using that has this issue:- 14.11.1
Firebasemodule(s) you're using that has the issue:- cloud messaging (messages)
- Are you using
TypeScript?- Y
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Strange - so if I read this correctly this is a simulator / real device difference? You confirm that when you run on a real device with the same firebase.json (after a pod install and build on each) that simulator prints this but real device does not?
That's unexpected for sure but I don't use this flag personally so I may have missed it.
Relevant data might be Xcode version, runtime specifics of simulator and real device
Yeah, it's the same build on both the simulator and physical device. The other relevant information might be that I'm using Expo and the builds are performed through EAS. I doubt it has much to do with this, but I figured I'd mention it since Xcode version on the physical build is a tad out of my control. However, in terms of the simulator, it's running 15.2 with xcode version 13.4.1
If I understand correctly and this is not affecting production builds, implying that your user's expectations of privacy are not degraded, then this won't be as a high priority.
But it's still puzzling. I'm trying to think under what conditions you might have a firebase.json with those contents and still hit that code branch, and I can't think of one. That implies that perhaps the firebase.json processing is totally failing somehow
These lines, where the firebase.json is included as a base64 string in Info.plist for runtime availability:
https://github.com/invertase/react-native-firebase/blob/a05f63d5cb208d9b6f645a0743584f58a942d6bc/packages/app/ios_config.sh#L77-L88
But there was a problem there recently (#6194) which I fixed and turned into a total build failure (#6234) so it should not be able to slip past there without your firebase.json being ingested in the plist and then loaded into app at runtime
Now we've got more pertinent information missing that the template would have provided ;-) - are you on a version that includes that change?
14.9.2 or higher https://github.com/invertase/react-native-firebase/commit/1f609d379117532d014bc44735827d38d79a36e9
I got the same warning message in my project. However I also got it with debug builds on a physical device. I did use pod install after changing the firebase.json file. I tested the rnfbdemo repo and there the problem did not appear. RNFirebase 15.4.0, RN 0.67.4.
I think the firebase.json file was entirely not used, because messaging().isAutoInitEnabled === true even though firebase.json contained "messaging_auto_init_enabled": false.
Might be related to the problems in https://github.com/invertase/react-native-firebase/issues/3902#issuecomment-925071370 ?
What seemed to solve the problem for me was to not use abstract_target in my Podfile. Perhaps my configuration was invalid/incomplete, or react-native-firebase makes some assumptions about this?
In case it helps these were my changes:
Old Podfile (firebase.json not working):
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
# Convert all "react-native-permissions" pods into static libraries (needed if we have "use_frameworks!")
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment the line corresponding to your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
# $RNFirebaseAsStaticFramework = true # suggested by react-native-firebase
abstract_target 'Apps' do
config = use_native_modules!
use_frameworks! # needed for react-native-firebase
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
# Enable modules of "react-native-permissions" library
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
# Do the above for each app target
target 'FirstTarget'
target 'SecondTarget'
end
New Podfile (works):
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
# $RNFirebaseAsStaticFramework = true # suggested by react-native-firebase
# Define common code for each target in a function
# Cannot contain pre- or post_install (error: multiple not allowed)
# Previously used abstract_target but that caused problems with react-native-firebase (firebase.json was not used)
def shared_pods
config = use_native_modules!
use_frameworks! # needed for react-native-firebase
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
# Enable modules of "react-native-permissions" library
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
# Enables Flipper.
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
end
target 'FirstTarget' do
shared_pods
end
target 'SecondTarget' do
shared_pods
end
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
# Convert all "react-native-permissions" pods into static libraries (needed if we have "use_frameworks!")
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment the line corresponding to your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
Strange... I use abstract_target in my work app, and I do not see this problem / I do see my firebase.json being ingested + used in my app
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.