An application to send Push Notification campaigns via Firebase Cloud Messaging
Ruby HTML CSS JavaScript CoffeeScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bin
config
db
doc/images
lib
log
public
test
tmp
vendor/assets
.gitignore
.rubocop.yml
.ruby-version Update Ruby, gems and add news development dependencies. Apr 29, 2017
Gemfile
Gemfile.lock
LICENSE
Procfile
README.md
Rakefile
config.ru
sample.env

README.md

About

This application was made to work with Firebase Cloud Messaging for Web.

The main idea is: Store your app users, subscribe them to your topics, create Push Notification campaigns and send messages to your desired audience.

Another critical reason to create this project is: Unfortunately the Firebase Notifications doesn't work with the Web platform.

What do you need to store an user?

Send a post to the /api/users resource. e.g:

curl -X POST -H 'Content-Type: application/json' -d '{
  "user": {
    "uid": "SOME-USER-UID",
    "email": "[email protected]",
    "token": "SOME-USER-FCM-TOKEN"
  }
}' http://localhost:3000/api/users

NOTE: Here, you can see a JS implementation.

What do you need to send a Push Notification/Message?

Making a curl call like this:

curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type: application/json" -d '{
  "notification": {
    "title": "Hello",
    "body": "World",
    "icon": "/an-image-from-your-app-receiver.png",
    "click_action": "https://your-app-receiver-host.com"
    },
    "to": "/topics/your-topic"
}' "https://fcm.googleapis.com/fcm/send"

Notes:

  1. You can retrieve YOUR-SERVER-KEY using this link and selecting your desired project.

  2. the toparam can receive an user/device token.

Or you can use this project! \o/

image

Configuration:

  • Ruby version: 2.3.2
  • Rails version: 5.0.0.1
  # Create a Firebase app
  https://firebase.google.com/docs/web/setup

  # Create a `.env` file and set up your firebase app configurations.
  cp sample.env .env

Deployment instructions (Heroku):

  1. Create a Firebase App

  2. Clone this repo and create a Heroku app to it.

  3. git clone https://github.com/YSimplicity/notification-server.git

  4. cd notification-server

  5. heroku create

  6. Set all environment variables.

`heroku config:set APPLICATION_CORS_ORIGINS='*' APPLICATION_AUTH_NAME='admin' APPLICATION_AUTH_PASSWORD='admin' WEB_APP_RECEIVER_HOST='http://localhost:5000' WEB_APP_RECEIVER_DEFAULT_ICON_PATH='/images/ysimplicity-logo-white-bg-black.png'  FIREBASE_SERVER_KEY='YOU-FIREBASE-SERVER-KEY' DEFAULT_TOPIC_SUBSCRIPTION='your-brand_or_general-topic'`
  1. Deploy to heroku: git push heroku master

  2. Open the application URL. You can see it using the command: heroku info