com.vaadin.polymer.platinum.widget.PlatinumPushMessaging Maven / Gradle / Ivy
/*
* This code was generated with Vaadin Web Component GWT API Generator,
* from platinum-push-messaging project by The Polymer Authors
* that is licensed with http://polymer.github.io/LICENSE.txt license.
*/
package com.vaadin.polymer.platinum.widget;
import com.vaadin.polymer.platinum.*;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingClickEvent;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingClickEventHandler;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingErrorEvent;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingErrorEventHandler;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingPushEvent;
import com.vaadin.polymer.platinum.widget.event.PlatinumPushMessagingPushEventHandler;
import com.vaadin.polymer.*;
import com.vaadin.polymer.elemental.*;
import com.vaadin.polymer.PolymerWidget;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.core.client.JavaScriptObject;
/**
* <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.
*/
public class PlatinumPushMessaging extends PolymerWidget {
/**
* Default Constructor.
*/
public PlatinumPushMessaging() {
this("");
}
/**
* Constructor used by UIBinder to create widgets with content.
*/
public PlatinumPushMessaging(String html) {
super(PlatinumPushMessagingElement.TAG, PlatinumPushMessagingElement.SRC, html);
}
/**
* Gets a handle to the Polymer object's underlying DOM element.
*/
public PlatinumPushMessagingElement getPolymerElement() {
return (PlatinumPushMessagingElement) getElement();
}
/**
* If true then displaying the notification should not cause any
vibration or sound to be played.
*
* JavaScript Info:
* @property silent
* @type Boolean
*
*/
public boolean getSilent() {
return getPolymerElement().getSilent();
}
/**
* If true then displaying the notification should not cause any
vibration or sound to be played.
*
* JavaScript Info:
* @property silent
* @type Boolean
*
*/
public void setSilent(boolean value) {
getPolymerElement().setSilent(value);
}
/**
* The details of the current push subscription, if any.
*
* JavaScript Info:
* @property subscription
* @type PushSubscription
*
*/
public JavaScriptObject getSubscription() {
return getPolymerElement().getSubscription();
}
/**
* The details of the current push subscription, if any.
*
* JavaScript Info:
* @property subscription
* @type PushSubscription
*
*/
public void setSubscription(JavaScriptObject value) {
getPolymerElement().setSubscription(value);
}
/**
* When a notification is displayed that has the same tag
as an
existing notification, the existing one will be replaced. If this
flag is true then such a replacement will cause the user to be
alerted as though it were a new notification, by vibration or sound
as appropriate.
*
* JavaScript Info:
* @property renotify
* @type Boolean
*
*/
public boolean getRenotify() {
return getPolymerElement().getRenotify();
}
/**
* When a notification is displayed that has the same tag
as an
existing notification, the existing one will be replaced. If this
flag is true then such a replacement will cause the user to be
alerted as though it were a new notification, by vibration or sound
as appropriate.
*
* JavaScript Info:
* @property renotify
* @type Boolean
*
*/
public void setRenotify(boolean value) {
getPolymerElement().setRenotify(value);
}
/**
* If true then the notification should be sticky, meaning that it is
not directly dismissable.
*
* JavaScript Info:
* @property sticky
* @type Boolean
*
*/
public boolean getSticky() {
return getPolymerElement().getSticky();
}
/**
* If true then the notification should be sticky, meaning that it is
not directly dismissable.
*
* JavaScript Info:
* @property sticky
* @type Boolean
*
*/
public void setSticky(boolean value) {
getPolymerElement().setSticky(value);
}
/**
* Indicates the status of the element. If true, push messages will be
received.
*
* JavaScript Info:
* @property enabled
* @type Boolean
*
*/
public boolean getEnabled() {
return getPolymerElement().getEnabled();
}
/**
* Indicates the status of the element. If true, push messages will be
received.
*
* JavaScript Info:
* @property enabled
* @type Boolean
*
*/
public void setEnabled(boolean value) {
getPolymerElement().setEnabled(value);
}
/**
* Indicates whether the Push and Notification APIs are supported by
this browser.
*
* JavaScript Info:
* @property supported
* @type Boolean
*
*/
public boolean getSupported() {
return getPolymerElement().getSupported();
}
/**
* Indicates whether the Push and Notification APIs are supported by
this browser.
*
* JavaScript Info:
* @property supported
* @type Boolean
*
*/
public void setSupported(boolean value) {
getPolymerElement().setSupported(value);
}
/**
* If true then displaying the notification should not turn the device’s
screen on.
*
* JavaScript Info:
* @property noscreen
* @type Boolean
*
*/
public boolean getNoscreen() {
return getPolymerElement().getNoscreen();
}
/**
* If true then displaying the notification should not turn the device’s
screen on.
*
* JavaScript Info:
* @property noscreen
* @type Boolean
*
*/
public void setNoscreen(boolean value) {
getPolymerElement().setNoscreen(value);
}
/**
* The pattern of vibration that should be used by default when a
notification is displayed. See
*
* JavaScript Info:
* @property vibrate
* @type Array
*
*/
public JsArray getVibrate() {
return getPolymerElement().getVibrate();
}
/**
* The pattern of vibration that should be used by default when a
notification is displayed. See
*
* JavaScript Info:
* @property vibrate
* @type Array
*
*/
public void setVibrate(JsArray value) {
getPolymerElement().setVibrate(value);
}
/**
* The URL of a default icon for notifications.
*
* JavaScript Info:
* @property iconUrl
* @type string
*
*/
public String getIconUrl() {
return getPolymerElement().getIconUrl();
}
/**
* The URL of a default icon for notifications.
*
* JavaScript Info:
* @property iconUrl
* @type string
*
*/
public void setIconUrl(String value) {
getPolymerElement().setIconUrl(value);
}
/**
* The URL of a default sound file to play when a notification is shown.
*
* JavaScript Info:
* @property sound
* @type string
*
*/
public String getSound() {
return getPolymerElement().getSound();
}
/**
* The URL of a default sound file to play when a notification is shown.
*
* JavaScript Info:
* @property sound
* @type string
*
*/
public void setSound(String value) {
getPolymerElement().setSound(value);
}
/**
* The default language to assume for the title and body of the
notification. If set this must be a valid
BCP 47 language tag.
*
* JavaScript Info:
* @property lang
* @type string
*
*/
public String getLang() {
return getPolymerElement().getLang();
}
/**
* The default language to assume for the title and body of the
notification. If set this must be a valid
BCP 47 language tag.
*
* JavaScript Info:
* @property lang
* @type string
*
*/
public void setLang(String value) {
getPolymerElement().setLang(value);
}
/**
* The default notification message.
*
* JavaScript Info:
* @property message
* @type string
*
*/
public String getMessage() {
return getPolymerElement().getMessage();
}
/**
* The default notification message.
*
* JavaScript Info:
* @property message
* @type string
*
*/
public void setMessage(String value) {
getPolymerElement().setMessage(value);
}
/**
* A URL from which message information can be retrieved.
* When a push event happens that does not contain a message body this
URL will be fetched. The document will be parsed as JSON, and should
result in an object.
* The valid keys for the object are title
, message
, url
, icon
,
tag
, dir
, lang
, noscreen
, renotify
, silent
, sound
,
sticky
and vibrate
. For documentation of these values see the
attributes of the same names, except that these values override the
element attributes.
*
* JavaScript Info:
* @property messageUrl
* @type string
*
*/
public String getMessageUrl() {
return getPolymerElement().getMessageUrl();
}
/**
* A URL from which message information can be retrieved.
* When a push event happens that does not contain a message body this
URL will be fetched. The document will be parsed as JSON, and should
result in an object.
* The valid keys for the object are title
, message
, url
, icon
,
tag
, dir
, lang
, noscreen
, renotify
, silent
, sound
,
sticky
and vibrate
. For documentation of these values see the
attributes of the same names, except that these values override the
element attributes.
*
* JavaScript Info:
* @property messageUrl
* @type string
*
*/
public void setMessageUrl(String value) {
getPolymerElement().setMessageUrl(value);
}
/**
* A default tag for the notifications that will be generated by
this element. Notifications with the same tag will overwrite one
another, so that only one will be shown at once.
*
* JavaScript Info:
* @property tag
* @type string
*
*/
public String getTag() {
return getPolymerElement().getTag();
}
/**
* A default tag for the notifications that will be generated by
this element. Notifications with the same tag will overwrite one
another, so that only one will be shown at once.
*
* JavaScript Info:
* @property tag
* @type string
*
*/
public void setTag(String value) {
getPolymerElement().setTag(value);
}
/**
* The default URL to display when a notification is clicked.
*
* JavaScript Info:
* @property clickUrl
* @type String
*
*/
public String getClickUrl() {
return getPolymerElement().getClickUrl();
}
/**
* The default URL to display when a notification is clicked.
*
* JavaScript Info:
* @property clickUrl
* @type String
*
*/
public void setClickUrl(String value) {
getPolymerElement().setClickUrl(value);
}
/**
* The default notification title.
*
* JavaScript Info:
* @property title
* @type string
*
*/
public String getTitle() {
return getPolymerElement().getTitle();
}
/**
* The default notification title.
*
* JavaScript Info:
* @property title
* @type string
*
*/
public void setTitle(String value) {
getPolymerElement().setTitle(value);
}
/**
* The default text direction for the title and body of the
notification. Can be auto
, ltr
or rtl
.
*
* JavaScript Info:
* @property dir
* @type String
*
*/
public String getDir() {
return getPolymerElement().getDir();
}
/**
* The default text direction for the title and body of the
notification. Can be auto
, ltr
or rtl
.
*
* JavaScript Info:
* @property dir
* @type String
*
*/
public void setDir(String value) {
getPolymerElement().setDir(value);
}
/**
* The location of the service worker script required by the element.
The script is distributed alongside the main HTML import file for the
element, so the location can normally be determined automatically.
However, if you vulcanize your project you will need to include the
script in your built project manually and use this property to let
the element know how to load it.
*
* JavaScript Info:
* @property workerUrl
* @type String
*
*/
public String getWorkerUrl() {
return getPolymerElement().getWorkerUrl();
}
/**
* The location of the service worker script required by the element.
The script is distributed alongside the main HTML import file for the
element, so the location can normally be determined automatically.
However, if you vulcanize your project you will need to include the
script in your built project manually and use this property to let
the element know how to load it.
*
* JavaScript Info:
* @property workerUrl
* @type String
*
*/
public void setWorkerUrl(String value) {
getPolymerElement().setWorkerUrl(value);
}
// Needed in UIBinder
/**
* The details of the current push subscription, if any.
*
* JavaScript Info:
* @attribute subscription
*
*/
public void setSubscription(String value) {
Polymer.property(this.getPolymerElement(), "subscription", value);
}
// Needed in UIBinder
/**
* The pattern of vibration that should be used by default when a
notification is displayed. See
*
* JavaScript Info:
* @attribute vibrate
*
*/
public void setVibrate(String value) {
Polymer.property(this.getPolymerElement(), "vibrate", value);
}
/**
* Programmatically trigger a push message
*
* JavaScript Info:
* @method testPush
* @param {} message
*
*
*/
public void testPush(Object message) {
getPolymerElement().testPush(message);
}
/**
* Request push messaging to be enabled.
*
* JavaScript Info:
* @method enable
*
* @return {JavaScriptObject}
*/
public JavaScriptObject enable() {
return getPolymerElement().enable();
}
/**
* Request push messaging to be disabled.
*
* JavaScript Info:
* @method disable
*
* @return {JavaScriptObject}
*/
public JavaScriptObject disable() {
return getPolymerElement().disable();
}
/**
* Fired when a notification is clicked that had the current page as the
click URL.
*
* JavaScript Info:
* @event platinum-push-messaging-click
*/
public HandlerRegistration addPlatinumPushMessagingClickHandler(PlatinumPushMessagingClickEventHandler handler) {
return addDomHandler(handler, PlatinumPushMessagingClickEvent.TYPE);
}
/**
* Fired when an error occurs while enabling or disabling notifications
*
* JavaScript Info:
* @event platinum-push-messaging-error
*/
public HandlerRegistration addPlatinumPushMessagingErrorHandler(PlatinumPushMessagingErrorEventHandler handler) {
return addDomHandler(handler, PlatinumPushMessagingErrorEvent.TYPE);
}
/**
* Fired when a push message is received but no notification is shown.
This happens when the click URL is for this page and the page is
visible to the user on the screen.
*
* JavaScript Info:
* @event platinum-push-messaging-push
*/
public HandlerRegistration addPlatinumPushMessagingPushHandler(PlatinumPushMessagingPushEventHandler handler) {
return addDomHandler(handler, PlatinumPushMessagingPushEvent.TYPE);
}
}