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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

Can you give me a pointer to documentation on this?

1 Mi Piace

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 Mi Piace

Molto curioso di sapere dove sia atterrato. Qualcuno è riuscito a incorporare Discourse nella propria app mobile tramite webview e sfruttare le notifiche?

Succede di tanto in tanto, manteniamo una manciata di app white-labeled per i clienti.

Sfortunatamente, il costo per intraprendere questa strada è enorme. Direi… prendi in considerazione questa strada se hai un budget di circa 20.000 USD all’anno per costruire/mantenere/debuggare.

2 Mi Piace

Sto lavorando a un progetto simile, ma il repository pubblico è obsoleto. Se desideri il mio aiuto, puoi assumermi.

@sam grazie per le parole di cautela, dato che sto per iniziare questo progetto.

Sono stato incoraggiato a vedere che il discourse hub sembra già fare questo - perché prevedi un costo così elevato? Immaginavo che fosse sufficiente far funzionare la webview e l’autenticazione, poi le notifiche sarebbero state un “nice to have”. Questa sarebbe una funzionalità fantastica da aggiungere alla mia app già esistente, il mio team ha già lavorato con le webview in passato.

C’è qualcosa che non sto prevedendo che causerà molto lavoro / aggiornamenti?

Storicamente ho visto quanto sforzo è stato dedicato alla banale web view discourse hub.

In superficie è “facile” ma poi devi preoccuparti di 1000 piccoli dettagli.

  • Riduci il pannello in basso
  • La curva sull’iPhone
  • Indicatori di caricamento
  • Aggiornamenti costanti della Webview
  • Controlli di sicurezza Apple e processo di approvazione dell’app
  • Debug complesso … cosa succede se qualcosa accade nella web view e non nel sito

Questo non è nemmeno un elenco esaustivo, sono sicuro che @pmusaraj e @kris.kotlarek possono tirarne fuori altri 20.

Le app sono molto difficili da realizzare e molto costose. Al giorno d’oggi, l’unica forte giustificazione per costruirne una è per iOS e non è un percorso facile.

5 Mi Piace

Ho originariamente posto questa domanda perché volevo mantenere gli utenti nella mia app, poiché penso che Apple e Google mi invieranno traffico gratuito.

Questo compito è più facile (o più difficile?) in una “Chrome Custom Tab” per Android?

È plausibile che offriate una libreria per iOS che avvolga una WKWebView e risolva questo problema per noi? (Sembra che abbiate già gestito il 90%+ del lavoro implementando Discourse Hub.)

1 Mi Piace

Direi che Android è difficile in modo “diverso”. Soprattutto perché il sistema operativo stesso non fornisce le primitive. È molto difficile giustificare lo sforzo lì quando la PWA è semplicemente così buona su Android.

Utilizziamo React Native e componenti per il wrapping di WKWebView. La complessità rimane, purtroppo. Anche gli aggiornamenti di React Native possono essere piuttosto dolorosi da affrontare in passato.

2 Mi Piace

@sam la mia giustificazione per intraprendere questo è davvero incentrata sulle notifiche push, e anche perché ho un’app esistente che consentirebbe facilmente ai miei membri di fare più cose nello stesso posto (studiare per il loro esame, chattare nella community, fare acquisti, ecc.).

Ma, sembra che potrei far loro aggiungere l’app della community come PWA, e potrebbero ricevere notifiche push e aggiornamenti? La PWA avrebbe notifiche push? Aggiornamento: ho trovato la risposta qui, sembra che non supporti le notifiche push.

Sto approfondendo l’opzione PWA - forse potrei persino aggiungere un link a “Partecipa alla discussione della community” nella mia app nativa esistente, e quello sarebbe il link corretto per scaricare la PWA?

Grazie!
James