デスクトップ PWA が Discourse と連携可能に!

Chrome がアプリランチャーを廃止した際、私はかなり落胆したことを覚えています。これは私が多くのサイトで利用していた機能でした。

幸いにも、Android 向けに行ってきた取り組みのおかげで、Discourse サイトでもこれを復活させることができます。

chrome://flags/#enable-desktop-pwas にアクセスし、これを有効にしてください。

また、リンクをキャプチャしてページへ送信する機能も必要であれば、「Desktop PWAs Link Capturing」を有効にし、追加のキャッシュ機能もオンにできます。

その後、Discourse サイトを訪れ、「デスクトップにインストール…」をクリックしてください。

これで、Discourse サイト専用のアプリケーションを起動できるようになりました。

@Falco@featheredtoast には、Android でのこの高度な機能のサポートを強く推してくださり、心より感謝申し上げます。そのおかげで、今やデスクトップでも利用可能になりました!

Mac 版 Chrome では用語が少し異なりますが、同様に機能します。

ただし、すべてのサイトで動作するわけではない点にご注意ください。これを実現するには、マニフェストファイルと、それをサポートするためのいくつかの高度な機能が必要です。

注意 これは、現在 Chrome 59 に固定されているため、単純な再パッケージ化においては Electron の強力な競合相手となることは間違いありません。

「いいね!」 43

There are a few things I want to clean up here that I will do in a theme component.

I think that in PWA desktop mode

  • The title should be a static “Discourse meta” cause the text duplication here is really annoying

  • Mini Profiler needs to find another spot cause it is really annoying there.

  • Big logo seems too much visually

  • A back button and refresh button would be nice

image

Luckily we have window.matchMedia('(display-mode: standalone)').matches to detect if we are in this mode so its simple to make a component to clean this stuff up.

「いいね!」 12

One thing I played with a bit is adding stats like:

  • Pageviews from PWA
  • Installations

To the Discourse Admin Dashboard and/or Google Analytics.

We can detect pageviews with that media query and installs with:

window.addEventListener('beforeinstallprompt', function(e) {
  // beforeinstallprompt Event fired

  // e.userChoice will return a Promise.
  // For more details read: https://developers.google.com/web/fundamentals/getting-started/primers/promises
  e.userChoice.then(function(choiceResult) {

    console.log(choiceResult.outcome);

    if(choiceResult.outcome == 'dismissed') {
      console.log('User cancelled home screen install');
    }
    else {
      console.log('User added to home screen');
    }
  });
});
「いいね!」 12

Super cool feature! :star_struck:

Is it planned to support this feature in hosted instances?

Oh it works on all discourse sites (hosted by us or self hosted), as long as you are on beta and up and have https enabled and enforced

Try it on random sites on the Internet and you will have less luck, Twitter does not work, mattermost does not and the list goes on

「いいね!」 5

Thanks! :slight_smile:

I meant on Discourse-hosted sites. I tried on Meta and the desktop app works perfect, but in our site https://brain.goodrebels.com/ the desktop app opens a new tab in Chrome. Perhaps we have to wait a bit for the latest update? or change some settings in /admin?

Hmm :thinking: we will investigate this cc @Falco @featheredtoast

I wonder if this is related to your site requiring login

「いいね!」 1

Worked for me on our require-logon site, FWIW


This is pretty interesting stuff. What are the advantages / disadvantages of using Discourse this way? I’d love to hear folks thoughts on this.

I know very little about this, so I’m just speaking based on what I saw in 2 min.

Wired: It’s really easy now to open the app now with Spotlight on Mac
Tired: I can only have one tab open

Wired: I can brag about how we have an app now (kinda)
Tired: I can only have one tab open

… you get the idea. :slight_smile:

「いいね!」 5

Yeah IMO this is kind of pointless. It’s like a web browser… but worse!

「いいね!」 5

Yeah I get that, I would find this more useful if there was only 1 discourse site I visited and if the icon on the desktop taskbar updated with notifications. But, I float between lots of sites so for me there is more limited use unless I had an app to bind all my sites, and even then lack of tabs is a big pain.

For chat (eg slack, mattermost) I find this very useful which is why I actually started this research. If my job was to moderate a single Discourse site I would also find this useful.

So yeah, I do not think this will be for everyone, but for some it may be handy, especially if there was some value add in the taskbar.

「いいね!」 13

I think it could work well, but it would take some additional work on the design of the UI. For instance, in Slack, you don’t need browser tabs because the navigation between channels is built into the app as a first class citizen. Maybe similar things could be done with theme components, where the UI could be designed within these new constraints.

That might work very well for many of our users who do fit into this mode for the most part:

「いいね!」 6

How does this relate to the instructions at

「いいね!」 3

Same old wine in a brand new bottle.

「いいね!」 3

Oh this topic was focusing on the ability to install Discourse in Desktops (which is no longer experimental).

The other one was mostly about the experimental Badging API. To use the Badging API you need to install to desktop, so this one here is a pre-requirement.

「いいね!」 3

First post looks quite wrong though? If it is not “experimental” where is that chrome menu item??

Yeah this is totally out of date, no point carrying this topic anymore.

Is a very big killer here usability wise. Now that his is official we should write a proper theme component to make PWA work as expected.

「いいね!」 4

There is one here:

Looks like it’s aimed at mobile iOS.

To get the menu entry in Chrome we must enable the service worker in desktop.

Yes but the tradeoff is that service worker adds a ton of support emails to our work… did you want to whitelist the service worker for Chrome and Firefox or something like that @sam in addition to Android?

I think we should whitelist Chrome now … hold off on whitelisting Firefox till this is done:

「いいね!」 4

Ok @falco can you do the needful on whitelist? We already whitelist Chrome / Android as I recall.

「いいね!」 4