| com.glia.androidsdk.fcm.PushNotifications |
Class responsible for handling FCM token and push messages.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| class | PushNotifications.Events | Push notification events | |||||||||
| interface | PushNotifications.PushNotificationsEvent<T> | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| abstract Set<PushNotificationEvent> |
getPushEvents()
Returns push notification events that the SDK is subscribed to.
| ||||||||||
| abstract String |
getToken()
Returns the currently active token.
| ||||||||||
| abstract GliaPushMessage |
handleOnMainActivityCreate(Bundle bundle)
Should be called when the main application activity is created.
| ||||||||||
| abstract <T> void |
off(PushNotificationsEvent<T> event, Consumer<T> listener)
This method allows the removal of event listeners from the PushNotificationHandler.
| ||||||||||
| abstract <T> void |
on(PushNotificationsEvent<T> event, Consumer<T> listener)
This method allows registration of event listeners for PushNotificationHandler.
| ||||||||||
| abstract void |
onNewMessage(RemoteMessage message)
Should be called when a new remote message is received from the Firebase Cloud Messaging framework.
| ||||||||||
| abstract void |
subscribeTo(Context context, Collection<PushNotificationType> types)
Allows to configure the push notifications that the SDK will subscribe to.
| ||||||||||
| abstract void |
subscribeTo(Collection<PushNotificationEvent> events)
Allows to configure the push notifications that the SDK will subscribe to.
| ||||||||||
| abstract void |
updateFcmToken(String newFcmToken)
This method should be called when a new token is generated by Firebase Cloud Messaging framework.
| ||||||||||
Returns push notification events that the SDK is subscribed to.
PushNotificationEvent
Returns the currently active token.
Should be called when the main application activity is created.
Usage example:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
GliaPushMessage push = Glia.getPushNotifications()
.handleOnMainActivityCreate(getIntent().getExtras());
if (push != null && push.getType() == GliaPushMessage.PushType.CHAT_MESSAGE) {
// handle the opening of the push notification
}
}
| bundle | - A mapping from String keys got from the main activity intent |
|---|
GliaPushMessage if the main activity is opened by clicking on
the notification or null if not.
This method allows the removal of event listeners from the PushNotificationHandler.
If an event listener is removed while the PushNotificationHandler is processing an event, it is not triggered with the current event.
Calling off with arguments which do not identify any currently registered
listener has no effect.
| event | - One of PushNotifications.Events |
|---|---|
| listener | - Event listener to remove |
This method allows registration of event listeners for PushNotificationHandler.
If a listener is added while the PushNotificationHandler is processing an event, it is not triggered with the current event.
If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the removeEventListener method.
| event | - One of PushNotifications.Events |
|---|---|
| listener | - Event listener to register |
Should be called when a new remote message is received from the Firebase Cloud Messaging framework.
You should use this method only if you have your own FCM service.
| message | - New FCM message |
|---|
Allows to configure the push notifications that the SDK will subscribe to.
The same as the subscribeTo(Collection)
but allows to set the push notifications type with default messages:
| context | - Application context
* @param types - Collection of PushNotificationType to subscribe to
|
|---|
Allows to configure the push notifications that the SDK will subscribe to.
If the notifications aren't configured, by default the SDK subscribes to the following push notifications:
Ensure that you call this method as early as possible, preferably in the implementation of the android.app.Application, and definitely before starting an engagement. Calling this method after creating an engagement will only enable push notifications for subsequent engagements.
| events | - Collection of PushNotificationEvent to subscribe to
|
|---|
This method should be called when a new token is generated by Firebase Cloud Messaging framework.
You should use this method only if you have your own FCM service.
| newFcmToken | - New FCM token |
|---|