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

Fix: Add "rocketchat://" scheme for macOS application #2446

Merged

Conversation

khramtsoff
Copy link
Contributor

Issue

Rocket.chat installed from Mac App Store(MAS) not handling rocketchat:// URL scheme

To Reproduce:

  1. On macOS that never ran Rocket.chat install app from MAS, launch it
  2. Open rocketchat://invite in Safari/Chrome

Expected result: Rocket.chat opens
Actual result: Error

Why is this happening

MacOS applications are required to specify handled protocols inside Info.plist

Electron:

When you package your app you'll need to make sure the macOS Info.plist and the Linux .desktop files for the app are updated to include the new protocol handler. Some of the Electron tools for bundling and distributing apps handle this for you.

Official documentation:

But it works on my machine!

  • The reason why it works on your machine is that you once ran NON-AppStore version, which is not sandboxed. Runtime scheme registration by electron (app.setAsDefaultProtocolClient) works only outside of the sandbox (it uses deprecated LSSetDefaultHandlerForURLScheme). Scheme is registered even if you delete the app. You can check this by deleting app and running:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | grep "rocketchat"

On machine that never launched Rocket.chat before and just installed it from MAS app.setAsDefaultProtocolClient('rocketchat') does not work without URL schemes in Info.plist (issue electron/electron#21319)

Another point - check Slack.app/Contents/Info.plist, it contains supported URI schemes (search for CFBundleURLSchemes) (Rocket.chat does not)

How to fix

According to electron-builder's documentation we can use protocols:
https://www.electron.build/configuration/configuration.html#PlatformSpecificBuildOptions-protocols

protocols Array<Protocol> | Protocol - The URL protocol schemes.
name String - The name. e.g. IRC server URL.
schemes Array<String> - The schemes. e.g. ["irc", "ircs"].
role = Editor “Editor” | “Viewer” | “Shell” | “None” - macOS-only The app’s role with respect to the type.

As a result Info.plist will contain new entry:
rocket_url

@CLAassistant
Copy link

CLAassistant commented Jul 13, 2022

CLA assistant check
All committers have signed the CLA.

@jeanfbrito
Copy link
Collaborator

Awesome contribution! Thank you!

@jeanfbrito jeanfbrito merged commit 1053b24 into RocketChat:master Aug 8, 2022
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

Successfully merging this pull request may close these issues.

3 participants