如果需要从应用程序应用程序写或阅读,我是否需要告知或获取用户的权限?

发布于 2025-01-23 16:44:27 字数 820 浏览 2 评论 0原文

如果需要从应用程序应用程序写或阅读,我是否需要告知或获取用户的权限?

我需要正式和合法地知道我是否必须要求用户授予我iOS或Android的权限

Future<String> get _localPath async {
  final directory = await getApplicationDocumentsDirectory();

  return directory.path;
}

 Future<File> get _localFile async {
  final path = await _localPath;
  return File('$path/counter.txt');
}
    // Write the file
    Future<File> writeCounter(int counter) async {
  final file = await _localFile;
  return file.writeAsString('$counter');
}
    
    // Read the file
   Future<int> readCounter() async {
  try {
    final file = await _localFile;
    final contents = await file.readAsString();
    return int.parse(contents);
  } catch (e) {
    return 0;
  }
}turn int.parse(contents);
      } catch (e) {
        return 0;
      }
    }

do i need inform or take permissions from users if i need to write or read from application app ?

i need to know Officially and legally if Do I have to ask the user to grant me permissions either by ios or android

Future<String> get _localPath async {
  final directory = await getApplicationDocumentsDirectory();

  return directory.path;
}

 Future<File> get _localFile async {
  final path = await _localPath;
  return File('$path/counter.txt');
}
    // Write the file
    Future<File> writeCounter(int counter) async {
  final file = await _localFile;
  return file.writeAsString('$counter');
}
    
    // Read the file
   Future<int> readCounter() async {
  try {
    final file = await _localFile;
    final contents = await file.readAsString();
    return int.parse(contents);
  } catch (e) {
    return 0;
  }
}turn int.parse(contents);
      } catch (e) {
        return 0;
      }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぽ尐不点ル 2025-01-30 16:44:27

是的,对于Android,您需要阅读和写入许可,但对于iOS,仅需要阅读权限,例如:

我想阅读和写入许可,然后我将修改

info.plist iOS中的文件

<key>NSMicrophoneUsageDescription</key>
<string>This app require permission to access microphone</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app require permission to access gallery</string>

ask permission for whatever resources I want

androidmainfest.xml android中的文件

<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permissionandroid:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

Yes, for android you need read and write permission but for iOS only read permission required, for example:

I want to read and write permission then I will modify

info.plist file in iOS

<key>NSMicrophoneUsageDescription</key>
<string>This app require permission to access microphone</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app require permission to access gallery</string>

ask permission for whatever resources I want

AndroidMainfest.xml file in android

<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permissionandroid:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文