Embed Discourse in a native app?

Our company has native apps for iOS and Android. One of our goals is to bring people back to our apps frequently, and to spend a lot of time in our apps. (The app stores seem to prioritize apps that get a lot of usage.)

We have a pretty solid Discourse forum, but currently we just link out to the forum’s website from the app. iOS users who want to receive forum push notifications then have to download the Discourse app separately. (Android users can receive push notifications directly from the website, which is great, but in that case, they’re still using the website, and not our app.)

We’d like to make the Discourse forum a part of our existing iOS and Android apps, and especially to allow users to receive forum push notifications in our apps, without forcing people to download a separate app or to leave our app to use the forum. (I’m imagining that the implementation would be a web view, much like the Discourse iOS app.)

Is there a way to do something like this today? (I’m guessing not?)

「いいね!」 3

It is possible, but note:

  1. You will have cookie / login problems at the moment, particularly on iOS, due to the way embedded Safari is currently working in iOS 12 and beyond.

  2. You could certainly consume the Discourse API in the native apps to grab Discourse notifications.

A full in-app webview will be more complicated than simply linking out, and implies more developer support for the native apps.

@sam may have other thoughts.

「いいね!」 3

On Android the story is quite simple, spinning up a Chrome Custom Tab is super easy and it shares authentication with Chrome. Only big downside and reason our Android team members avoid using the Android app (and that we are considering killing the Android app) is cause opening a Chrome Tab is slow compared to PWA, so people prefer the PWA.

Being Android though you could possibly automate creating the PWA link and all that Jazz from your app which may be interesting.

On iOS the story is more complex due to Apple bugs.

We have the user API key system @pmusaraj will be working on improving per: Delegated authentication for Discourse Mobile app (which also includes adding documentation)

My recommendation here for you @dfabulich is to hold tight for a month or 2 while we redo our protocol and improve documentation.

「いいね!」 8

How would push notifications work in this story? Would I have to poll? (I’d rather do proper remote pushes.)

I read somewhere that Chrome 72 now support Trusted web activities , which means you can now distribute PWAs in the Google play store. If it works well I think you will have more reason to kill the Android app.

It’s a bit involved, since you need the validation key, paying the Google fee, etc. But it does work.

「いいね!」 1

Let me give one good reason not to: some people do not have a Google account and won’t have one. If the app would be distributed over F-Droid, it would be fine, but forcing people into Google is not a friendly move.

「いいね!」 2

As long as you ensure that it works with Firefox as well is can also solve

Discourse as an open source application should always prefer open source solutions

Checking back in on this! What’s the story here?

Delegated auth is in, and our new login flow is pretty rock solid on the app. The protocols are all open.

「いいね!」 2

Can you give me a pointer to documentation on this?

「いいね!」 1

This is our current spec:

It could certainly use an improvement or 2 so edits on it totally welcome.

Canonical implementation is open source and available at: GitHub - discourse/DiscourseMobile: Discourse Mobile

「いいね!」 3

これがどこに着地したのか非常に興味があります。誰かがwebviewを介してDiscourseをモバイルアプリに埋め込み、通知を活用することができましたか?

これは時々起こります。当社では、顧客向けにいくつかのホワイトラベルアプリを維持しています。

残念ながら、この方法を選択した場合のコストは膨大です。構築/維持/デバッグに年間2万米ドルの予算がある場合に、この方法を検討すべきだと思います。

「いいね!」 2

私はちょうどそのようなプロジェクトに取り組んでいましたが、はい、公開リポジトリは最新ではありません。お手伝いが必要な場合は、私を雇うことができます。

@sam ご注意いただきありがとうございます。まさにこのプロジェクトに着手するところでした。

ディスコースハブがすでにこれを行っているのを見て励まされました。なぜそれほど高いコストになると予想されるのですか?ウェブビューと認証を機能させ、通知はあれば嬉しい機能だと考えていました。これはすでに存在するアプリに素晴らしい機能を追加することになります。私のチームは以前にもウェブビューを扱ったことがあります。

多くの作業や更新を引き起こす、私が予期していない何かがありますか?

歴史的に、些細なWebビューのDiscourseハブにどれだけの労力が費やされてきたかを見てきました。

表面上は「簡単」に見えますが、その後には1000個の細かいディテールを心配する必要があります。

  • 下部のパネルを縮小する
  • iPhoneのカーブ
  • ローディングスピナー
  • Webビューの定数更新
  • Appleのセキュリティチェックとアプリ承認プロセス
  • 複雑なデバッグ…Webビューで何か発生し、サイトでは発生しない場合はどうなるか

これは網羅的なリストでさえありません。@pmusarajと@kris.kotlarekなら、さらに20項目挙げられるはずです。

アプリは正しく作り込むのが非常に難しく、非常に高価です。最近では、iOSのためにアプリを構築する強い理由は限られており、それも簡単な道のりではありません。

「いいね!」 5

この質問をしたのは、AppleやGoogleが私のアプリに無料のトラフィックを送ってくれると考えて、アプリのユーザーを維持したかったからです。

Androidの「Chromeカスタムタブ」では、このタスクは簡単になりますか(それとも難しくなりますか)?

WKWebViewをラップし、この問題を解決するiOS用ライブラリを提供することは可能でしょうか?(Discourse Hubを実装することで、すでに90%以上の作業を完了しているように思われます。)

「いいね!」 1

Androidは「異なる」難しさがあると言えます。特にOS自体がプリミティブを提供していないためです。PWAがAndroidで非常に優れていることを考えると、そこで労力を費やす正当な理由を見つけるのは非常に困難です。

私たちはReact NativeとWKWebViewをラップするためのコンポーネントを使用しています。残念ながら、複雑さは残ります。過去の経験から、React Nativeのアップデートも非常に厄介なものになり得ます。

「いいね!」 2

@sam 私がこれを始める正当な理由は、プッシュ通知のためであり、また、メンバーが同じ場所で複数のこと(試験勉強、コミュニティでのチャット、買い物など)を簡単に行える既存のアプリを持っているからです。

しかし、コミュニティアプリをPWAとして追加すれば、プッシュ通知やアップデートを受け取れるということでしょうか?PWAはプッシュ通知に対応していますか?追記:ここで回答を見つけました。プッシュ通知はサポートしていないようです。

PWAのオプションをさらに検討しています。既存のネイティブアプリに「コミュニティディスカッションに参加する」というリンクを追加することもできるかもしれません。それはPWAをダウンロードするための正しいリンクになりますか?

ありがとうございます!
ジェームス