【发布时间】:2018-11-04 07:17:37
【问题描述】:
我无法从 React Native 应用打开 iOS 画廊应用。 我有文件 url 和资产 url。我从 CameraRoll 获得了资产 url。现在我想打开画廊本身来查看图像。
这是我使用的代码
openGallery = () => {
// this code is working on android using asset url
// sample url on iOS
// file url : file:///var/mobile/Containers/Data/Application/A41FFC2E-06D4-445D-9B94-D21E885930C7/Documents/video/popcam-1527202811.mov
// asset url : assets-library://asset/asset.mov?id=D4C62335-EDB1-4A75-B94D-61C3D48CADEA&ext=mov
const { galleryUrl, source } = this.props
const url = Platform.OS === 'ios' ? source : galleryUrl
Linking.canOpenURL(url).then(canOpen => {
if (canOpen) {
Linking.openURL(url)
} else {
Alert.alert('Info', 'Under Development')
}
})
谢谢
【问题讨论】:
-
你可以使用cameraroll ..facebook.github.io/react-native/docs/cameraroll.html
-
我已经使用相机胶卷来获取资产 url。我从相机胶卷中得到了这个网址(资产网址:asset-library://asset/asset.mov?id=D4C62335-EDB1-4A75-B94D-61C3D48CADEA&ext=mov)。相机胶卷仅用于获取资产 url,不打开画廊本身
-
你可以使用 react-native-image-picker
标签: ios react-native deep-linking react-native-ios camera-roll