fix file share not appearing in share menu on iOS

This commit is contained in:
ammarahm-ed
2021-02-23 16:38:58 +05:00
parent 9e44108ef5
commit 0192675e9e

View File

@@ -1,4 +1,5 @@
import React, {createRef} from 'react'; import React, {createRef} from 'react';
import { Platform } from 'react-native';
import {Clipboard, View} from 'react-native'; import {Clipboard, View} from 'react-native';
import QRCode from 'react-native-qrcode-svg'; import QRCode from 'react-native-qrcode-svg';
import Share from 'react-native-share'; import Share from 'react-native-share';
@@ -137,7 +138,7 @@ class RecoveryKeyDialog extends React.Component {
} }
try { try {
let path = await Storage.checkAndCreateDir('/'); let path = await Storage.checkAndCreateDir('/');
let fileName = 'nn_' + 'test' + '_recovery_key.txt'; let fileName = 'nn_' + this.user?.email + '_recovery_key.txt';
RNFetchBlob = require('rn-fetch-blob').default; RNFetchBlob = require('rn-fetch-blob').default;
await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, 'utf8'); await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, 'utf8');
ToastEvent.show({ ToastEvent.show({
@@ -167,9 +168,8 @@ class RecoveryKeyDialog extends React.Component {
if (!path) return; if (!path) return;
try { try {
await Share.open({ await Share.open({
url: 'file:/' + path, url: Platform.OS === "ios" ? path : 'file:/' + path,
title: 'Save recovery key to cloud', title: 'Save recovery key to cloud',
message: this.state.key,
failOnCancel: false, failOnCancel: false,
}); });
} catch (e) {} } catch (e) {}