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

Register as URI scheme handler seems unreliable #154

Open
dmarmor opened this issue Nov 11, 2019 · 3 comments
Open

Register as URI scheme handler seems unreliable #154

dmarmor opened this issue Nov 11, 2019 · 3 comments

Comments

@dmarmor
Copy link

dmarmor commented Nov 11, 2019

I'm having some trouble trying to create an app that reliably passes along the URLs sent to it to the script. I'm a new Platypus user (love it so far!), so it's possible I'm doing something wrong, but if so, I can't figure out what. Here's my test setup:

Create a Platypus app called TestURLs (or whatever) with a Text Window interface, with Accept dropped items checked, and within those settings, I checked Register as URI scheme handler and added http and https as schemes. Use this as the script:

#!/bin/sh

for arg in "$@" ; do
    echo "arg: '$arg'"
done

In the terminal, issue the following command:

open -a TestURLs 'http://example.com' 'http://foobar.com'

Expected output:

​arg: 'http://example.com'
​arg: 'http://foobar.com'

Actual output varies. Most often, I get the following:

​arg: 'http://example.com'

and it loses the second URL. Sometimes I get no output at all, as if no arguments have been passed. Very rarely, I'll get the expected output of both URLs.

I've verified that if I send the same open command to an ordinary browser, both URLs get opened. For example, this command will open both URLs in Chrome:

open -a 'Google Chrome' 'http://example.com' 'http://foobar.com'

Any ideas what's going on here?

Thanks!

@dmarmor
Copy link
Author

dmarmor commented Nov 13, 2019

Hi again. I've done some more testing, and it appears the same behavior happens with dragged files. If I create an app with Accept dragged files checked, add some UTIs, and then drag 2 or more files of those types onto the app icon, it doesn't reliably pass them both along to the script's arguments.

Not sure if this is related, but there also seems to be a lengthy delay (3-4 seconds on my system, a 2016 MacBook Pro running Mojave) when launching a Platypus app this way (by dragging 1 or more files onto it). If I launch the app with no files, just double-clicking the app icon, it launches right away.

Hope this info is helpful in diagnosing the situation. Thank you!

@sveinbjornt
Copy link
Owner

This may be due to issues with macOS Launch Services, which is sometimes flaky about how it sends Apple Events. I am very busy with my real job at the moment but I will look into this as soon as possible.

@JayBrown
Copy link

JayBrown commented Aug 28, 2020

I have had success with this, but you need to manually add this kind of stuff to the ./Contents/Info.plist, not just ./Contents/Resources/AppSettings.plist

For example, in a Platypus app I'm currently working on, AppSettings.plist automatically gets the following:

<key>URISchemes</key>
<array>
	<string>uplc</string>
</array>

But you need extra stuff in the Info.plist:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLName</key>
		<string>Uploha Companion</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>uplc</string>
		</array>
	</dict>
</array>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants