Friday, May 10, 2024
HomeiOS Developmentios - how can enable customers to view recordsdata on their cellphone...

ios – how can enable customers to view recordsdata on their cellphone when they’re downloaded from my app


async perform saveFile(uri: string, filename: string, mimetype: any) {
    if (Platform.OS === 'android') {
      const permissions =
        await FileSystem.StorageAccessFramework.requestDirectoryPermissionsAsync();
      if (permissions.granted) {
        const base64 = await FileSystem.readAsStringAsync(uri, {
          encoding: FileSystem.EncodingType.Base64,
        });

        await FileSystem.StorageAccessFramework.createFileAsync(
          permissions.directoryUri,
          filename,
          mimetype
        )
          .then(async (uri) => {
            await FileSystem.writeAsStringAsync(uri, base64, {
              encoding: FileSystem.EncodingType.Base64,
            });
          })
          .catch((e) => console.log(e));
      } else {
        Toast.present({
          kind: 'error',
          text1: 'Permission Denied',
          text2: 'Please allow storage permission',
        });
      }
    } else if (Platform.OS === 'ios') {
      const documentDirectory = FileSystem.documentDirectory;
      const path = documentDirectory + filename;
      strive {
        await FileSystem.writeAsStringAsync(path, uri, {
          encoding: FileSystem.EncodingType.UTF8,
        });

        Toast.present({
          kind: 'success',
          text1: 'File saved',
          text2: 'File efficiently saved in Paperwork folder',
        });
      } catch (error) {
        console.error('Error saving file:', error);
        Toast.present({
          kind: 'error',
          text1: 'Error saving file',
          text2: 'Please strive once more later',
        });
      }
    } else {
      Toast.present({
        kind: 'error',
        text1: 'Unsupported Platform',
        text2: 'File saving not supported on this platform',
      });
    }
  }

In Android its working that customers choose folder to save lots of their recordsdata after which go to that folder to view the recordsdata however in ios i’m unable to find the place the file has been downloaded please assist me out i’m utilizing epxo sdk 49 for my app and i need customers to view their recordsdata that has been downloaded on their cellphone



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments