Skip to content

Commit

Permalink
fix pass kit related crash on iPad (#2171)
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy authored Nov 17, 2023
1 parent 1809630 commit 3bddbca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion DuckDuckGo/FilePreviewHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ struct FilePreviewHelper {

static func canAutoPreviewMIMEType(_ mimeType: MIMEType) -> Bool {
switch mimeType {
case .reality, .usdz, .passbook, .calendar:
case .passbook:
return UIDevice.current.userInterfaceIdiom == .phone

case .reality, .usdz, .calendar:
return true
default:
return false
Expand Down
5 changes: 3 additions & 2 deletions DuckDuckGo/PassKitPreviewHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class PassKitPreviewHelper: FilePreview {
do {
let data = try Data(contentsOf: self.filePath)
let pass = try PKPass(data: data)
let controller = PKAddPassesViewController(pass: pass)!
viewController?.present(controller, animated: true)
if let controller = PKAddPassesViewController(pass: pass) {
viewController?.present(controller, animated: true)
}
} catch {
os_log("Can't present passkit: %s", type: .debug, error.localizedDescription)
}
Expand Down

0 comments on commit 3bddbca

Please sign in to comment.