go-flutter icon indicating copy to clipboard operation
go-flutter copied to clipboard

New Plugin: uni_links

Open StefanLobbenmeier opened this issue 6 years ago • 15 comments

Hi, I will probably need to use uni_links soon-ish. That will probably require some research, so I just wanted to create this issue to collect any info I can find.

StefanLobbenmeier avatar Aug 23 '19 07:08 StefanLobbenmeier

Platform specific:

Windows:

  • https://stackoverflow.com/questions/80650/how-do-i-register-a-custom-url-protocol-in-windows

StefanLobbenmeier avatar Aug 23 '19 07:08 StefanLobbenmeier

Linux: https://unix.stackexchange.com/a/497147

provokateurin avatar Aug 25 '19 11:08 provokateurin

Is possible to pass arguments from go app to dart main function?

ykmnkmi avatar Sep 07 '19 15:09 ykmnkmi

Is possible to pass arguments from go app to dart main function?

No and you should avoid putting business code above runAp because it delays the first frame.

For needs described above you can use the following system channel: https://api.flutter.dev/flutter/services/SystemChannels/navigation-constant.html

pushRoute, which is called with a single string argument when the operating system instructs the application to open a particular page.

You can make a go-flutter plugin that invoke this method https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin#call-dart-from-golang


Edit add simple example: Golang:

channel := plugin.NewMethodChannel(p.messenger, "flutter/navigation", plugin.JSONMethodCodec{})
channel.InvokeMethod("pushRoute", "/anotherRoute")

Dart:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/anotherRoute': (BuildContext context) =>
            Scaffold(body: Text("anotherRoute")),
        //other routes
      },
      home: Scaffold(body: Text("Home")),
    );
  }
}

pchampio avatar Sep 07 '19 17:09 pchampio

While we have the exper present: from my understanding Windows would spawn a new process every time an uni link is opened. I think this process then needs to start the actual app (if needed) and deliver the message. Is that understanding correct? Is there any standard way for inter process commutation in go?

StefanLobbenmeier avatar Sep 07 '19 17:09 StefanLobbenmeier

I think this process then needs to start the actual app (if needed) and deliver the message. Is that understanding correct?

I'm not an expert, but I does match my browser behavior, when I click on a link in the terminal either my browser is started with the link, or a new tab is opened.

Is there any standard way for inter process commutation in go?

again, not a big expert in that domain. There is https://github.com/ybbus/jsonrpc , without much search that what I would use^^

pchampio avatar Sep 07 '19 17:09 pchampio

I thinks this is a relevent kink: https://github.com/w3c/web-share/blob/master/docs/native.md

Its a good heads up for how we can implement sharing native.

joeblew99 avatar Sep 27 '19 14:09 joeblew99

any news on this? I'm willing to use move my app to go-flutter but lack the necessary knowledge to implement it myself. I implemented uni_links for macos on the FDE side if it helps somehow https://github.com/LittleLightForDestiny/littlelight/tree/desktop/desktop_plugins/uni_links_fde/macos

joaopmarquesini avatar May 26 '20 15:05 joaopmarquesini

You could re-use your MacOS implementation to create a CGO plugin, but that still requires the knowledge of go and go-flutter plugins.

provokateurin avatar May 26 '20 17:05 provokateurin

is there some knowledge base or a quickstart for plugins ? I was stuck while trying to create a minimal example to proper "test" my plugin. Also, is there already a repo for this plugin ? Or should I create a new one ?

joaopmarquesini avatar May 26 '20 18:05 joaopmarquesini

Here are the official go-flutter plugins: https://github.com/go-flutter-desktop/plugins For the repo you can just upload it to your own account.

provokateurin avatar May 26 '20 19:05 provokateurin

is there some knowledge base or a quickstart for plugins ? I was stuck while trying to create a minimal example to proper "test" my plugin.

Yes, sure, checkout our wiki: https://github.com/go-flutter-desktop/go-flutter/wiki/Plugin-info https://github.com/go-flutter-desktop/go-flutter/wiki/Create-a-hover-compatible-plugin https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin

pchampio avatar May 26 '20 19:05 pchampio

The problem on implementing it for linux is that only the .desktop file can specify a custom protocol handler

provokateurin avatar May 26 '20 19:05 provokateurin

So aside from the code part, there will also be need to change something during packaging? Perhaps this can be related to the hooks discussion?

GeertJohan avatar May 30 '20 08:05 GeertJohan

@GeertJohan probably. In macOS i need to change the Info.plist to add the url schemes. Also the way go-flutter runs its dev builds on mac doesn't support that (it isn't a packaged .app) so it could be a bit hard to test this kind of feature.

joaopmarquesini avatar May 30 '20 15:05 joaopmarquesini