I'm having this problem, with this code:
let docPicker = UIDocumentPickerViewController(forOpeningContentTypes: [
.pdf
])
docPicker.delegate = self
docPicker.modalPresentationStyle = .currentContext
view.window?.rootViewController?.present(docPicker, animated: true, completion: nil)
but then when I open the simulator and click the button that calls to the method that has this code...
Cannot pick the pdf document.
Testing in browserstack with real devices is working, but it's a very slow process, why I cannot use simulators to make work this?
Post
Replies
Boosts
Views
Activity
I'm working with a deeplink I have to implement to my app. The deeplink is working because in some cases i will explain later the method is being executed. So when I tap the deeplink with a deeplink-tester-web I detect if the url is which I want and, if it's the case, i post a notification to NotificationCenter with a string parameter I need.
Case 1. I tap the deeplink when the view controller with the addObserver method is at the background with the app itself. It works (the only case)
Case 2. The app is closed so the deeplink opens the app directly in that view controller (the method is no being called event if the notification is there) Why?
Case 3. The app is at the background but in another screen. When I tap the deeplink and, after returning to the app, travel to my viewController the method is not called when the ViewController becomes visible. Why?
I've not seen anything in the documentation that can help me and i cannot access to the array of observers because the API does not allow that
Thanks. Any help will be appreciate.
Code:
When the deeplink is tapped the app delegate method that manages universal links call to this code when the url is a specific one
@objc func handleRecommendedOffer(offerId: String) {
NotificationCenter.default.post(name: .deeplinkRecommendedOfferNotification, object: nil, userInfo: ["offerId": offerId])
}
In my viewcontroller viewDidLoad (i've tried also viewWillAppear too):
NotificationCenter.default.addObserver(self, selector: #selector(goToDetail(notification:)), name: .deeplinkRecommendedOfferNotification, object: nil)
@objc private func goToDetail(notification: Notification) {
if let userInfo = notification.userInfo, let offerId = userInfo["offerId"] as? String {
showLoading()
getOfferViewModel.getOfferDetail(id: offerId)
}
}
I'm upgrading my app from minVersion iOS 11 to iOS 12. My compiler says that UIDocumentMenuViewController with UIDocumentPickerViewController is deprecated, they recommend to use directly the last one. So I change the code.
fileprivate func openDocumentPicker() {
let documentPicker = UIDocumentPickerViewController(
documentTypes: [
"com.adobe.pdf",
"org.openxmlformats.wordprocessingml.document", // DOCX
"com.microsoft.word.doc" // DOC
],
in: .import
)
documentPicker.delegate = self
view.window?.rootViewController?.present(documentPicker, animated: true, completion: nil)
}
When I open the picker in iOS 17.2 simulator and under it is well shown, like a page sheet. But in iOS 18.0 and up at first it opens like a page sheet with no content but then it is displayed as a transparent window with no content. Is there any issue with this component and iOS 18? If I open the picker through UIDocumentMenuViewControllerDelegate in an iphone with iOS 18.2 it is well shown.
Image in iOS 18.2 with the snippet
The same snippet in iOS 17.2 (and expected in older ones)