我正在尝试在iOS中的react-native应用程序中将截图保存到Camera Roll,但是一旦调用CameraRoll.saveToCameraRoll,应用程序就会崩溃。它一直工作到iOS 10并且反应原生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 ()
答案 0 :(得分:18)
我也遇到同样的问题。 通过在info.plist中添加NSPhotoLibraryAddUsageDescription(“隐私 - 照片库添加使用说明”)进行修复。
这是iOS 11的新规则。