Skip to content

Commit dd1e853

Browse files
authored
Merge pull request #6 from JordyLangen/expose_protocol_handler_instance
Expose ProtocolHandlerPlugin so it's possible to call 'handleEventURL' for multiple plugins
2 parents 130e8cf + 7731d13 commit dd1e853

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

macos/Classes/ProtocolHandlerPlugin.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ import Cocoa
22
import FlutterMacOS
33

44
public class ProtocolHandlerPlugin: NSObject, FlutterPlugin {
5+
private static var _instance: ProtocolHandlerPlugin?
56
private var channel: FlutterMethodChannel!
6-
77
private var _initialUrl: String?
8+
9+
public static var instance: ProtocolHandlerPlugin {
10+
get {
11+
return _instance!
12+
}
13+
}
814

915
override init(){
1016
super.init();
@@ -14,12 +20,13 @@ public class ProtocolHandlerPlugin: NSObject, FlutterPlugin {
1420
public static func register(with registrar: FlutterPluginRegistrar) {
1521
let channel = FlutterMethodChannel(name: "protocol_handler", binaryMessenger: registrar.messenger)
1622
let instance = ProtocolHandlerPlugin()
23+
_instance = instance
1724
instance.channel = channel
1825
registrar.addMethodCallDelegate(instance, channel: channel)
1926
}
2027

2128
@objc
22-
private func handleURLEvent(_ event: NSAppleEventDescriptor, with replyEvent: NSAppleEventDescriptor) {
29+
public func handleURLEvent(_ event: NSAppleEventDescriptor, with replyEvent: NSAppleEventDescriptor) {
2330
guard let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue else { return }
2431
if (_initialUrl == nil) {
2532
_initialUrl = urlString

0 commit comments

Comments
 (0)