GithubHelp home page GithubHelp logo

invokemedia / vue-push-notification-example Goto Github PK

View Code? Open in Web Editor NEW
124.0 11.0 39.0 410 KB

An example repo for using browser push notifications with Vue.js and Firebase

License: MIT License

HTML 9.15% JavaScript 90.85%
firebase vue push-notifications push message

vue-push-notification-example's Introduction

Vue.js Push Notification Example

An example repo for using browser push notifications with Vue.js. We also use Firebase in this example as it can be used to send the notifications for free and with zero-configuration.

Frontend

Signing up in the form

signup demo

Showing a notification

notification demo

Requirements

  • Firebase account
  • Server running on the project root

Installation

  • Create a manifest.json following this structure
  • Create a firebase.json with the Firebase Web credentials
  • Make sure the Firebase table can be written to

Sending Notifications

Using Firebase Function

Be sure to change into the firebase-function/functions/ directory and run npm install.

Initial Setup

Copy the "Server key" from Project Settings > Cloud Messaging page. Store it as follows in a file named firebase-function/functions/google-push-key.json:

{
  "key": "THAT SERVER KEY FROM CLOUD MESSAGING"
}

Running the app locally

In order to get the app to work locally, Firebase needs to be authenticated using a JSON file with the correct application keys and secrets.

Download the Firebase Admin SDK file from the Project Settings > Service Accounts page. Rename it and place it in firebase-function/firebase-adminsdk.json. If no Firebase auth file is found, the app will not be able to run locally. You don't need the auth file when running in the Firebase cloud function environment.

You can run the app locally by just changing to the firebase-function/functions/ folder and using npm run start.

Deploy

Read the Firebase Functions docs on getting started.

Single User

You can send the notification using cURL:

curl --header "Authorization: key=<YOUR_FIREBASE_SERVER_KEY>" --header
"Content-Type: application/json" https://android.googleapis.com/gcm/send -d
"{\"registration_ids\":[\"<SUBSCRIBER_ID>\"]}"

To get a <SUBSCRIBER_ID> for your user, you can pull it out of the endpoint that is saved to the Firebase database when the user is stored.

For example your endpoint may look like this: "https://android.googleapis.com/gcm/send/<SUBSCRIBER_ID>" and you can take that crazy ID out and place it in the registration_ids array.

vue-push-notification-example's People

Contributors

james2doyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-push-notification-example's Issues

firebase.json example

Hi, please can you give an example of the firebase.json that you mentioned?
or where can I find an example?

Thanks

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.