Expo React Native应用TestFlight环境点击Accepter按钮崩溃求助
Expo应用TestFlight构建版本点击"Accepter"按钮崩溃问题
我的Expo应用在开发版本和模拟器上运行完全正常,没有任何bug或崩溃,但通过TestFlight构建并测试时,执行特定操作会崩溃——点击"Accepter"按钮时应用崩溃,点击"Rejeter"按钮则一切正常。我调试后推测,崩溃原因是日历权限申请失败。
按钮组件代码
<Button title="Accepter" onPress={() => acceptAppointment(currentMessage.appointmentId, currentMessage._id) } /> <Button title="Refuser" onPress={() => declineAppointment(currentMessage.appointmentId, currentMessage._id) } />
接受预约函数代码
const acceptAppointment = async (appointmentId, messageId) => { try { const appointmentRef = doc(db, 'appointments', appointmentId); await updateDoc(appointmentRef, { accepted: true, responded: true, }); const appointmentDoc = await getDoc(appointmentRef); const appointment = appointmentDoc.data(); const result = await addAppointmentToCalendar(appointment, selectedService, appointmentTitle); let textMessage; if (result.success) { textMessage = 'Vous avez accepté le rendez-vous et il a été ajouté à votre calendrier.'; } else { textMessage = `Vous avez accepté le rendez-vous, mais il n'a pas pu être ajouté à votre calendrier. Erreur : ${result.error}`; } sendMessage(conversationId, {text: textMessage, isResponded: true}, userId); const message = { to: expoPushToken, sound: 'default', title: appointmentTitle, body: 'Encore un rendez-vous de pris !', data: {appointmentId}, }; const response = await fetch('https://exp.host/--/api/v2/push/send', { method: 'POST', headers: { Accept: 'application/json', 'Accept-encoding': 'gzip, deflate', 'Content-Type': 'application/json', }, body: JSON.stringify(message), }); } catch (error) { console.error("Une erreur s'est produite lors de l'acceptation du rendez-vous:", error); } };
崩溃日志
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: BeautyHome [7179] Triggered by Thread: 15 Last Exception Backtrace: 0 CoreFoundation 0x1b78b77bc __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x1afe08ea0 objc_exception_throw + 60 (objc-exception.mm:356) 2 BeautyHome 0x10063e8e0 0x100330000 + 3205344 3 CoreFoundation 0x1b7920b00 -[NSSet makeObjectsPerformSelector:withObject:] + 188 (NSSet.m:303) 4 BeautyHome 0x1003a6078 0x100330000 + 483448 5 BeautyHome 0x1003a62ec 0x100330000 + 484076 6 BeautyHome 0x100355d30 0x100330000 + 154928 7 BeautyHome 0x1003aa828 0x100330000 + 501800 8 BeautyHome 0x1003aa794 0x100330000 + 501652 9 BeautyHome 0x1003aa888 0x100330000 + 501896 10 BeautyHome 0x1003534d8 0x100330000 + 144600 11 BeautyHome 0x10034e91c 0x100330000 + 125212 12 BeautyHome 0x10034e9b0 0x100330000 + 125360 13 CoreFoundation 0x1b7921ed4 __invoking___ + 148 (:-1) 14 CoreFoundation 0x1b78ceec8 -[NSInvocation invoke] + 428 (NSForwarding.m:3399) 15 BeautyHome 0x100398514 0x100330000 + 427284 16 BeautyHome 0x1003f5c58 0x100330000 + 810072 17 BeautyHome 0x100388924 0x100330000 + 362788 18 libdispatch.dylib 0x1bf6306a8 _dispatch_call_block_and_release + 32 (init.c:1530) 19 libdispatch.dylib 0x1bf632300 _dispatch_client_callout + 20 (object.m:561) 20 libdispatch.dylib 0x1bf639894 _dispatch_lane_serial_drain + 748 (queue.c:3885) 21 libdispatch.dylib 0x1bf63a3c4 _dispatch_lane_invoke + 380 (queue.c:3976) 22 libdispatch.dylib 0x1bf645004 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6913) 23 libdispatch.dylib 0x1bf644878 _dispatch_workloop_worker_thread + 404 (queue.c:6507) 24 libsystem_pthread.dylib 0x21fc7ae50 _pthread_wqthread + 288 (pthread.c:2629) 25 libsystem_pthread.dylib 0x21fc7abf0 start_wqthread + 8 (:-1)
内容的提问来源于stack exchange,提问作者Rémi Baltus
相关产品推荐
相关产品推荐

