![]() |
Summary | Send Discourse push notifications to iOS or Android via your own app |
![]() |
Repository Link | GitHub - Sprachprofi/discourse-fcm-notifications: Send Discourse push notifications through FCM to any custom app |
![]() |
Install Guide | How to install plugins in Discourse |
Features
If you have an app that people can use to browse your Discourse forum, this plugin will let your forum send push notifications via the app. (If you don’t have an app yet but might want one, check out this minimalist solution.)
Convenient for users: when a user receives a push notification about a private message, tapping on that notification will open up your app and directly display that private message. This is a major advantage over using Discourse Pushover Notifications, where push notifications open the Pushover app and it’s not obvious how to get to the message. On the other hand, Pushover Notifications is good if you want push notifications without an app.
Universal: uses Google Firebase as a message layer, so all iOS and Android devices can receive these push notifications, as long as the country hasn’t banned Google.
Configuration
- Install and activate the plugin.
- Create a free Google Firebase project for your app. Add the Firebase project ID, token and the json (with OAuth data) to the plugin settings in Discourse.
- Adjust your app code:
-
Subscribe the active user to push notifications by sending the device token to YOUR_FORUM.com/fcm_notifications/automatic_subscribe?token=… . Be sure to call this every time the device token changes.
-
Unsubscribe the active user by calling YOUR_FORUM.com/fcm_notifications/automatic_subscribe?token=REMOVE
-
Push notifications will have the form:
'data': { "linked_obj_type" => 'link', "linked_obj_data" => <url to the post/message referenced in the message>, }, 'notification': { title: <something like "USERNAME sent you a private message in TOPIC">, body: <beginning of the message>, }
So you need to display the push notification with title/body and tapping on it should open the URL from linked_obj_data in an in-app browser. This is what you have to define in the app’s code.
Example implementation
You can get the code for a minimalist but fully functional app that works with this plugin here. (It’s the whitelabel version of a production app that we created, which needed this plugin.) If you only want an app that displays your forum, sends push notifications and remembers people’s login / last topic read, you just need to change the branding and submit it to the App Stores and you’re done. Otherwise, it could be a foundation.
Proceeds from this app will fund the maintenance and further development of the plugin.