No Description

ios.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import {
  5. NativeModules,
  6. DeviceEventEmitter,
  7. Platform,
  8. NativeAppEventEmitter,
  9. } from 'react-native'
  10. const RNFetchBlob:RNFetchBlobNative = NativeModules.RNFetchBlob
  11. /**
  12. * Open a file using UIDocumentInteractionController
  13. * @param {string} path Path of the file to be open.
  14. * @param {string} scheme URI scheme that needs to support, optional
  15. * @return {Promise}
  16. */
  17. function previewDocument(path:string, scheme:string) {
  18. if(Platform.OS === 'ios')
  19. return RNFetchBlob.previewDocument('file://' + path, scheme)
  20. else
  21. return Promise.reject('RNFetchBlob.openDocument only supports IOS.')
  22. }
  23. /**
  24. * Preview a file using UIDocumentInteractionController
  25. * @param {string} path Path of the file to be open.
  26. * @param {string} scheme URI scheme that needs to support, optional
  27. * @return {Promise}
  28. */
  29. function openDocument(path:string, scheme:string) {
  30. if(Platform.OS === 'ios')
  31. return RNFetchBlob.openDocument('file://' + path, scheme)
  32. else
  33. return Promise.reject('RNFetchBlob.previewDocument only supports IOS.')
  34. }
  35. /**
  36. * Set excludeFromBackupKey to a URL to prevent the resource to be backuped to
  37. * iCloud.
  38. * @param {string} url URL of the resource, only file URL is supported
  39. * @return {Promise}
  40. */
  41. function excludeFromBackupKey(path:string) {
  42. return RNFetchBlob.excludeFromBackupKey('file://' + path);
  43. }
  44. export default {
  45. openDocument,
  46. previewDocument,
  47. excludeFromBackupKey
  48. }