Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open the redirect_uri obtained after VP in an external app. #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions tw2023_wallet/Feature/ShareCredential/Views/RedirectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,6 @@ struct RedirectView: View {
)
}
}

func openURLInSafari(urlString: String) {
if let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
presentationMode.wrappedValue.dismiss()
}
else {
print("invalid url is specified.")
alertTitle = "URLが不正です"
alertMessage = urlString
showAlert = true
}
}
}

#Preview {
Expand Down
35 changes: 10 additions & 25 deletions tw2023_wallet/tw2023_walletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extension String: Identifiable {
struct tw2023_walletApp: App {
@State private var credentialOffer: String? = nil
@State private var openID4VP: String? = nil
@State private var navigateToRedirectView = false

@State private var sharingRequestModel = SharingRequestModel()

Expand Down Expand Up @@ -59,36 +58,13 @@ struct tw2023_walletApp: App {
if let postResult = sharingRequestModel.postResult,
let location = postResult.location
{
navigateToRedirectView.toggle()
openURLInExternalApp(urlString: location)
}
}
) { value in
SharingRequest(args: createOpenID4VPArgs(value: value)).environment(
sharingRequestModel)
}
.fullScreenCover(
isPresented: $navigateToRedirectView,
onDismiss: {
navigateToRedirectView = false
}
) {
// let (urlString, cookies) = getRedirectParameters()
if let postResult = sharingRequestModel.postResult,
let urlString = postResult.location
{
NavigationView {
RedirectView(urlString: urlString, cookieStrings: [])
.navigationBarItems(
trailing: Button("close") {
navigateToRedirectView = false
}
)
}
}
else {
EmptyView()
}
}
}
else {
AuthenticationView(authenticationManager: self.authenticationManager).onOpenURL(
Expand All @@ -103,6 +79,15 @@ struct tw2023_walletApp: App {
}
}

private func openURLInExternalApp(urlString: String) {
if let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
else {
print("invalid url is specified.")
}
}

private func handleScenePhaseChange(_ newPhase: ScenePhase) {
switch newPhase {
case .active:
Expand Down
Loading