diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index a5a7aa5..e8db5b1 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -41,5 +41,11 @@ UIViewControllerBasedStatusBarAppearance + NSPhotoLibraryAddUsageDescription + Need this permission to save tangheem as image on device + NSMicrophoneUsageDescription + Need this permission to record voice + UISupportsDocumentBrowser + diff --git a/lib/widgets/aya_record_widget.dart b/lib/widgets/aya_record_widget.dart index 222c5e9..16a2c9d 100644 --- a/lib/widgets/aya_record_widget.dart +++ b/lib/widgets/aya_record_widget.dart @@ -86,12 +86,16 @@ class _AyaRecordWidgetState extends State { Future getFilePath() async { Directory storageDirectory = await getApplicationDocumentsDirectory(); + if (Platform.isIOS) { + storageDirectory = await getTemporaryDirectory(); + } + String sdPath = storageDirectory.path + "/record"; var d = Directory(sdPath); if (!d.existsSync()) { d.createSync(recursive: true); } - return sdPath + "/test.mp3"; + return sdPath + "/temp${DateTime.now().millisecondsSinceEpoch}.mp3"; } @override @@ -292,8 +296,14 @@ class _AyaRecordWidgetState extends State { void saveToPhoneStorage(String filePath) async { File file = File(filePath); - - Directory storageDirectory = await getExternalStorageDirectory(); + Directory storageDirectory; + if (Platform.isAndroid) { + storageDirectory = await getExternalStorageDirectory(); + } else if (Platform.isIOS) { + storageDirectory = await getApplicationDocumentsDirectory(); + } else { + return; + } String storagePath = storageDirectory.path; if (storagePath.contains("/Android/data")) {