ios – macCatalyst share extension occasionaly blocks input?

ios – macCatalyst share extension occasionaly blocks input?

ios – macCatalyst share extension occasionaly blocks input?

I’m having a hard-to-reproduce issue with my share extension code that I struggle to fix – I can’t find any similar issues anywhere and my attempts so far have been shots in the dark.

This is a Catalyst app and it works fine on iOS and iPadOS. This issue only happens on Catalyst.

When the user opens the share extension from Safari, a form will pop up and occasionally there’s no way to interact with it. Click on buttons or trying to focus on text fields don’t do anything. It just blocks all inputs and the only way to get out of that situation is to restart Safari. It’s incredibly annoying but happens very randomly, probably once or twice per day.

The NSExtensionPrincipalClass is set to AddPostNavigationController which looks like this:

    init() {

        self.account = AccountManager.shared.account
        self.viewController = account.isLoggedIn ? EditPostViewController(account: account) : EmptyViewController(account: account)

        super.init(rootViewController: viewController)

    override func beginRequest(with context: NSExtensionContext) {
        super.beginRequest(with: context)

        switch viewController {
        case let viewController as EditPostViewController:
            let _ = viewController.view
            viewController.actionExtensionContext = context
        case let viewController as EmptyViewController:
            let _ = viewController.view
            viewController.actionExtensionContext = context

The actionExtensionContext property in both EditPostViewController and EmptyViewController populates the form values based on the web site and set up callbacks like:

onCancel = { extensionContext.completeRequest(returningItems: nil) }
onPostSaved = { extensionContext.completeRequest(returningItems: nil) }

Every time the share extension pops up, I can see form values being correctly set. It just refuses to accept inputs from time to time.

Any ideas are welcome.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *