MaikuB / MaikuB/flutter_appauth

[MacOS] Deeplink handling fails when another plugin registers an event handler

Open
#358 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Objective-C
Stars
308
Forks
301
Avg merge
2d 11h
Merged PRs (30d)
5

Description

We've run into the issue that we have multiple plugins that depend on setting an event handler through `NSAppleEventManager.shared().setEventHandler`, the next one always overwriting the previous one.

In our case it's the [uni_links_desktop](https://github.com/leanflutter/uni_links_desktop) plugin that handles every deeplink as it registers after the flutter app_auth plugin. To solve this, we've come up with two solutions:

1. A `FlutterAppAuth` static instance is exposed, so we can do something like this:

```swift
// our own event handler that calls every plugins `handleURLEvent` method
public func handleURLEvent(_ event: NSAppleEventDescriptor, with replyEvent: NSAppleEventDescriptor) {
HandlerA.instance.handleURLEvent(...)
HandlerB.instance.handleURLEvent(...)
// other handlers
}
```

2. A new method on the platform interface like `processCallback(url)` which we can call after `uni_links` gave us the callback url on the flutter side. (I understand this solution solves _our_ problem, not necessarily everyones problem who might run into the same issue). I've made a quick proof of concept and this would work.

Let me know what you think, we'd be happy to help out and create the PR if needed.

Contributor guide

Open the contributing guide

Research direction

Start with the macOS deeplink path around NSAppleEventManager.shared().setEventHandler and the FlutterAppAuth handleURLEvent entry point. Compare the proposed static instance approach with a platform-interface processCallback(url) method, then confirm how uni_links_desktop interacts with either design. Done means callbacks can be handled without one plugin overwriting another.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter, macos, swift
Domain
authentication, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.