diff --git a/app/views/Export.js b/app/views/Export.js index 8da6c1ccb6..2758fd03b7 100644 --- a/app/views/Export.js +++ b/app/views/Export.js @@ -7,8 +7,7 @@ import { View, Text, Alert, - Image, - Share + Image } from 'react-native'; import colors from "../constants/colors"; @@ -16,6 +15,14 @@ import WebView from 'react-native-webview'; import Button from "../components/Button"; import BackgroundGeolocation from '@mauron85/react-native-background-geolocation'; import { GetStoreData } from '../helpers/General'; +import Share from 'react-native-share'; +import RNFetchBlob from 'rn-fetch-blob'; + +const base64 = RNFetchBlob.base64 + + +//import RNShareFile from 'react-native-file-share'; + class ExportScreen extends Component { constructor(props) { @@ -25,31 +32,27 @@ class ExportScreen extends Component { } onShare = async () => { - try { - const locationArray = await GetStoreData('LOCATION_DATA'); - var locationData; - - if (locationArray !== null) { - locationData = JSON.parse(locationArray); - } else { - locationData = []; - } - - const result = await Share.share({ - message: JSON.stringify(locationData) - }); - - if (result.action === Share.sharedAction) { - if (result.activityType) { - // shared with activity type of result.activityType + try { + const locationArray = await GetStoreData('LOCATION_DATA'); + var locationData; + + if (locationArray !== null) { + locationData = JSON.parse(locationArray); } else { - // shared + locationData = []; } - } else if (result.action === Share.dismissedAction) { - // dismissed - } - } catch (error) { - console.log(error.message); + + b64Data = base64.encode(JSON.stringify(locationData)); + Share.open({ + url: "data:string/txt;base64," + b64Data + }).then(res => { + console.log(res); + }) + .catch(err => { + console.log(err.message, err.code); + }) + } catch (error) { + console.log(error.message); } }; @@ -63,6 +66,7 @@ class ExportScreen extends Component { } render() { + return ( diff --git a/package.json b/package.json index d8e1c69f25..5c289218e3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,9 @@ "react-native-gesture-handler": "~1.5.0", "react-native-safe-area-context": "0.6.0", "react-native-screens": "2.0.0-alpha.12", - "react-native-webview": "^8.1.2" + "react-native-share": "^3.0.0", + "react-native-webview": "^8.1.2", + "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "^7.8.6",