簡體   English   中英

如何從React Native應用程序打開iOS gallery應用程序

[英]How to open iOS gallery app from React Native app

我無法從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')
  }
})

謝謝

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");
 }
}

我不知道打開特定資產的方法。 但是,您可以使用以下方案打開照片應用程序:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM