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

混江龙づ霸主 提交于 2019-12-22 09:42:19

问题


I am trying to save a screenshot to Camera Roll in my react-native app in iOS but as soon as the CameraRoll.saveToCameraRoll is called the app crashes. It was working till iOS 10 and react-native 0.47. And it is working perfectly fine in Android.

I already have the permissions required for iOS 10+ in Info.plist.

This is my code for saving the image to Camera Roll.

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

Note that I am not getting any of the console logs of above two. It is a native crash and below is the crash thread.

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 ()

回答1:


I get same problem too. Fixed by adding NSPhotoLibraryAddUsageDescription("Privacy - Photo Library Additions Usage Description") in info.plist.

It's a new rule for iOS 11.



来源:https://stackoverflow.com/questions/46581830/app-crash-on-cameraroll-savetocameraroll-in-ios-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!