invertase / react-native-firebase

πŸ”₯ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

[πŸ›] firebase.json not respecting "messaging_ios_auto_register_for_remote_messages" property on iOS #4428

Closed todesignandconquer closed 3 years ago

todesignandconquer commented 3 years ago

Issue

This is a very straightforward vanilla implementation, including a firebase.json as follows in the project root, as described here: https://rnfirebase.io/messaging/usage#auto-registration-ios

Regardless, I still get the following 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.

Project Files

Javascript

Click To Expand

#### `package.json`: ```json "@react-native-firebase/analytics": "^7.6.2", "@react-native-firebase/app": "^8.4.2", "@react-native-firebase/dynamic-links": "^7.5.3", "@react-native-firebase/iid": "^7.4.3", "@react-native-firebase/in-app-messaging": "^7.5.1", "@react-native-firebase/messaging": "^7.8.6", ... "react-native": "0.63.2", ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "messaging_ios_auto_register_for_remote_messages": false } } ``` Redux implementation: ```javascript ... import Messaging from '@react-native-firebase/messaging' ... const refreshNotifications = () => async(dispatch, getState) => { ... await Messaging().registerDeviceForRemoteMessages() const token = await Messaging().getToken() ... } ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby 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' workspace 'App' target 'App' do config = use_native_modules! use_react_native!(:path => config["reactNativePath"]) permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec" pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec" pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec" pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec" pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec" pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec" pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec" pod 'react-native-geolocation', path: '../node_modules/@react-native-community/geolocation' target 'Tests' do inherit! :complete # Pods for testing end # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. use_flipper! post_install do |installer| flipper_post_install(installer) end end ``` #### `AppDelegate.m`: ```objc ... #import "Firebase.h" ... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } ... return YES; } ```

Environment

Click to expand

**`react-native info` output:** ``` System: OS: macOS 10.15.6 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 260.61 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node Yarn: Not Found npm: 6.14.5 - ~/.nvm/versions/node/v12.14.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 23, 27, 28, 29 Build Tools: 28.0.3, 29.0.0, 29.0.3 System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild Languages: Java: 1.8.0_211 - /usr/bin/javac Python: 2.7.16 - /Users//.pyenv/shims/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **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-firebase` version you're using that has this issue:** - `^8.4.2` - **`Firebase` module(s) you're using that has the issue:** - `@react-native-firebase/messaging@^7.5.1` - **Are you using `TypeScript`?** - `N`

TommyLeong commented 3 years ago

Hello @todesignandconquer, im curious about your use case. Why do you need to disable the auto registration then register yourself to get token?

todesignandconquer commented 3 years ago

@TommyLeong I want to defer requesting/registering the Messaging token until after a user has created an account.

stale[bot] commented 3 years ago

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 the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

OlegPanfyorov commented 3 years ago

Same issue! Why did you close it? the key messaging_ios_auto_register_for_remote_messages totally ignored in firebase.json, I still see the warning

mikehardy commented 3 years ago

Why did you close it?

"we" did not close it, the stale bot closed it because it was stale. I don't recall seeing you here before, perhaps if you had posted on it before, it would not be closed? When issues get no traffic, they go stale and close, as we assume it is not really an issue - the users that log issues that are actually project-specific (not module bugs), fix them themselves then never return to close the issue is staggering, thus the stale bot.

totally ignored in firebase.json

One thing I notice about firebase.json on iOS is that it is only included in the app after rebuilding, it is built in to the app. So you have to rebuild. Did you rebuild? Further, there was a bug recently that caused the Info.plist to be processed by react-native after Firebase processed it. I think I fixed that #5153 but you should check that PR and the related issue for the exact output to expect to make sure the Info.plist in the app actually has the key in it.

Then it should work?

emadhajjar commented 3 years ago

I am still having the same issue.

mikehardy commented 3 years ago

I am making a sweep through all the various Info.plist / AndroidManifest.xml / firebase.json config settings right now and I had kept this in my queue for inspection at this time. I probed it as thoroughly as I could, I was unable to reproduce any problem.

I'm not sure what was happening here but with a firebase.json containing a false for auto register, I don't see warning messages, and the status of registration is correct before and after manual registration / un-registration.

Baterka commented 3 years ago

Seems like it is still not fixed and iOS not respecting config... Even I disabled every auto-init:

{
  "react-native": {
    "crashlytics_debug_enabled": true,
    "messaging_ios_auto_register_for_remote_messages": false,
    "messaging_auto_init_enabled": false,
    "analytics_auto_collection_enabled": false
  }
}

I am still getting "Access to Local Network" permission popup on iOS which means that messaging is still auto-initialized and calling for additional permissions.

enzomanuelmangano commented 2 years ago

I solved the problem by adding the schema. I know it's strange, since the schema is supposed to be for the intellisense editor only, but by adding the schema and restarting, I no longer saw any warnings.

{
  "$schema": "./node_modules/@react-native-firebase/app/firebase-schema.json",
  "react-native": {
    "messaging_ios_auto_register_for_remote_messages": false
  }
}
mikehardy commented 2 years ago

On ios I think the key is to understand the script that takes firebase.json into plist first must be injected into the xcode project and it only runs on build. I think this could be a good change to the docs if you want to post a PR, I keep remembering and forgetting to do it, and it's a pretty big potential gotcha

francois-pasquier commented 2 years ago

@enzomanuelmangano it did the trick, thank you πŸ™πŸ½

rivaros commented 1 year ago

@mikehardy please take a look here https://github.com/invertase/react-native-firebase/issues/6829#issuecomment-1386106571

the above issue is more likely to come from bug in react-native/cli

KrystianKasprzakPrimotly commented 11 months ago

5153

where you added this schema and what file name?

alexruzenhack commented 9 months ago

5153

where you added this schema and what file name?

@KrystianKasprzakPrimotly, the file name is firebase.json, see the documentation.