Giter VIP home page Giter VIP logo

notification-server's Introduction

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. 1. git clone https://github.com/YSimplicity/notification-server.git 2. cd notification-server 3. heroku create

  3. 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

notification-server's People

Contributors

serradura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

doplgangr wlads

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.