在 iOS 中的 CameraRoll.saveToCameraRoll 上,应用程序在 react-native 中崩溃

App crash on CameraRoll.saveToCameraRoll in iOS in react-native

我试图在 iOS 中的本机反应应用程序中将屏幕截图保存到相机胶卷,但是一旦调用 CameraRoll.saveToCameraRoll 应用程序就会崩溃。它一直工作到 iOS 10 和 react-native 0.47。它在 Android.

中运行良好

我已经在 Info.plist 中拥有 iOS 10+ 所需的权限。

这是我将图像保存到相机胶卷的代码。

CameraRoll.saveToCameraRoll(mUri, 'photo')
.then(()=>console.log('saved to CameraRoll'))
.catch(()=>console.log('error in saving'))

请注意,我没有得到以上两个的任何控制台日志。这是本机崩溃,下面是崩溃线程。

Thread 39 Queue : com.apple.root.default-qos (concurrent)
#0  0x000000010c8280aa in __abort_with_payload ()
#1  0x000000010c824326 in abort_with_payload_wrapper_internal ()
#2  0x000000010c82434f in abort_with_payload ()
#3  0x000000010c9d2b09 in __CRASHING_DUE_TO_PRIVACY_VIOLATION__ ()
#4  0x000000010c9d2a53 in __TCCAccessRequest_block_invoke.77 ()
#5  0x000000010c9d6273 in __tccd_send_block_invoke ()
#6  0x000000010c76ead5 in _xpc_connection_reply_callout ()
#7  0x000000010c76417c in _xpc_connection_call_reply_async ()
#8  0x000000010c39f49e in _dispatch_client_callout3 ()
#9  0x000000010c3b7658 in _dispatch_mach_msg_async_reply_invoke ()
#10 0x000000010c3a407d in _dispatch_queue_override_invoke ()
#11 0x000000010c3ab1f9 in _dispatch_root_queue_drain ()
#12 0x000000010c3aae97 in _dispatch_worker_thread3 ()
#13 0x000000010c85d5a2 in _pthread_wqthread ()
#14 0x000000010c85d07d in start_wqthread ()
Enqueued from com.apple.libdispatch-manager (Thread 42) Queue : com.apple.libdispatch-manager (serial)
#0  0x000000010c3b405c in _dispatch_mach_reply_merge_msg ()
#1  0x000000010c3ba3f3 in _dispatch_event_loop_merge ()
#2  0x000000010c3b2481 in _dispatch_kevent_worker_thread ()
#3  0x000000010c85d47b in _pthread_wqthread ()
#4  0x000000010c85d07d in start_wqthread ()

我也遇到了同样的问题。 通过在 info.plist 中添加 NSPhotoLibraryAddUsageDescription("Privacy - Photo Library Additions Usage Description") 修复。

这是 iOS 11 的新规则。