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.
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.
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:
-
You can retrieve YOUR-SERVER-KEY using this link and selecting your desired project.
-
the
to
param can receive an user/device token.
Or you can use this project! \o/
- 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
-
Create a Firebase App
-
Clone this repo and create a Heroku app to it. 1.
git clone https://github.com/YSimplicity/notification-server.git
2.cd notification-server
3.heroku create
-
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'`
-
Deploy to heroku:
git push heroku master
-
Open the application URL. You can see it using the command:
heroku info