You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Firebase OnCall函数登录1小时后失效问题求助

Firebase Callable函数登录1小时后调用失败问题

我开发了一个React Native应用,使用react-native-firebase SDK 14.5.1实现用户认证,近期接入了Firebase Functions,调用代码如下:

try {
    const response = await FBfunction.app().functions('europe-west1').httpsCallable('getUser')();
    alert(JSON.stringify(response));
} catch (e) {
    alert(e);
}

问题现象

用户登录后1小时内函数响应正常,但1小时后调用会报错:An internal error has occurred, print and inspect the error details for more information。退出登录重新登录后,函数可再次正常使用1小时。

排查发现,函数无法调用时,firebase.auth().currentUser返回的用户信息完全正确,我的OnCall函数通过context对象校验用户认证状态,测试用的函数代码如下:

const functions = require('firebase-functions');
const axios = require('axios');
const androidGoogleMapsApiKey = functions.config().android.googlemaps.key;
const iosGoogleMapsApiKey = functions.config().ios.googlemaps.key;

exports.getUser = functions.region('europe-west1').https.onCall(async (data, context) => {
    try {
        return context.auth.uid + '//' + context.auth.token.email;
    } catch (error) {
        throw new functions.https.HttpsError('Error', error);
    }
});

解决方法

问题已解决,原因是未启用谷歌地图API中的「Cloud Functions」服务,该配置缺失会导致函数正常工作1小时后失效,启用对应服务后问题消除。


内容的提问来源于stack exchange,提问作者Djoby

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 17:32:19