struct GalleryView: View {
@State private var permissionGranted: Bool = false
@State private var permissionError: PermissionError?
var body: some View {
NavigationView {
VStack {
List(Media.Photos.all) { photo in
NavigationLink(destination: PhotoView(photo: photo)) {
Text(photo.id)
}
}.navigationBarTitle("Photos", displayMode: .inline)
Button(action: {
self.requestPermission()
}) {
Text("Trigger permission request")
}
}
}
}
}
extension GalleryView {
private func requestPermission() {
Media.requestPermission { result in
switch result {
case .success:
self.permissionGranted = true
self.permissionError = nil
case .failure(let error):
self.permissionGranted = false
self.permissionError = error
}
}
}
}
3. I start the app 2nd, I try to tap [Trigger permission request] button in the above code, I expect for the alert below, but nothing happened.
So, How could I open the photo permission selection again in my application? Thanks a lot.