Commit abc71913 authored by shigemi miura's avatar shigemi miura

Camera使用許可

parent 3d687d77
......@@ -48,7 +48,7 @@ enum HttpRequestType : String {
case GetMessage = "https://ssv-qc-web.azurewebsites.net/api/chatdata/getmessages?shipId=XXXXX"
case SignalR = "https://ssv-qc-web.azurewebsites.net/signalr/shore"
case PushHistory = "https://ssv-qc-web.azurewebsites.net/api/sailassist/pushhistory/XXXXX"
case UploadImage = "https://ssv-qc-web.azurewebsites.net/api/chatdata/uploadimage"
case UploadImage = "https://ssv-qc-web.azur.net/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://ssv-qc-notification.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=qjI5K38IyGfh2arFherVgp5tNUBE2U4eVClgTEQip54="
case HubName = "ssv-qc-sailassist-notification"
case storage = "https://tacmiquaritycheckstorage.z31.web.core.windows.net/"
......
......@@ -6,15 +6,17 @@
//
import SwiftUI
import AVFoundation
struct LoginTypeSelectView: View{
@Binding var isQrRead: Bool
@Binding var viewMode: LoginViewMode
@State var isCameraAlert = false
var body: some View{
VStack (spacing: 20) {
Button(action: {
isQrRead = true
checkCamera()
}, label: {
Text("Read the QR code")
.font(FontStyle.TitleS.font)
......@@ -33,11 +35,45 @@ struct LoginTypeSelectView: View{
.font(FontStyle.SupplementText.font)
.foregroundColor(ColorSet.Body.color)
})
.alert("Error", isPresented: $isCameraAlert) {
Button("Cancel") {}
Button("Setting") {
guard let settingsURL = URL(string: UIApplication.openSettingsURLString) else {
return
}
UIApplication.shared.open(settingsURL, options: [:], completionHandler: nil)
}
} message: {
Text("Please allow access to the camera in iOS settings.")
}
}
.padding(.horizontal, 50)
}
/**
* カメラ許可確認
*/
func checkCamera() {
isQrRead = true
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)
if status == AVAuthorizationStatus.authorized {
print(debug: "Camera permission")
} else if status == AVAuthorizationStatus.notDetermined {
print(debug: "Haven't asked for camera access permission yet")
} else if status == AVAuthorizationStatus.denied {
print(debug: "Camera not allowed")
AVCaptureDevice.requestAccess(for: .video, completionHandler: { granted in
if (granted == false) {
isCameraAlert = true
isQrRead = false
}
})
}
}
}
#Preview {
LoginTypeSelectView(isQrRead: .constant(false), viewMode: .constant(.SelectType))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment