File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 55
66import Foundation
77import NextcloudKit
8+ import PassKit
89import PhotosUI
910import UIKit
1011import Realm
@@ -4129,6 +4130,17 @@ import SwiftUI
41294130 return
41304131 }
41314132
4133+ // Use PKAddPassesViewController for Apple Wallet passes
4134+ if fileExtension == " pkpass " {
4135+ if let passData = try ? Data ( contentsOf: URL ( fileURLWithPath: fileLocalPath) ) ,
4136+ let pass = try ? PKPass ( data: passData) ,
4137+ let addPassVC = PKAddPassesViewController ( pass: pass) {
4138+ self . present ( addPassVC, animated: true )
4139+ self . isPreviewControllerShown = false
4140+ return
4141+ }
4142+ }
4143+
41324144 let preview = QLPreviewController ( )
41334145 preview. dataSource = self
41344146 preview. delegate = self
Original file line number Diff line number Diff line change 55
66import UIKit
77import QuickLook
8+ import PassKit
89
910@objcMembers class RoomSharedItemsTableViewController : UITableViewController ,
1011 NCChatFileControllerDelegate ,
@@ -276,6 +277,7 @@ import QuickLook
276277
277278 let fileExtension = URL ( fileURLWithPath: fileLocalPath) . pathExtension. lowercased ( )
278279
280+ // Use VLCKitVideoViewController for file formats unsupported by the native PreviewController
279281 if VLCKitVideoViewController . supportedFileExtensions. contains ( fileExtension) {
280282 let vlcViewController = VLCKitVideoViewController ( filePath: fileLocalPath)
281283 vlcViewController. delegate = self
@@ -286,6 +288,17 @@ import QuickLook
286288 return
287289 }
288290
291+ // Use PKAddPassesViewController for Apple Wallet passes
292+ if fileExtension == " pkpass " {
293+ if let passData = try ? Data ( contentsOf: URL ( fileURLWithPath: fileLocalPath) ) ,
294+ let pass = try ? PKPass ( data: passData) ,
295+ let addPassVC = PKAddPassesViewController ( pass: pass) {
296+ self . present ( addPassVC, animated: true )
297+ self . isPreviewControllerShown = false
298+ return
299+ }
300+ }
301+
289302 let previewController = QLPreviewController ( )
290303 previewController. dataSource = self
291304 previewController. delegate = self
Original file line number Diff line number Diff line change @@ -375,6 +375,22 @@ - (void)setSharedItemToShareConfirmationViewController:(ShareConfirmationViewCon
375375 }];
376376 return ;
377377 }
378+ // Check if shared pkpass (Apple Wallet)
379+ if ([itemProvider hasItemConformingToTypeIdentifier: @" com.apple.pkpass" ]) {
380+ [itemProvider loadItemForTypeIdentifier: @" com.apple.pkpass"
381+ options: nil
382+ completionHandler: ^(id <NSSecureCoding > _Nullable item, NSError * _Null_unspecified error) {
383+ if ([(NSObject *)item isKindOfClass: [NSData class ]]) {
384+ NSLog (@" Shared Pass = %@ " , item);
385+ NSData *passData = (NSData *)item;
386+ NSString *passFileName = [NSString stringWithFormat: @" Pass_%.f .pkpass" , [[NSDate date ] timeIntervalSince1970 ] * 1000 ];
387+ NSURL *tempURL = [NSURL fileURLWithPath: [NSTemporaryDirectory () stringByAppendingPathComponent: passFileName]];
388+ [passData writeToURL: tempURL atomically: YES ];
389+ [shareConfirmationVC.shareItemController addItemWithURLAndName: tempURL withName: passFileName];
390+ }
391+ }];
392+ return ;
393+ }
378394 // Check if shared URL
379395 if ([itemProvider hasItemConformingToTypeIdentifier: @" public.url" ]) {
380396 [itemProvider loadItemForTypeIdentifier: @" public.url"
You can’t perform that action at this time.
0 commit comments