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

React Native Firebase项目App Store Connect提交按钮失效问题排查

iOS 17.2下Submit按钮无响应排查思路(React Native + Firebase)

React Native + Firebase项目两次被App Store Connect驳回,测试人员反馈弹窗的Submit按钮点击无任何反应。对比测试截图发现,测试设备iOS 17.2的键盘显示“enter”而非我设备上的“send”(我使用的也是iOS 17.2)。本地iOS、Android端测试正常,项目已上架Google Play,未做修改重新提交仍被驳回。

弹窗组件代码

{/* GLOBAL Modal    GLOBAL Modal    GLOBAL Modal    GLOBAL Modal */}
<Modal
animationType='slide'
transparent={false}
visible={globeModalVis}
onRequestClose={()=>
console.log("whatevs globe")
}
>
<View style={globalStyles.modalCont}>
    <Image source={iEarth} style={globalStyles.modalImage} />
    <Text style={[globalStyles.basicText, globalStyles.white, {marginTop:'30%'}]}>{i18n.t('GlobalRoom')}</Text>
    <TextInput
    style={[globalStyles.usernameInput, {marginBottom: '5%'}]}
    placeholder={i18n.t('RoomPlaceholder')}
    value={custName}
    onChangeText={text=>setCustName(text)}
    returnKeyType="send"
    onSubmitEditing={modalGlobe}
    />
    <View style={globalStyles.modalButtons}>
        <TouchableOpacity style={globalStyles.modalBtn} onPress={()=>[setGlobeModalVis(false),setCustName('')]}>
            <Text style={[globalStyles.inputText, globalStyles.red]}>{i18n.t('Cancel')}</Text>
        </TouchableOpacity>

        <TouchableOpacity style={globalStyles.modalBtn} onPress={modalGlobe}>
            <Text style={[globalStyles.inputText, globalStyles.green]}>{i18n.t('Submit')}</Text>
        </TouchableOpacity>
    </View>
</View>    
</Modal>

触发函数代码

const modalGlobe = () => {
    try {
        if(userName.length > 12 || userName.length < 3){
            showToast(i18n.t("ErrNameLength"))
            setGlobeModalVis(false)
            //test
            setNoNameDoor(2)
            setUsernameModalVis(true)
        }
        else if(custName.length > 13 || custName.length < 3){
            showToast(i18n.t("ErrRoomLength"))
        }
        else if(checkSuspension(suspendedDate))
        {
            showToast(i18n.t("SuspensionDate") + suspendedDate)
        }
        else if (latitude && longitude != null){
            roomName = ""
            roomName = custName
            roomName = roomName.toLocaleLowerCase()        
            updateDateTime(userName)
            navigation.navigate("ChatRoom", {userName, roomName, rando, uniqueId})
            setGlobeModalVis(false)
        }
    } catch (error) {
        console.error("Error in modalGlobe function:", error);
    }
}

ChatRoom页面Firestore逻辑代码

const colRef = firebase.firestore().collection( navigation.getParam("roomName") )
useEffect(() => { (async () => unmount())()
  const unsubscribe = colRef
    .orderBy('time', 'asc')
    .onSnapshot(
      querySnapshot => {
        const messages = []
        querySnapshot.forEach((doc) => {
          const { message, time, userName, col, Unique_ID } = doc.data()
          messages.unshift({
            id: doc.id,
            message,
            userName,
            time, 
            col,
            Unique_ID
          })
        })
        setMessages(messages)
      }
    )
    return () => {
    unsubscribe()
  }
}, [])

排查思路

1. 键盘与输入框焦点问题

  • 虽然设置了returnKeyType="send",但iOS可能因系统语言/地区、输入框类型差异显示“enter”。尝试添加keyboardType="default"和blurOnSubmit={false},确保onSubmitEditing事件正常触发;Modal弹出后手动调用TextInput.focus(),避免焦点异常导致按钮事件被拦截。
  • 检查弹窗层级是否存在遮挡:确认Modal内的TouchableOpacity未被其他透明View覆盖,可临时给按钮添加背景色验证点击区域。

2. 触发函数边界条件漏洞

  • userName状态异常:函数直接使用userName但未明确其初始化逻辑,若测试环境中userName长度不符合要求,仅会弹出Toast并跳转用户名弹窗,测试人员可能未注意到Toast提示,误以为按钮无反应。需添加console.log(userName, custName)输出实际值,确认是否进入分支逻辑。
  • custName校验后无弹窗关闭:第二个判断分支仅弹出Toast但未关闭弹窗,测试人员重复点击会无状态变化,需补充setGlobeModalVis(false)或引导用户修正输入。
  • 位置信息为空无处理:函数仅处理latitude && longitude != null的情况,若位置未获取到,会无任何操作。需添加else分支,弹出位置获取失败的Toast提示。
  • roomName变量作用域问题:未声明直接赋值roomName,严格模式下可能报错,改为const roomName = custName.toLocaleLowerCase()避免隐式全局变量异常。

3. Firebase与导航异步问题

  • updateDateTime未等待异步完成:如果updateDateTime是异步操作,直接调用navigation.navigate会导致数据未同步就跳转,需改为await updateDateTime(userName)确保数据写入完成。
  • Firestore权限限制:测试环境中Firebase安全规则可能禁止创建新集合或读写操作,导致跳转后ChatRoom页面无数据反馈。检查Firestore规则,确保允许目标集合的创建和访问。
  • navigation参数获取兼容:React Native Navigation的getParam已被route.params取代,若使用新版本导航库,navigation.getParam("roomName")可能返回undefined,导致集合引用错误。替换为route.params.roomName(需确保组件接收route参数)。

4. 环境差异问题

  • 生产包权限配置:检查Info.plist是否添加位置权限描述(NSLocationWhenInUseUsageDescription),若测试设备未授权位置,latitude/longitude会为null,导致函数无后续操作。
  • Release模式兼容性:本地调试用Debug模式,生产包为Release模式,部分依赖在Release模式下可能出现优化导致的异常。打包Release包在本地iOS设备测试,复现测试人员场景。
  • Firebase环境配置:确认生产环境的Firebase配置与本地一致,避免因环境差异导致初始化失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 17:43:17