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.71k stars 2.22k forks source link

[🐛] 🔥 [iOS] - RNFirebase not receiving FCM #6734

Closed Spxc closed 1 year ago

Spxc commented 1 year ago

Issue

RNFirebase background (and foreground) Push Notifications never triggered for iOS. Working great in Android. All APN's updated. Only thing that hasent been integrated is the "use_framework" in the POD file, as it will causes issues to the entire app, as we are using Flipper (and no way around it).

Tried with the use of "use_framework!", but still no change, this is after disabling Flipper.

We currently run the following code in our 'index.js' file, and again it works for Android, just not iOS. Analytics seems to be working for both (Firebase).

`requestUserPermission() .then(data => { console.log("ACCEPTED PERMISSION"); var payload = { source_account: response.public, token: FCMToken }

      messaging().onMessage(onMessageReceived);
      messaging().onNotificationOpenedApp((notification) => {
        console.log('Background Notification', JSON.stringify(notification));
        // Handle Your notification here
      });
      messaging().setBackgroundMessageHandler(async remoteMessage => {
          console.log('Message handled in the background!', remoteMessage);
          showNotification(remoteMessage)
      });
  }).catch(err => {
      console.log("[FIREBASE]: Error "+err)
  })`

Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "App", "version": "1.5.1", "app_build": "1000948 public", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "postinstall": "yarn rn-nodeify --install url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn" }, "dependencies": { "@connectedcars/react-native-slide-charts": "^1.0.5", "@fortawesome/fontawesome-svg-core": "^6.1.1", "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.0", "@haskkor/react-native-pincode": "^1.22.6", "@haskkor/react-native-recaptchav3": "^1.2.1", "@react-native-async-storage/async-storage": "^1.17.7", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/push-notification-ios": "^1.10.1", "@react-native-firebase/app": "^16.4.6", "@react-native-firebase/messaging": "^16.4.6", "@tradle/react-native-http": "^2.0.0", "@walletconnect/qrcode-modal": "^1.8.0", "@walletconnect/sign-client": "^2.0.0-rc.1", "@walletconnect/types": "^2.0.0-rc.1", "axios": "^0.27.2", "buffer": "^4.9.1", "events": "^1.0.0", "fast-text-encoding": "^1.0.4", "https": "^1.0.0", "https-browserify": "~0.0.0", "jetifier": "^2.0.0", "lodash": "^4.17.21", "moment": "^2.29.3", "patch-package": "^6.4.7", "patch-packages": "^1.0.0", "process": "^0.11.10", "react": "17.0.2", "react-moment": "^1.1.2", "react-native": "^0.68.2", "react-native-biometrics": "^2.2.0", "react-native-camera": "^4.2.1", "react-native-chart-kit": "^6.12.0", "react-native-crypto": "^2.1.0", "react-native-flip-card": "^3.5.6", "react-native-gesture-handler": "^2.8.0", "react-native-image-base64": "^0.1.4", "react-native-image-picker": "^4.8.4", "react-native-keychain": "^8.1.1", "react-native-modal": "^13.0.1", "react-native-navigation": "7.28.0", "react-native-pin-code": "^0.5.3", "react-native-polyfill": "^1.2.1", "react-native-progress": "^5.0.0", "react-native-push-notification": "^8.1.1", "react-native-qrcode-svg": "^6.1.2", "react-native-randombytes": "^3.0.0", "react-native-recaptcha-v3": "^0.0.16", "react-native-rename": "^2.9.0", "react-native-root-modal": "^5.0.1", "react-native-safe-area-context": "^4.3.1", "react-native-safe-area-view": "^1.1.1", "react-native-select-two": "^1.1.0", "react-native-svg": "^13.2.0", "react-native-toast-message": "^2.1.5", "react-native-vector-icons": "^9.2.0", "react-native-webview": "^11.22.4", "readable-stream": "1.0.33", "rn-qr-generator": "^1.2.0", "stellar-sdk": "^10.4.0", "stream": "^0.0.2", "stream-browserify": "^1.0.0", "text-encoding": "^0.7.0", "toggle-switch-react-native": "^3.3.0", "url": "~0.10.1", "util": "~0.10.3", "vm-browserify": "0.0.4" }, "devDependencies": { "@babel/core": "^7.18.6", "@babel/runtime": "^7.18.6", "@react-native-community/eslint-config": "^3.0.3", "babel-jest": "^28.1.2", "eslint": "^8.19.0", "jest": "^28.1.2", "metro-react-native-babel-preset": "^0.71.2", "react-test-renderer": "17.0.2", "rn-nodeify": "^10.3.0" }, "jest": { "preset": "react-native" }, "react-native": { "crypto": "react-native-crypto", "http": "@tradle/react-native-http", "https": "https-browserify", "_stream_transform": "readable-stream/transform", "_stream_readable": "readable-stream/readable", "_stream_writable": "readable-stream/writable", "_stream_duplex": "readable-stream/duplex", "_stream_passthrough": "readable-stream/passthrough", "stream": "stream-browserify", "vm": "vm-browserify" }, "browser": { "crypto": "react-native-crypto", "http": "@tradle/react-native-http", "https": "https-browserify", "_stream_transform": "readable-stream/transform", "_stream_readable": "readable-stream/readable", "_stream_writable": "readable-stream/writable", "_stream_duplex": "readable-stream/duplex", "_stream_passthrough": "readable-stream/passthrough", "stream": "stream-browserify", "vm": "vm-browserify" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [x] I'm not using Pods - [ ] I'm using Pods and my Podfile looks like: ```ruby $RNFirebaseAsStaticFramework = true #RNFireBase 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' install! 'cocoapods', :deterministic_uuids => false target 'StashApp' do config = use_native_modules! pod 'Firebase', :modular_headers => true #RNFireBase pod 'FirebaseCore', :modular_headers => true #RNFireBase pod 'FirebaseCoreInternal', :modular_headers => true #RNFireBase pod 'GoogleUtilities', :modular_headers => true #RNFireBase # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'StashAppTests' 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 the next line. #use_frameworks! :linkage => :static #RNFireBase use_flipper!() #use_flipper!({ 'Flipper-Folly' => '2.3.0' }) #use_flipper!({ 'Flipper-Folly' => '~> 2.6' }) post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 12.6 CPU: (10) arm64 Apple M1 Pro Memory: 79.22 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.11.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.2 - /opt/homebrew/bin/npm Watchman: 2022.10.31.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.0/14A309 - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: ^0.68.2 => 0.68.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] 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:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


Spxc commented 1 year ago

Uncommented use_flipper and the post install functions, that seems to do the trick for now

Current Podfile:

# Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_frameworks! :linkage => :static #RNFireBase
  #use_flipper!()
  #use_flipper!({ 'Flipper-Folly' => '2.3.0' })
  #use_flipper!({ 'Flipper-Folly' => '~> 2.6' })

  # post_install do |installer|
  #   react_native_post_install(installer)
  #   __apply_Xcode_12_5_M1_post_install_workaround(installer)
  # end
mikehardy commented 1 year ago

Since use_frameworks is required and adding it appears to fix things, I'm going to close this as it does not seem actionable I will say that the post_install block there is pretty important. I'd keep it.

Spxc commented 1 year ago

Hi there. The latest block needs to be commented out to get rid of the errors when compiling. This because flipper needs to be removed in order to use_framework.

Only commenting out 'use_flipper' will most likely cause build errors running: npx react-native run-ios

man. 28. nov. 2022 kl. 13:48 skrev Mike Hardy @.***>:

Closed #6734 https://github.com/invertase/react-native-firebase/issues/6734 as completed.

— Reply to this email directly, view it on GitHub https://github.com/invertase/react-native-firebase/issues/6734#event-7902608440, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKPVS2DFJXZMSOPU4YY5TLWKSS3HANCNFSM6AAAAAASNBXBGQ . You are receiving this because you authored the thread.Message ID: @.*** com>

--

mikehardy commented 1 year ago

That's incorrect. The post_install block and flipper on versus off are orthogonal. They are unrelated.

I definitely disable flipper and I definitely leave that post_install block in and it definitely works.

https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

That script proves it.