Nav apraksta

ios.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2016 wkh237@github. All rights reserved.
  2. // Use of this source code is governed by a MIT-style license that can be
  3. // found in the LICENSE file.
  4. // @flow
  5. import {
  6. NativeModules,
  7. DeviceEventEmitter,
  8. Platform,
  9. NativeAppEventEmitter,
  10. } from 'react-native'
  11. const RNFetchBlob:RNFetchBlobNative = NativeModules.RNFetchBlob
  12. /**
  13. * Open a file using UIDocumentInteractionController
  14. * @param {string]} path Path of the file to be open.
  15. * @param {string} scheme URI scheme that needs to support, optional
  16. * @return {Promise}
  17. */
  18. function openDocument(path:string, scheme:string) {
  19. if(Platform.OS === 'ios')
  20. return RNFetchBlob.openDocument('file://' + path, scheme)
  21. else
  22. return Promise.reject('RNFetchBlob.openDocument only supports IOS.')
  23. }
  24. /**
  25. * Preview a file using UIDocumentInteractionController
  26. * @param {string]} path Path of the file to be open.
  27. * @param {string} scheme URI scheme that needs to support, optional
  28. * @return {Promise}
  29. */
  30. function previewDocument(path:string, scheme:string) {
  31. if(Platform.OS === 'ios')
  32. return RNFetchBlob.previewDocument('file://' + path, scheme)
  33. else
  34. return Promise.reject('RNFetchBlob.previewDocument only supports IOS.')
  35. }
  36. export default {
  37. openDocument,
  38. previewDocument
  39. }