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.66k stars 2.21k forks source link

[🐛] Can not get a device token on Testflight app after upgrading macOS to Ventura 13.0.1 #6815

Closed AndrzejRokosz closed 1 year ago

AndrzejRokosz commented 1 year ago

Issue

Hi, I am not able to get a device token on App installed on Testflight after upgrading macOS to Ventura 13.0.1. The Testflight app was getting token without any issues on earlier macOS version.
Now for some reason it stopped working.

useEffect(() => {
    messaging()
      .requestPermission()
      .then((authStatus) => {
        if (
          authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
          authStatus === messaging.AuthorizationStatus.PROVISIONAL
        ) {
          messaging()
            .getToken()
            .then((token) => {
              //dispatch(setDeviceTokenAction(token));
            })
            .catch((e) => console.log(e, '________________________________'));   <---------------------------**ERROR HERE**

          messaging().onTokenRefresh((token) => {
            dispatch(setDeviceTokenAction(token));
          });

          messaging().onMessage(async (remoteMessage) => {
            if (remoteMessage) {
              pushNotificationsHandler({
                data: remoteMessage,
                actionIdentifier: FOREGROUND_ARRIVED_ACTION,
              });
            }
          });

          messaging().onNotificationOpenedApp((remoteMessage) => {
            if (remoteMessage) {
              pushNotificationsHandler({
                data: remoteMessage,
                actionIdentifier:
                  TAPPED_BY_USER_AND_OPENED_APP_FROM_BG_STATE_ACTION,
              });
            }
          });

          messaging()
            .getInitialNotification()
            .then((remoteMessage) => {
              if (remoteMessage) {
                pushNotificationsHandler({
                  data: remoteMessage,
                  actionIdentifier:
                    TAPPED_BY_USER_AND_OPENED_APP_FROM_KILL_STATE_ACTION,
                });
              }
            });
        } else {
          showRemoteNotificationsNotAllowedAlert();
        }
      })
      .catch((error) =>
        console.log('messaging.requestPermission Error: ', error)
      );

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

Error caught in XCODE console `11 2023-01-04 14:30:36.838294+0100 eskulap_currier_develop_release[93382:8394727] 10.3.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '536128569260'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set. 2023-01-04 14:30:36.900537+0100 eskulap_currier_develop_release[93382:8394737] 10.3.0 - [GoogleUtilities/AppDelegateSwizzler][I-SWZ001011] App Delegate Proxy is disabled. 2023-01-04 14:30:36.936024+0100 eskulap_currier_develop_release[93382:8394323] [AppKitColor] AppKit dark highlight color is not opaque: UIExtendedSRGBColorSpace 1 1 1 0.247059 2023-01-04 14:30:36.951803+0100 eskulap_currier_develop_release[93382:8394323] IOMFB: FigInstallVirtualDisplay not found 2023-01-04 14:30:36.951896+0100 eskulap_currier_develop_release[93382:8394323] iomfb_populate_display_infos: Local call to iomfb_match_callback 2023-01-04 14:30:36.951959+0100 eskulap_currier_develop_release[93382:8394323] iomfb_match_callback: primary 2023-01-04 14:30:36.952020+0100 eskulap_currier_develop_release[93382:8394323] iomfb_match_callback: external-0 2023-01-04 14:30:36.967384+0100 eskulap_currier_develop_release[93382:8394726] 10.3.0 - [FirebaseMessaging][I-FCM027004] Unable to save checkin info, resetting checkin preferences in memory. 2023-01-04 14:30:36.973873+0100 eskulap_currier_develop_release[93382:8394738] [javascript] [Error: [messaging/unknown] The operation couldn’t be completed. (com.google.iid error -34018.)], '____'

`11

Thx, for any help with this one. PS: It is working fine with earlier version of macOS operating system.

Project Files

Javascript

Click To Expand { "name": "eskulap_currier", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "android:clean": "cd android && ./gradlew clean && ./gradlew cleanBuildCache && cd ..", "ios": "react-native run-ios", "ios:clean": "cd ios && xcodebuild clean && rm -rf ~/Library/Caches/CocoaPods && rm -rf Pods && rm -rf ~/Library/Developer/Xcode/DerivedData/* && pod cache clean --all && pod deintegrate && pod setup && pod install && cd ..", "start": "react-native start", "test": "jest", "lint": "eslint .", "lint-fix": "eslint . --fix", "postinstall": "jetify" }, "dependencies": { "@babel/preset-env": "^7.17.12", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-firebase/app": "^16.5.0", "@react-native-firebase/crashlytics": "^16.5.0", "@react-native-firebase/messaging": "^16.5.0", "@react-navigation/devtools": "^6.0.10", "@react-navigation/drawer": "^6.1.8", "@react-navigation/native": "^6.0.13", "@react-navigation/native-stack": "^6.2.5", "@redux-devtools/extension": "^3.2.3", "axios": "^0.27.2", "moment": "^2.29.3", "react": "17.0.2", "react-hook-form": "^7.36.1", "react-native": "0.66.3", "react-native-background-fetch": "^4.1.1", "react-native-background-geolocation": "^4.8.2", "react-native-calendar-strip": "^2.2.6", "react-native-check-version": "^1.0.17", "react-native-device-info": "^9.0.2", "react-native-gesture-handler": "^2.0.0", "react-native-linear-gradient": "^2.6.2", "react-native-location": "^2.5.0", "react-native-maps": "^1.3.1", "react-native-network-info": "^5.2.1", "react-native-network-logger": "^1.13.0", "react-native-reanimated": "^2.2.4", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^3.4.1", "react-native-screens": "^3.17.0", "react-native-select-dropdown": "^1.7.0", "react-native-smart-code": "^1.1.0", "react-native-sound-player": "^0.12.0", "react-native-spinkit": "^1.5.1", "react-native-splash-screen": "^3.3.0", "react-native-toast-message": "^2.1.5", "react-redux": "^8.0.4", "redux": "^4.1.2", "redux-thunk": "^2.4.1" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "babel-eslint": "^10.1.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.4", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-react-native": "^4.0.0", "jest": "^26.6.3", "jetifier": "^2.0.0", "metro-react-native-babel-preset": "^0.66.2", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } }

#### `package.json`: ```json # N/A ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand $RNFirebaseAsStaticFramework = true 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' target 'eskulap_currier' do config = use_native_modules! use_frameworks! :linkage => :static use_react_native!( :path => config[:reactNativePath], ) pod 'RNSmartCode', :path => '../node_modules/react-native-smart-code' pod 'react-native-location', :path => '../node_modules/react-native-location' pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info' target 'eskulap_currierTests' do inherit! :complete end post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" config.build_settings["ONLY_ACTIVE_ARCH"] = "YES" if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" target.build_configurations.each do |config| config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' end end end case target.name when 'RCT-Folly' target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0' end end end end end

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] 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 13.0.1 CPU: (8) arm64 Apple M1 Memory: 76.13 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node Yarn: 1.22.5 - ~/.yarn/bin/yarn npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm Watchman: 2022.12.12.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 28, 30, 31, 32 Build Tools: 28.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0 System Images: android-30 | Intel x86 Atom_64, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-32 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /Users/andrzejrokosz/.jenv/shims/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.3 => 0.66.3 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`


Chasty commented 1 year ago

A workaround https://github.com/invertase/react-native-firebase/issues/4983#issuecomment-1358632635

AndrzejRokosz commented 1 year ago

Do you mean setting this in Info.plist ? It did not make any difference, but thx for response

AndrzejRokosz commented 1 year ago

is there any chance to get help with this one ?

mikehardy commented 1 year ago

There should be no problem with this now (assuming you stay on firebase-ios-sdk), after the firebase team rolled back a server side change here https://github.com/firebase/firebase-ios-sdk/issues/10679#issuecomment-1396293848

In the future if you update to firebase-ios-sdk 10.4.0 (which we will incorporate for you, if you are not overriding it) you'll need the result of #6864 which will give you more isntructive log messages.

However, the log message is pretty specific, and it is correct. You're obtaining FCM tokens without an APNS token which means your FCM token is useless, it points nowhere and messages won't be delivered even if the firebase FCM backend will still temporarily accept these sorts of useless FCM tokens.

Their goal with the original rejection of these tokens - which they temporarily reversed - was to educate clients that they have useless tokens instead of silently accepting them.

You should make sure you are getting an APNS token. If you've disabled method swizzling for messaging somehow then you need to manually implement the callbacks that accept the APNS token after registering for remote notifications, and you need to set the token into the FCM system (directly using firebase-ios-sdk APIs for now, or with the new setAPNSToken API in #6864

More info: https://github.com/firebase/firebase-ios-sdk/issues/10679#issuecomment-1396293848

This is not actionable here anymore as you should be able to get an FCM token again even though you don't have an APNS token, and a future release here will handle it and is already tracked in #6830 so I'm going to close this but I hope this info helps

AndrzejRokosz commented 1 year ago

@mikehardy Thank you for your response. I tried to use SDK 10.3.0 (@react-native-firebase/messaging - 16.5.0) but the problem still exists for me and it only affects apps which run on MacOS via Testflight. Everything is OK for apps running on iOS devices even if I use Testflight platform.

I also tried to bump the SDK version to 10.5.0 (@react-native-firebase/messaging - 17.0.1) and use setAPNSToken manually but have no idea how to generate or get the proper APNS token (getAPNSToken also returns null). It can not be any hexed string. Is there any chance that u could look at this case more deeply? Is it possible to update documentation and provide more specific example? Or this issue still exists on macOS Testflight apps.

Methods swizzling is enabled. I am not writing any native code, got rather basic knowledge about this topic (still learning), just using your react-native library and methods provided. And as I said this was working perfectly well till MacOS upgrade to Ventura.

10.3.0 - [FirebaseMessaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at: https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging to ensure proper integration.

Any ideas? thx for help

mikehardy commented 1 year ago

I'd it is a MacOS app (like, catalyst or actually MacOS) then perhaps check the firebase iOS sdk change log, i seem to recall something about it nit connecting to the correct sandbox vs production apns instance. Also there is more to do with signing and config perhaps?

rmontana2023 commented 10 months ago

I'm experiencing inconsistency in getting device token on ios tesflight but in local environment it is working. Any ideas ? TY for the help

MypowerHD commented 6 months ago

I'm experiencing inconsistency in getting device token on ios tesflight but in local environment it is working. Any ideas ? TY for the help

@rmontana2023 did you find any solutions?