You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue while using react-native-firebase in a React Native-based PWA. The workflow involves fetching the FCM token in the React Native repository using the getToken method and passing it to the React repository via a WebView. A register API is then called to register the token with Firebase and subscribe it to topics.
Issue Details:
In more than 99% of cases, the register API successfully registers the FCM token with Firebase.
However, in a small number of cases (<1%), the register API fails with an "Unknown Error" and a 5XX status code.
I am relying on the token provided by the messaging().getToken() method.
Expected Behavior
The getToken method should always generate a valid token, and the token should register successfully with Firebase without causing 5XX errors.
Actual Behavior
In rare cases, the token provided by getToken results in a 5XX error when attempting to register it with Firebase via the register API.
Could there be an issue with how getToken generates tokens in rare cases? Please help if anyone ever faced such issue or could possible know how to resolve such type of issue.
The text was updated successfully, but these errors were encountered:
Please don't report issues on old versions.
Update to current versions and attempt to reproduce
If you still reproduce, please log again but do not delete the template, rather, provide the information requested in the issue template when asking for help via an issue (makes sense, yes?)
Additionally, please grab device logs - for instance, when you reproduce on android include relevant parts of adb logcat
If you cannot reliably reproduce, we will not be able to reliably help
Description
I am encountering an issue while using react-native-firebase in a React Native-based PWA. The workflow involves fetching the FCM token in the React Native repository using the getToken method and passing it to the React repository via a WebView. A register API is then called to register the token with Firebase and subscribe it to topics.
Issue Details:
Expected Behavior
The getToken method should always generate a valid token, and the token should register successfully with Firebase without causing 5XX errors.
Actual Behavior
In rare cases, the token provided by getToken results in a 5XX error when attempting to register it with Firebase via the register API.
Environment
"react-native": "0.68.6",
@react-native-firebase/app: "18.1.0"
@react-native-firebase/messaging: "18.1.0"
@react-native-firebase/analytics: "18.1.0"
Steps to Reproduce
Javascript
Fetching FCM Token
export const getFcmToken = async () => {
try {
if (!messaging().isDeviceRegisteredForRemoteMessages) {
await messaging().registerDeviceForRemoteMessages();
}
const fcmToken = await messaging().getToken();
if (fcmToken) {
const tokenStorage = {
token: fcmToken
}
await AsyncStorage.setItem(FCM_CONSTANTS.FCM_TOKEN, JSON.stringify(tokenStorage));
}
} catch (err) {
console.error(err);
}
};
Registering Token
export const registerToken = async() => {
try {
const webView = getWebView();
const tokenRegistered = await AsyncStorage.getItem(FCM_CONSTANTS.FCM_TOKEN)
let obj = {
...JSON.parse(tokenRegistered!),
type: FCM_CONSTANTS.TOKEN,
deviceId: DeviceInfo.getDeviceId(),
}
if(webView) {
webView.injectJavaScript(
window.postMessage('${JSON.stringify(obj) }');true;
);}
} catch (err) {
console.error(err);
}
}
Could there be an issue with how getToken generates tokens in rare cases? Please help if anyone ever faced such issue or could possible know how to resolve such type of issue.
The text was updated successfully, but these errors were encountered: