public class PushClient
extends java.lang.Object
The PushClient handles the activation of push notifications for the Gluon Mobile application. Upon enabling it, the device will be registered at the correct push notifications service for the platform where the device is running on. For Android devices, this is Google Cloud Messaging (GCM) or Firebase Cloud Messaging (FCM); for iOS devices, this is the Apple Push Notification service (APNs).
Note: The PushClient uses the PushNotificationsService
for handling the platform specific
details of push notifications. It also depends on the DeviceService
to get a handle to the unique
identifier of the device for the Gluon Mobile application. Therefor, make sure that both the push-notifications
plugin and the device plugin have been enabled in your Gluon Mobile application build configuration:
jfxmobile { downConfig { plugins = 'device', 'push-notifications', ... } }
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyBooleanProperty |
enabled
This read-only property can be listened to, to detect if the current device is ready for
receiving push notifications or for subscribing to specific topics.
|
Constructor and Description |
---|
PushClient() |
Modifier and Type | Method and Description |
---|---|
void |
enable(java.lang.String gcmSenderId)
Enable push notifications for the Gluon Mobile application.
|
javafx.beans.property.ReadOnlyBooleanProperty |
enabledProperty()
This read-only property can be listened to, to detect if the current device is ready for
receiving push notifications or for subscribing to specific topics.
|
boolean |
isEnabled()
Check if the current device is correctly registered for receiving push notifications.
|
GluonObservableObject<TopicSubscription> |
subscribe(java.lang.String topic)
Subscribe the current device to the specified topic.
|
GluonObservableObject<java.lang.Void> |
unsubscribe(java.lang.String topic)
Unsubscribe the current device from the specified topic.
|
public javafx.beans.property.ReadOnlyBooleanProperty enabledProperty
isEnabled()
public void enable(java.lang.String gcmSenderId)
gcmSenderId
is
the Sender ID of your GCM or FCM application. iOS devices don't need any specific parameters because they will
be setup correctly when building the iOS ipa application bundle.gcmSenderId
- the Sender ID of the Google Cloud Messaging applicationpublic boolean isEnabled()
true
if the current device can receive push notifications, false
otherwise.public javafx.beans.property.ReadOnlyBooleanProperty enabledProperty()
isEnabled()
public GluonObservableObject<TopicSubscription> subscribe(java.lang.String topic) throws java.lang.IllegalStateException
enable(String)
before you can subscribe the device to a topic.topic
- The name of the topic to subscribe to.java.lang.IllegalStateException
- when the process of enabling push notifications for this device is
not yet fully completedpublic GluonObservableObject<java.lang.Void> unsubscribe(java.lang.String topic) throws java.lang.IllegalStateException
ConnectState.REMOVED
, unsubscribing from the topic was successful.topic
- The name of the topic to unsubscribe from.java.lang.IllegalStateException
- when the process of enabling push notifications for this device is
not yet fully completed