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 curtidas

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 curtidas

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 curtidas

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 curtida

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 curtidas

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 curtidas

Can you give me a pointer to documentation on this?

1 curtida

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 curtidas

Muito curioso para saber onde isso foi parar. Alguém conseguiu incorporar o Discourse em seu aplicativo móvel via webview e aproveitar as notificações?

Isso acontece de tempos em tempos, mantemos um punhado de aplicativos de marca branca para clientes.

Infelizmente, o custo de seguir esse caminho é enorme. Eu diria… considere seguir esse caminho se você tiver um orçamento anual de cerca de US$ 20.000 para construir/manter/depurar.

2 curtidas

Eu acabei de trabalhar em um projeto assim, mas sim, o repositório público está desatualizado. Se você quiser que eu ajude, pode me contratar.

@sam obrigado pelas palavras de cautela, pois estou prestes a embarcar neste projeto.

Fiquei encorajado ao ver que o discourse hub já parece fazer isso - por que você antecipa um custo tão alto? Eu imaginava que você só precisava fazer o webview e a autenticação funcionarem, então as notificações seriam um bônus. Este seria um recurso incrível para adicionar ao meu aplicativo já existente, minha equipe já trabalhou com webviews anteriormente.

Há algo que não estou antecipando que causará muito trabalho/atualizações?

Historicamente, vi o esforço que foi dedicado à trivial interface web do Discourse Hub.

Na superfície, é “fácil”, mas então você precisa se preocupar com 1000 pequenos detalhes.

  • Painel de encolhimento na parte inferior
  • A curva no iPhone
  • Spinners de carregamento
  • Atualizações constantes da webview
  • Verificações de segurança da Apple e processo de aprovação do aplicativo
  • Depuração complexa … e se algo acontecer na webview e não no site

Esta nem é uma lista exaustiva, tenho certeza de que @pmusaraj e @kris.kotlarek podem adicionar mais 20 itens.

Aplicativos são muito difíceis de acertar e muito caros. Hoje em dia, a única justificativa forte para construir um é para iOS e não é uma jornada fácil.

5 curtidas

Eu fiz essa pergunta originalmente porque queria reter usuários no meu aplicativo, pois acho que Apple e Google me enviarão tráfego gratuito.

Essa tarefa é mais fácil (ou mais difícil?) em uma “Chrome Custom Tab” para Android?

É plausível que vocês ofereçam uma biblioteca para iOS que envolva um WKWebView e resolva esse problema para nós? (Parece que vocês já lidaram com mais de 90% do trabalho implementando o Discourse Hub.)

1 curtida

Eu diria que o Android é “diferentemente” difícil. Especialmente porque o próprio sistema operacional não fornece os primitivos. É muito difícil justificar o esforço lá quando o PWA é simplesmente tão bom no Android.

Usamos React Native e componentes para encapsular o WKWebView. A complexidade permanece, infelizmente. As atualizações do React Native também podem ser bastante dolorosas de resolver historicamente.

2 curtidas

@sam minha justificativa para embarcar nisso é realmente em torno de notificações push e também porque tenho um aplicativo existente que permitiria facilmente aos meus membros fazer várias coisas no mesmo lugar (estudar para o exame, conversar na comunidade, comprar, etc.).

Mas parece que eu poderia fazer com que eles adicionassem o aplicativo da comunidade como um PWA, e eles poderiam receber notificações push e atualizações? O PWA teria notificações push? Atualização: encontrei a resposta aqui, parece que não suporta notificações push.

Estou investigando a opção PWA mais a fundo - talvez eu possa até adicionar um link para “Participar da discussão da comunidade” no meu aplicativo nativo existente, e esse seria o link correto para baixar o PWA?

Obrigado!
James