Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应本机fbsdk共享对话框。如何与预先填充的邮件和照片内容一起共享?_Javascript_Reactjs_React Native - Fatal编程技术网

Javascript 反应本机fbsdk共享对话框。如何与预先填充的邮件和照片内容一起共享?

Javascript 反应本机fbsdk共享对话框。如何与预先填充的邮件和照片内容一起共享?,javascript,reactjs,react-native,Javascript,Reactjs,React Native,我有react-native 0.44.0和react-native fbsdk 0.5.0。ShareDialog组件工作正常,但由于缺少文档,解释被完全卡住了。我有自己的API应用程序。我使用照片数组制作API调用获取共享模板 .then((responseData) => { console.log("Facebook Share Api Test") console.log(responseData) // After receiving result checking Platf

我有react-native 0.44.0和react-native fbsdk 0.5.0。ShareDialog组件工作正常,但由于缺少文档,解释被完全卡住了。我有自己的API应用程序。我使用照片数组制作API调用获取共享模板

.then((responseData) => {
console.log("Facebook Share Api Test")
console.log(responseData)
// After receiving result checking Platform
// If this is iOS we should let our result image links be fetched to encode it in Base64.
if(Platform.OS !== 'android'){
  console.log("Not Andro!d!")
  let imgUrl
  let sharePhotoContent

  let iteratePhotos = function (data) {
    var photoInfo = [];
    var ready = Promise.resolve(null)
    data.forEach(function (value, i) {
      let iconURL = API.SERVER_URL + API.SERVICE_PORT + API.HEAD_ICON_RES_URL + value.photo_id + 'S'
      ready = ready.then(function () {
        return RNFetchBlob
        .fetch('GET', iconURL)
        .then(res => res.data)
        .then(resData => {
            imgUrl = 'data:image/jpeg;base64,' + resData
            console.log(imgUrl) 
            return imgUrl
        })
        .then(img => {
          console.log(img) 
          let res = {
            imageUrl: img,
            userGenerated: true,
            caption: value.comment
          } 
          return res
        })
        .catch(err => {
          console.log(err)
        })
      }).then(function (resData) {
        photoInfo[i] = resData;
      });
    });

    return ready.then(function () { return photoInfo; });
  }

  iteratePhotos(responseData.photos).then((res) => {
    console.log('res', res)
    if(res.length > 0){
      sharePhotoContent = {
        contentType: 'photo',
        contentDescription: 'Wow, check out this great site!',
        photos: res
      }
    } else {
      sharePhotoContent = {
        contentType: 'link',
        contentUrl: 'some url',
        message: responseData.message
      }
    }
    ShareDialog.canShow(sharePhotoContent)
    .then((canShow) => {
      if (canShow) {
        return ShareDialog.show(sharePhotoContent);
      }
    })
    .then((result) => {
      this.setState({isshowIndicator: false})
      if(!result.isCancelled){
        this.setState({isFacebookShared: true})
        setTimeout(() => alert("Success!"), 100)
      }
    })
    .catch(error => {
      this.setState({isshowIndicator: false})
      console.log(error)
      setTimeout(() => alert('Share fail with error: ' + error), 100)
      }
    )
  })
} else {
  let photoInfo = responseData.photos.map(value => {
    return {
      imageUrl: API.SERVER_URL + API.SERVICE_PORT + API.HEAD_ICON_RES_URL + value.photo_id + 'S',
      ...value 
    }
  })
  console.log(photoInfo, "It IS ANDROID")
  if(responseData.photos.length > 0){
    var sharePhotoContent = {
      contentType: 'photo',
      photos: photoInfo
    }
  } else {
    var sharePhotoContent = {
      contentType: 'link',
      contentUrl: 'some url',
      message: responseData.message
    }
  }
  ShareDialog.canShow(sharePhotoContent)
  .then((canShow) => {
    if (canShow) {
      return ShareDialog.show(sharePhotoContent);
    }
  })
  .then((result) => {
    this.setState({isshowIndicator: false})
    if(!result.isCancelled){
      this.setState({isFacebookShared: true})
      setTimeout(() => alert("Success!"), 100)
    }
  })
  .catch(error => {
    this.setState({isshowIndicator: false})
    setTimeout(() => alert('Share fail with error: ' + error), 100)
  })
}
})
当我点击“共享”时,sharedialog打开,我想要的照片被粘贴,但消息行等待填充 但我需要打开一个共享对话框:

需要附上的照片; 根据我从API收到的消息预填充消息。 这可能吗?请帮助,这是预发布的功能需要实现非常快,我不知道如何

附加描述1的屏幕截图。这是怎么回事?2.我想做的事


一些社交网络(如facebook)不支持按照其政策为用户预先填写信息: