npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polymer/platinum-push-messaging

v0.0.3

Published

Subscribes for push messaging and handles notifications.

Downloads

40

Readme

Build Status

Demo and API Docs

##<platinum-push-messaging>

<platinum-push-messaging> sets up a push messaging subscription and allows you to define what happens when a push message is received.

The element can be placed anywhere, but should only be used once in a page. If there are multiple occurrences, only one will be active.

Sample

For a complete sample that uses the element, see the Cat Push Notifications project.

Requirements

Push messaging is currently only available in Google Chrome, which requires you to configure Google Cloud Messaging. Chrome will check that your page links to a manifest file that contains a gcm_sender_id field. You can find full details of how to set all of this up in the HTML5 Rocks guide to push notifications.

Notification details

The data for how a notification should be displayed can come from one of three places.

Firstly, you can specify a URL from which to fetch the message data.

<platinum-push-messaging
  message-url="notification-data.json">
</platinum-push-messaging>

The second way is to send the message data in the body of the push message from your server. In this case you do not need to configure anything in your page:

<platinum-push-messaging></platinum-push-messaging>

Note that this method is not currently supported by any browser. It is, however, defined in the draft W3C specification and this element should use that data when it is implemented in the future.

If a message-url is provided then the message body will be ignored in favor of the first method.

Thirdly, you can manually define the attributes on the element:

<platinum-push-messaging
  title="Application updated"
  message="The application was updated in the background"
  icon-url="icon.png"
  click-url="notification.html">
</platinum-push-messaging>

These values will also be used as defaults if one of the other methods does not provide a value for that property.

Testing

If you have set up Google Cloud Messaging then you can send push messages to your browser by following the guide in the GCM documentation.

However, for quick client testing there are two options. You can use the testPush method, which allows you to simulate a push message that includes a payload.

Or, at a lower level, you can open up chrome://serviceworker-internals in Chrome and use the 'Push' button for the service worker corresponding to your app.