Open eirikhanasand opened 2 months ago
Is it possible to give this issue increased priority? This is currently causing all our Android users to not recieve notifications in production, and we are unable to debug the problem, as the hanging doesnt leave any trace, logs or probable cause behind.
@eirikhanasand - I've just tried this and had no issue subscribing to topic on android and receiving message via topic. Worth stripping out all app code to something like this:
import React from 'react';
import { AppRegistry, Button, Text, View } from 'react-native';
import firebase from '@react-native-firebase/app';
import messaging from '@react-native-firebase/messaging';
firebase.messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('Message handled in the background!', remoteMessage);
});
firebase.messaging().onMessage(message => {
console.log('on message log');
});
function App(props) {
return (
<View>
<Text>text text text</Text>
<Text>text text text</Text>
<Text>text text text</Text>
<Button
title="subscribe to topic"
onPress={async () => {
try {
await firebase.messaging().subscribeToTopic('test');
console.log('subscribed');
} catch (e) {
console.log(e);
}
}}
/>
<Button
title="get token"
onPress={async () => {
try {
const token = await messaging().getToken();
console.log('token', token);
} catch (e) {
console.log(e);
}
}}
/>
</View>
);
}
AppRegistry.registerComponent('testing', () => App);
Might be worth building app via android studio and seeing what happens as I'm not sure what is causing it to hang.
Thanks for the quick reply. Ive tested more with your code, but unfortunately I am still consistently encountering the indefinite hanging issue with your code. Ive began work on a minimal reproducible repository to demonstrate the issue. However, I was unable to complete it today due to an unrelated iOS issue that blocked me from testing the minrep on iOS first to ensure the problem was the same. An update will follow tomorrow, hopefully with the minrep complete.
After further research Ive been able to complete the minrep and discover the root cause of this issue. Ive been consistently able to reproduce the issue today, but during testing I discovered a vulnerability in the GCC API. I will share the cause and steps to reproduce after Ive shared the findings with Google.
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.
This issue occurs if you accidentally whitelist the wrong fingerprint in the cloud console. Minimal reproducible: https://github.com/eirikhanasand/subscribetotopic-min-rep
However the minrep in itself isnt really that relevant since u can replicate it in any repo by just whitelisting an incorrect fingerprint.
I also have this problem. Seems to happen when closing the network connection by minimizing the app for example. I have to restart the app completely to make the subscribe work again. I found i xcode logs that it hangs after this error message occurs.
10.29.0 - [FirebaseMessaging][I-FCM004001] Failed to subscribe to topic Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=57, NSUnderlyingError=0x3034b5050 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x301abb700 [0x1f2bebc70]>{length = 16, capacity = 16, bytes = 0x100201bb8efa4a2a0000000000000000}, _kCFStreamErrorCodeKey=57, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E95291D7-E07D-4C1C-A2EE-55E226AAC350>.<71>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <E95291D7-E07D-4C1C-A2EE-55E226AAC350>.<71>",
"LocalDataTask <A121CC79-22D1-4377-A3D8-EFC6F1C774C7>.<86>"
), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://iid.googleapis.com/iid/register, NSErrorFailingURLKey=https://iid.googleapis.com/iid/register, _kCFStreamErrorDomainKey=1}
This is not the same issue. The issue I have reported is Android only, and minimizing the app does not affect it.
lΓΈr. 12. okt. 2024 kl. 19:10 skrev xerdnu @.***>:
I also have this problem. Seems to happen when closing the network connection by minimizing the app for example. I have to restart the app completely to make the subscribe work again. I found i xcode logs that it hangs after this error message occurs.
10.29.0 - [FirebaseMessaging][I-FCM004001] Failed to subscribe to topic Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=57, NSUnderlyingError=0x3034b5050 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x301abb700 [0x1f2bebc70]>{length = 16, capacity = 16, bytes = 0x100201bb8efa4a2a0000000000000000}, _kCFStreamErrorCodeKey=57, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask
.<71>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask .<71>", "LocalDataTask .<86>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://iid.googleapis.com/iid/register, NSErrorFailingURLKey=https://iid.googleapis.com/iid/register, _kCFStreamErrorDomainKey=1} β Reply to this email directly, view it on GitHub https://github.com/invertase/react-native-firebase/issues/7997#issuecomment-2408629828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOFFPBTQWXSXXJ53LWY7ATTZ3FJZJAVCNFSM6AAAAABNLRJQ2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYGYZDSOBSHA . You are receiving this because you were mentioned.Message ID: @.***>
This issue occurs if you accidentally whitelist the wrong fingerprint in the cloud console. Minimal reproducible: eirikhanasand/subscribetotopic-min-rep
However the minrep in itself isnt really that relevant since u can replicate it in any repo by just whitelisting an incorrect fingerprint.
Yes, the reproduction is doing the same as my code snippet effectively. This seems more of a bug upstream. I suggest opening a ticket with Firebase support and find out why subscribeToTopic()
hangs with the above mentioned misconfiguration. Seems like it should throw an exception perhaps.
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.
subscribeToTopic hanging indefinitely on Android
Description
When using the messaging().subscribeToTopic(topic) function on Android, the function hangs indefinitely, despite putting the function in a trycatch block. Ive verified that the application has INTERNET, NOTIFICATIONS and PUSH_NOTIFICATIONS permissions, and verified that the devices in question have access to internet and that the phone settings allows notifications. Furthermore Ive verified that the same exact code works on iOS, and that notifications are successfully delivered to the topic there. Ive also checked that the google-services.json file is valid, and redownloaded it from firebase in case I was doing something weird. The hanging issue makes it impossible to debug or handle in any way, as Ive tried everything I can think of, and the error is still there, without any useful feedback.
Relevant code
Here I am importing messaging, and using the subscribeToTopic() to subscribe to a topic (Ive verified that the topic is typeof string, and that it does not contain any special topics. Ive tested with topics 'test', or 'maintenance', both of which worked on iOS, and both of which hung indefinitely on Android.
Project Files
iOS:
Podfile
contents: Not relevant, Android only issue.Android:
android/build.gradle
contents.Android:
android/app/build.gradle
contents:Javascript
Click To Expand
#### `package.json`: ```json { "name": "login", "version": "2.1.3", "private": true, "main": "index.ts", "scripts": { "eas-build-pre-install": "./decodeSecrets.sh", "start": "react-native start", "cstart": "npx react-native start --reset-cache", "estart": "expo start --dev-client", "prebuild": "expo prebuild", "ios": "react-native run-ios", "eios": "expo run:ios", "android": "react-native run-android", "eandroid": "expo run:android", "build": "eas build -p all --auto-submit", "buildi": "eas build -p ios --local", "builda": "eas build -p android --local", "test": "jest" }, "dependencies": { "@expo/config-plugins": "^7.8.4", "@react-native-async-storage/async-storage": "1.21.0", "@react-native-clipboard/clipboard": "^1.14.1", "@react-native-firebase/app": "^18.8.0", "@react-native-firebase/messaging": "^18.9.0", "@react-navigation/bottom-tabs": "^6.6.1", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.11.0", "@react-navigation/stack": "^6.4.1", "@reduxjs/toolkit": "^2.2.7", "expo": "~50.0.20", "expo-application": "~5.8.4", "expo-blur": "~12.9.2", "expo-build-properties": "^0.11.1", "expo-calendar": "^12.2.1", "expo-device": "~5.9.4", "expo-image-picker": "^14.7.1", "expo-linear-gradient": "~12.7.2", "expo-linking": "~6.2.2", "expo-splash-screen": "^0.26.5", "expo-status-bar": "~1.11.1", "expo-system-ui": "~2.9.4", "expo-web-browser": "~12.8.2", "react": "^18.2.0", "react-native": "0.73.6", "react-native-base64": "^0.2.1", "react-native-gesture-handler": "~2.14.0", "react-native-markdown-display": "^7.0.2", "react-native-reanimated": "~3.6.2", "react-native-safe-area-context": "4.8.2", "react-native-screens": "~3.29.0", "react-native-svg": "14.1.0", "react-redux": "^9.1.2", "redux": "^5.0.1", "redux-persist": "^6.0.0", "redux-thunk": "^3.1.0" }, "devDependencies": { "@babel/core": "^7.25.2", "@types/react": "~18.2.14", "@types/react-native-base64": "^0.2.2", "@types/react-test-renderer": "^18.3.0", "babel-jest": "^29.7.0", "babel-plugin-inline-import": "^3.0.0", "babel-plugin-module-resolver": "^5.0.2", "jest": "^29.7.0", "jest-transform-stub": "^2.0.0", "react-native-svg-transformer": "^1.5.0", "react-test-renderer": "18.2.0", "ts-jest": "^29.2.5", "typescript": "^5.5.4" }, "engines": { "node": ">=20" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```
iOS
Android only issue.
Android
Click To Expand
#### Have you converted to AndroidX? No
Environment
Click To Expand
**`react-native info` output:** ``` eirikhanasand@Eiriks-Macbook-Pro login_app % npx react-native info info Fetching system and libraries information... (node:16128) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) System: OS: macOS 14.3.1 CPU: (10) arm64 Apple M1 Max Memory: 509.19 MB / 64.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 22.7.0 path: /opt/homebrew/bin/node Yarn: Not Found npm: version: 10.8.2 path: /opt/homebrew/bin/npm Watchman: version: 2024.08.19.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/eirikhanasand/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 23.5 - iOS 17.5 - macOS 14.5 - tvOS 17.5 - visionOS 1.2 - watchOS 10.5 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: version: 15.4/15F31d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.6 path: /usr/bin/javac Ruby: version: 3.0.2 path: /Users/eirikhanasand/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: ^18.2.0 react-native: installed: 0.73.6 wanted: 0.73.6 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false info React Native v0.75.2 is now available (your project is running on v0.73.6). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.75.2 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.75.2 info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos". ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x ] 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:** 18.9.0 - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** Y, 5.5.4