I'm trying to figure it out how to use the polymer
message="The application was updated in the background"
platinum-push-messaging.html:437 Uncaught (in promise) TypeError: Cannot read property 'active' of undefined(…)
platinum-push-messaging element can be used to subscribe to push notifications using a
gcm_sender_id (GCM stands for Google Cloud Messaging).
If you're hosting your project on Firebase, you can find your
gcm_sender_id in the Console of your project > Project settings > Cloud Messaging.
Otherwise you can create a Project in the Google Developers Console and find the ID in the settings (Project Number).
Note: Due to the Requirements section in the Docs, push messaging is currently only available in Google Chrome.
But let's do a step by step demo (Works for MAC and UNIX - thats what the offical demo supports):
bower init(for the
bower install PolymerElements/paper-elements(elements used by the offical demo we will use)
bower install PolymerElements/platinum-push-messaging(you'll get the
bower_componentsfolder with everything needed for the demo)
platinum-push-messagingand the manifest.json (copy those files inside the folder you've just created)
index.html change the 6
rel="imports" to the corresponding element's
.html file inside
bower_components and the webcomponents include to
bower_components/webcomponentsjs/webcomponents-lite.min.js. The imports should look somewhat like this:
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="bower_components/paper-styles/paper-styles.html"> <link rel="import" href="bower_components/paper-styles/classes/global.html"> <link rel="import" href="bower_components/paper-item/paper-item.html"> <link rel="import" href="bower_components/paper-material/paper-material.html"> <link rel="import" href="bower_components/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="bower_components/platinum-push-messaging/platinum-push-messaging.html"> <link rel="manifest" href="manifest.json">
Go to the Google Developers Console and create a project.
gcm_sender_idto the copied number.
polymer serve --open
paper-toggle-buttonto enable push messaging (if the current subscription doesn't show anything, try to disable and reenable it)
curlcommand at the bottom of the
[YOUR_PUBLIC_API_KEY]with the API key you copied in step 11
Note: If you have problems finding stuff in the Google Developers Console, there is a great Tutorial.