Following up on the discussion here, I have successfully set up a fork of the official Discourse app that can send push notifications via the OneSignal API.
There are two parts to this:
discourse-onesignal - a Discourse plugin that sends Push Notifications to OneSignal's REST API
and a DiscourseMobile fork - which is used to build the app
For now the app works only on iOS. Android version should be coming soon.
Instructions for setting this up for your own app:
- Register an App ID on the Apple portal (developer.apple.com)
- Open an account with OneSignal (free), create a new app, and generate certificates for iOS using the OneSignal provisionator (or generate certs on the Apple portal)
- Create the provisioning profiles on the Apple portal. You need a distribution profile for pushing to TestFlight and the App Store, and likely an ad-hoc profile for testing quickly on your device. (Note that you may also need a development certificate for testing the app on your device. Step 2 above creates only the production certificate.)
- Create an iCloud container and associate it with your App ID.
Discourse-Mobile locally, and get started setting up your environment and building the app using the steps described in the repo: https://github.com/pmusaraj/DiscourseMobile
global.js to set your app's variables: site domain, app name, OneSignal App ID and URL scheme (optional).
- Make sure you have Node installed, and run
node setup.ios.js from your command line. This will use the variables set in
global.js to update the app files.
- Load XCode, open
Discourse.xcodeproj and update your Bundle identifier and your Provisioning profiles.
- Now, jump over to your Discourse instance and make sure you are running your site on https. The OneSignal plugin does not support http at this point.
- Add the
discourse-onesignal plugin to your Discourse instance and configure it: enable notifications, add your OneSignal App ID and the OneSignal REST API key.
- You should now be ready to build and test the app in Xcode our using
react-native run-ios on the command line. (To test push notifications, you need to set up your app on your phone, either via ad-hoc or through TestFlight.)
If anybody is interested in testing this using a demo Discourse instance, I have a demo site set up at white.saloncms.ca. Please respond below with your email address if you are interested in testing. The demo is offline for now.
- the home screen of the app needs to be improved a little bit. the official Discourse app accepts connections to multiple sites. The whitelisted app is geared towards a single site. So that home screen is a little raw and empty. I'm working on a better UI for it. (PRs and suggestions welcome.)