Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Register in Launch Services as a viewer for the feed URL scheme #532

Closed
1 task done
einkoro opened this issue Oct 25, 2018 · 5 comments
Closed
1 task done

Register in Launch Services as a viewer for the feed URL scheme #532

einkoro opened this issue Oct 25, 2018 · 5 comments

Comments

@einkoro
Copy link

einkoro commented Oct 25, 2018

Prerequisites

Description

Winds currently does not appear to register with launch services as a viewer for the feed URL scheme. This currently prevents detecting Winds as an application supporting feeds or launching Winds to subscribe to a feed via NSWorkspace.

Steps to Reproduce

1a. Using SwiftDefaultApps prefpane navigate to the URL schemes tab and view the feed entries
OR
1b. From the terminal run the following:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump|grep "io.getstream.winds"
  1. Confirm winds is not there for feed

Expected behavior: Winds should be listed under feed

Actual behavior: Winds is not listed under feed

Reproduces how often: 100%

Versions

Winds 2.1.49 (via MAS)
MacOS 10.14 (18A391)

Additional Information

For reference I use the following to detect applications registered as feed viewers:

if let foundFeedHandlers = LSCopyAllHandlersForURLScheme("feed" as CFString)?.takeUnretainedValue() {
    let identifiers = foundFeedHandlers as! [String]
                
    for (index, id) in identifiers.enumerated() {
        if id == "com.apple.news" { continue } // Apple News dropped RSS support but still registers as a feed handler
        // … add to NSPopUp list
    }
}

And to launch applications registered as viewers via the URL scheme:

NSWorkspace.shared.open([url], withAppBundleIdentifier: feedHandler.appId,
    options: NSWorkspace.LaunchOptions.default,
    additionalEventParamDescriptor: nil,
    launchIdentifiers: nil)
@mahboubii
Copy link
Contributor

Thank you @einkoro, we'll put this on our backlog. Are you up for a coding challenge by chance? you can create a PR for this feature.

@einkoro
Copy link
Author

einkoro commented Oct 25, 2018

I'm not terribly familiar with electron but the documentation for registering URL schemes or extending Info.plist seems to be rather lacking and mostly dead wiki links from GH issues circa ~2016. Are you familiar at all with how extendInfo works in electron builder? About the only example I could find and virtually zero documentation was:

"build": {
  "extendInfo": {
    "CFBundleDisplayName": "My Awesome Name"
  }
}

With no mention if there is support for arrays or dictionaries or just passing in a plist like electron packager. Registering as a viewer for the feed URL scheme would require the following in Info.plist as a starting point:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Viewer</string>
		<key>CFBundleURLName</key>
		<string>io.getstream.winds</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>feed</string>
		</array>
	</dict>
</array>

@einkoro
Copy link
Author

einkoro commented Oct 25, 2018

After more digging if I'm following correctly this looks like it:

"build": {
    ...
    "protocols": [{
        "name": "io.getstream.winds",
        "role": "Viewer",
        "schemes": ["feed"]
    }]
}

Which would be in package.json around here: https://github.com/GetStream/Winds/blob/v2.3.3/app/package.json#L92

And then register an open-url event handler on the app object and handle it there. This seems pretty bare but appears to be the relevant bits:
https://electronjs.org/docs/api/app#event-will-finish-launching
https://electronjs.org/docs/api/app#event-open-url-macos

Probably something like:

app.on('will-finish-launching', () => {
    app.on('open-url', (event, url) => {
        event.preventDefault();
        ...
    });
});

In here: https://github.com/GetStream/Winds/blob/v2.3.3/app/public/electron.js#L191

Is the entire process to setup a dev env in the readme required just to edit and test a build of the mac app? Or can I get away with something more minimal and quicker?

@mahboubii
Copy link
Contributor

@einkoro you can set up the front-end application and point it to the winds production API, check the details on the README, Also for more detailed guide:
https://getstream.io/blog/winds-an-in-depth-tutorial-on-making-your-first-contribution-to-open-source-software/

@astrotars
Copy link
Contributor

Closing this out due to inactivity.

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

No branches or pull requests

3 participants