-
public interface PushNotificationsClass responsible for handling FCM token and push messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePushNotifications.PushNotificationsEventpublic final classPushNotifications.EventsPush notification events
-
Method Summary
Modifier and Type Method Description abstract voidsubscribeTo(@NonNull() Collection<PushNotificationEvent> events)Allows to configure the push notifications that the SDK will subscribe to. abstract voidsubscribeTo(@NonNull() Context context, @NonNull() Collection<PushNotificationType> types)Allows to configure the push notifications that the SDK will subscribe to. abstract Set<PushNotificationEvent>getPushEvents()Returns push notification events that the SDK is subscribed to. abstract voidupdateFcmToken(@Nullable() String newFcmToken)This method should be called when a new token is generated by Firebase Cloud Messaging framework. abstract voidonNewMessage(@NonNull() RemoteMessage message)Should be called when a new remote message is received from the Firebase Cloud Messaging framework. abstract GliaPushMessagehandleOnMainActivityCreate(@Nullable() Bundle bundle)Should be called when the main application activity is created. abstract StringgetToken()Returns the currently active token. abstract <T> voidon(@NonNull() PushNotifications.PushNotificationsEvent<T> event, @NonNull() Consumer<T> listener)This method allows registration of event listeners for PushNotificationHandler. abstract <T> voidoff(@NonNull() PushNotifications.PushNotificationsEvent<T> event, @NonNull() Consumer<T> listener)This method allows the removal of event listeners from the PushNotificationHandler. -
-
Method Detail
-
subscribeTo
abstract void subscribeTo(@NonNull() Collection<PushNotificationEvent> events)
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:
- START
- MESSAGE
- TRANSFER
Ensure that you call this method as early as possible, preferably in the implementation ofthe android.app.Application, and definitely before starting an engagement.Calling this method after creating an engagement will only enable push notificationsfor subsequent engagements.
- Parameters:
events- - Collection of PushNotificationEvent to subscribe to
-
subscribeTo
abstract void subscribeTo(@NonNull() Context context, @NonNull() Collection<PushNotificationType> types)
Allows to configure the push notifications that the SDK will subscribe to.
The same as the subscribeTo but allows to set the push notifications type with default messages:
- glia_webhook_event_start
- glia_webhook_event_end
- glia_webhook_event_failed
- glia_webhook_event_message
- glia_webhook_event_transfer
- Parameters:
context- - Application context* @param types - Collection of PushNotificationType to subscribe to
-
getPushEvents
@NonNull() abstract Set<PushNotificationEvent> getPushEvents()
Returns push notification events that the SDK is subscribed to.
-
updateFcmToken
abstract void updateFcmToken(@Nullable() String newFcmToken)
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.
- Parameters:
newFcmToken- - New FCM token
-
onNewMessage
abstract void onNewMessage(@NonNull() RemoteMessage message)
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.
- Parameters:
message- - New FCM message
-
handleOnMainActivityCreate
@Nullable() abstract GliaPushMessage handleOnMainActivityCreate(@Nullable() Bundle bundle)
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 } }- Parameters:
bundle- - A mapping from String keys got from the main activity intent
-
on
abstract <T> void on(@NonNull() PushNotifications.PushNotificationsEvent<T> event, @NonNull() Consumer<T> listener)
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 typethe duplicate instances are discarded. They do not cause the listenerto be called twice and do not need to be removed with the removeEventListenermethod.
- Parameters:
event- - One of PushNotifications.Eventslistener- - Event listener to register
-
off
abstract <T> void off(@NonNull() PushNotifications.PushNotificationsEvent<T> event, @NonNull() Consumer<T> listener)
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
{@code off}with arguments which do not identify any currently registeredlistener has no effect.- Parameters:
event- - One of PushNotifications.Eventslistener- - Event listener to remove
-
-
-
-