Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url scheme’s for Desktop #27

Open
gedw99 opened this issue Dec 31, 2022 · 22 comments
Open

Url scheme’s for Desktop #27

gedw99 opened this issue Dec 31, 2022 · 22 comments
Labels
enhancement New or improved feature for existent plugins

Comments

@gedw99
Copy link

gedw99 commented Dec 31, 2022

associate a file type with my gio app. So that when the user double clicks the file, it opens my gio app.

*Describe alternatives you've considered

none.

Additional context

seen it also work for web URLs on desktop and mobile … seems to be useful only when you also have a web app ?

https://stackoverflow.com/questions/67400225/handling-url-schemes-with-golang

example code for max and desktop

scraly/learning-go-by-examples#7

@gedw99 gedw99 added the enhancement New or improved feature for existent plugins label Dec 31, 2022
@gedw99 gedw99 changed the title Url scheme’s Url scheme’s for Desktop Dec 31, 2022
@gedw99
Copy link
Author

gedw99 commented Dec 31, 2022

Good explanations

https://developer.shotgridsoftware.com/af0c94ce/

@gedw99
Copy link
Author

gedw99 commented Dec 31, 2022

This is interesting aspect too

https://help.twixlmedia.com/hc/en-us/articles/115000739265-Using-custom-URL-Schemes-in-your-app

Using the url schemes to trigger things in the app or it seems to deep link into sone part of your app.

@inkeliz
Copy link
Contributor

inkeliz commented Dec 31, 2022

The feature you mentioned sounds nice. However, implementing it will likely require modifying the gio and gigio libraries, which cannot be done on a third-party library. Additionally, changes to the manifest or plist files may be necessary on iOS, Android and macOS. This means that initially, only basic support for Linux and Windows as a "plugin" may be possible.

However, since we are changing gio/gogio: it may be possible to handle "deep links" (which are URLs that support HTTP/HTTPS) and are similar in nature. It might be beneficial to implement both features (custom schemes and deep links) together.

@gedw99
Copy link
Author

gedw99 commented Jan 1, 2023

thanks @inkeliz for your expertise on this.

Yep needs work on he GIo side, so I raised an issue on the GIO list at https://todo.sr.ht/~eliasnaur/gio/470 to get the ball rolling.

I agree that Deep Links and File handlers ( if that's a good name for it ) have some crossover and it would be awesome to have both in GIO.

@gedw99
Copy link
Author

gedw99 commented Mar 23, 2023

Hey @inkeliz

i put together a darwin / ios sample of this. I was wondering if i can PR it on a branch ?

@gedw99
Copy link
Author

gedw99 commented Mar 23, 2023

also because there is some forking of gio should we establish that fork somewhere so that all code can use it ?

@inkeliz
Copy link
Contributor

inkeliz commented Mar 24, 2023

I think is fine to PR. That will also make easier to understand what kind of changes need to apply to Gio. 👍

@gedw99
Copy link
Author

gedw99 commented Jun 9, 2023

I think we can make it work for browsers too.

so when you put it into the browser it opens the local app, or the web site if the local app is not installed.

we need proper packaging for mac and windows for this to work too.
I git it for mac and am working it for windows msi.

@inkeliz
Copy link
Contributor

inkeliz commented Jul 6, 2023

That feature is a "pre-requisite" to implement "OAuth" (SignIn with {Google/Microsoft/Apple/Facebook/WeChat}). Exists two strategies that can be applied:

  • Localhost: On desktop create a localhost and then use redirect_url to https://localhost.
  • Custom Scheme: On mobile/desktop listen to specific scheme (your.app.something://) and use it as redirect_url.

In both cases PKCE is recommended for security.

Exists another strategy, which is the app listen the some custom server (non-Oauth) and execute the login as Web, then the server (non-OAuth server) notifies the user. But that requires more setup.


Since I'm working with Login with ______, then "Custom Scheme" will be added too. HOWEVER, that requires modify gogio, which leads again to "create a custom gogio".

@gedw99
Copy link
Author

gedw99 commented Jul 6, 2023

Hey @inkeliz

sorry i got stuck on the PR, and side tracked into other work.

The plan you have sounds awesome. If i can help with any of it please tell me, as i have some time at the moment.

Also you mentioned the GOGIO cmd needing work; I have to modify GOGIO anyway in order to get proper web manifest for Web push notifications.
I wrote it up here in our Push Notifications issue: #17 (comment)

Is this aligned with what we need for Url Scheme, deep link ? Basically a proper Web manifest and service worker right ?

@inkeliz
Copy link
Contributor

inkeliz commented Jul 6, 2023

I'm currently (kind of) designing the API. The major issues, currently is:

  • Registering on Windows is at runtime. But, on MacOS, iOS, Android it's at "compiled time" (on manifest ~gogio issue aside).
  • Windows don't have any specific "Event". So, if you click at mycustomproto://something, it will launch another instance of the app (say, open another "myapp.exe"). It's possible to fix that using IPC (unix socket and similar). But... That only works if only one instance of the app is open. Imagine that you have 2x myapp.exe opened (it opens without any scheme, just by double-clicking at the icon). What should happen when you click at myapp://do-somehting?! Both must get notified, one of them or must be impossible to have 2 instances of the same program?

The implementation for Android is done (but, requires to modify the manifest manually, on gogio soruce-code, currently). The implementation for MacOS is almost done, and iOS should work by luck, I didn't test. The Windows is the next, but have that "undefined behaviour" of multiple same app opened.

@gedw99
Copy link
Author

gedw99 commented Jul 7, 2023

@inkeliz

about windows opening the same app twice… I don’t have windows so can’t confirm but assuming your right then i aspect we let it happen ( if that how windows apps operate , or we use a config file to track open files of the file extension. If a 2nd attempts to open the same file we close and “ redirect “ to the already opened one.

This is just a brain storm idea as an alternative to ipc.

@gedw99
Copy link
Author

gedw99 commented Jul 7, 2023

I plan to put up a fork with lots of automation / ci for gio-plugins. So if you like it it can be PRed to your repo.

will let you know when that’s ready and you can have a look

@inkeliz
Copy link
Contributor

inkeliz commented Jul 7, 2023

df63942 that change adds support for Android/Windows. But, iOS/macOS needs to be upstream (Gio-core). So, I'm moving everything to Gio-core, but the Windows situation is quite tricky. Because even using IPC it needs to be done before Gio inits, otherwise it will show display some random UI and then close. Let's see what Elias will suggest.

You can PR anytime. :)

@inkeliz
Copy link
Contributor

inkeliz commented Jul 7, 2023

On Android, gogio must be patched:

diff --git a/gogio/androidbuild.go b/gogio/androidbuild.go
index cddba99..72d1d04 100644
--- a/gogio/androidbuild.go
+++ b/gogio/androidbuild.go
@@ -462,12 +462,24 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
 			android:theme="@style/Theme.GioApp"
 			android:configChanges="screenSize|screenLayout|smallestScreenSize|orientation|keyboardHidden"
 			android:windowSoftInputMode="adjustResize"
+			android:launchMode="singleTask"
 			android:exported="true">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
 				<category android:name="android.intent.category.LAUNCHER" />
 			</intent-filter>
 		</activity>
+		<activity android:name="com.inkeliz.deeplink.deeplink_android" 
+			android:label="com.inkeliz.deeplink.deeplink_android"
+			android:noHistory="true" 
+			android:launchMode="singleInstance">
+			<intent-filter>
+				<action android:name="android.intent.action.VIEW"></action>
+				<category android:name="android.intent.category.DEFAULT"></category>
+				<category android:name="android.intent.category.BROWSABLE"></category>
+				<data android:scheme="yourscheme"></data>
+			</intent-filter>
+		</activity>
 	</application>
 </manifest>`)
 	var manifestBuffer bytes.Buffer

@gedw99
Copy link
Author

gedw99 commented Jul 7, 2023

This looks really good. I will try out the the deep links code and PR anything i see that can help.

Also since we have to change some things in gogio, could you let me know where your fork of gioio repo is ?
So then i can use it when working on gio-plugins.

thanks

@inkeliz
Copy link
Contributor

inkeliz commented Jul 7, 2023

I didn't fork it, because <data android:scheme="yourscheme"></data> needs to change per-project. So, the best way is to create one -deeplink flag in gogio.

Since I'm moving it to Gio, you can track it here: gioui/gio-cmd#9 (and another PR is coming to gioui/gio)

@gedw99
Copy link
Author

gedw99 commented Jul 7, 2023

Gio

I didn't fork it, because <data android:scheme="yourscheme"></data> needs to change per-project. So, the best way is to create one -deeplink flag in gogio.

Since I'm moving it to Gio, you can track it here: gioui/gio-cmd#9 (and another PR is coming to gioui/gio)

@inkeliz

Ok make sense now - thanks for the update.

@inkeliz
Copy link
Contributor

inkeliz commented Jul 7, 2023

While testing iOS, I notice one "bug": https://stackoverflow.com/questions/42839716/ios-tel-and-mailto-links-only-work-with-target-blank

For some reason, <a href="yourapp://data"></a> will not work, but adding target="_blank" fixes the issue, but I don't know why.

@gedw99
Copy link
Author

gedw99 commented Jul 8, 2023

Curious what happens when the user just types it into safari omni bar and it tries to open the installed app that matches the url scheme …

@inkeliz
Copy link
Contributor

inkeliz commented Jul 8, 2023

If you type into Safari's address bar it works fine, just the HTML (without _blank) doesn't work.

I push this feature to Gio:
gioui/gio-cmd#9
gioui/gio#117

It's finished. But, maybe will take some couple of weeks to get it into Gio-core, if that get accepted.

@gedw99
Copy link
Author

gedw99 commented Jul 8, 2023

I will try it off the githash on your PR’s.

This is really cool @inkeliz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature for existent plugins
Projects
Status: In-Progress
Development

No branches or pull requests

2 participants