一、起因
今天更新app迭代版本惊现原来测试通分享存储功能闪退了。遂查了一遍问题。
在调用 Share.open 的方法之后,app会闪退
报错信息:
App crash with error: Illegal callback invocation from native module. This callback type only permits a single invocation from native code
The callback showShareActionSheetWithOptions() exists in module ActionSheetManager, but only one callback may be registered to a function in a native module.
二、解决
查阅文档之后发现确实是 react-native-share更新了一个版本去适配IOS13,但 rn 版本还没有更新,所以会闪退。
解决方法:
RN 0.61.1版本已经修复。若您的版本低于此(也就是博主本人),可以采用如下方法:
替换node_modules里的文件 路径:react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m
替换文件直接去这里复制然后粘贴到项目下:https://github.com/facebook/react-native/blob/0.61-stable/Libraries/ActionSheetIOS/RCTActionSheetManager.m
参考文献: https://github.com/react-native-share/react-native-share/issues/585