如何从React Native应用程序打开iOS画廊应用程序

Add*_*din 4 deep-linking ios camera-roll react-native react-native-ios

我无法从React Native应用程序打开iOS画廊应用程序。我有文件网址和资产网址。我从CameraRoll获取了资源网址。现在,我想打开图库本身以查看图像。

这是我使用的代码

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')
  }
})
Run Code Online (Sandbox Code Playgroud)

谢谢

小智 5

openPhotos = () =>{
switch(Platform.OS){
  case "ios":
    Linking.openURL("photos-redirect://");
  break;
  case "android":
    Linking.openURL("content://media/internal/images/media");
  break;
  default:
    console.log("Could not open gallery app");
 }
}
Run Code Online (Sandbox Code Playgroud)


jwa*_*nga 0

我不知道打开特定资产的方法。但是,您可以使用以下方案打开照片应用程序:

Linking.openURL('photos-redirect://')