Fix uploading and downloading sets on ios

Just need to now use a library for notifications
instead of my native DownloadModule
This commit is contained in:
Brandon Presley 2022-11-22 22:16:14 +13:00
parent 93b4861da9
commit c50dc4aacf
3 changed files with 10 additions and 14 deletions

View File

@ -1,6 +1,5 @@
import {NavigationProp, useNavigation} from '@react-navigation/native'
import {useCallback, useState} from 'react'
import {Platform} from 'react-native'
import DocumentPicker from 'react-native-document-picker'
import {FileSystem} from 'react-native-file-access'
import {Divider, IconButton, Menu} from 'react-native-paper'
@ -154,16 +153,8 @@ export default function DrawerMenu({name}: {name: keyof DrawerParamList}) {
icon="more-vert"
/>
}>
{Platform.OS === 'android' && (
<>
<Menu.Item
icon="arrow-downward"
onPress={download}
title="Download"
/>
<Menu.Item icon="arrow-upward" onPress={upload} title="Upload" />
</>
)}
<Menu.Item icon="arrow-downward" onPress={download} title="Download" />
<Menu.Item icon="arrow-upward" onPress={upload} title="Upload" />
<Divider />
<Menu.Item
icon="delete"

View File

@ -47,6 +47,10 @@
<array>
<string>armv7</string>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>

View File

@ -1,9 +1,10 @@
import {NativeModules, PermissionsAndroid} from 'react-native'
import {NativeModules, PermissionsAndroid, Platform} from 'react-native'
import {Dirs, FileSystem} from 'react-native-file-access'
export const write = async (name: string, data: string) => {
const filePath = `${Dirs.DocumentDir}/${name}`
const permission = async () => {
if (Platform.OS !== 'android') return true
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
)
@ -12,7 +13,7 @@ export const write = async (name: string, data: string) => {
const granted = await permission()
if (!granted) return
await FileSystem.writeFile(filePath, data)
if (!FileSystem.exists(filePath)) return
await FileSystem.cpExternal(filePath, name, 'downloads')
if (Platform.OS === 'android')
await FileSystem.cpExternal(filePath, name, 'downloads')
NativeModules.DownloadModule.show(name)
}