Search in sources :

Example 1 with ChatEventType

use of com.azure.android.communication.chat.models.ChatEventType in project azure-sdk-for-android by Azure.

the class PushNotificationClient method handlePushNotification.

/**
 * Handle incoming push notification.
 * Invoke corresponding chat event handle if registered.
 * @param pushNotification Incoming push notification payload from the FCM SDK.
 *
 * @return True if there's handler(s) for incoming push notification; otherwise, false.
 */
public boolean handlePushNotification(ChatPushNotification pushNotification) {
    this.logger.info(" Receive handle push notification request.");
    ChatEventType chatEventType = this.parsePushNotificationEventType(pushNotification);
    this.logger.info(" " + chatEventType + " received.");
    if (this.pushNotificationListeners.containsKey(chatEventType)) {
        ChatEvent event = this.parsePushNotificationEvent(chatEventType, pushNotification);
        Set<Consumer<ChatEvent>> callbacks = this.pushNotificationListeners.get(chatEventType);
        for (Consumer<ChatEvent> callback : callbacks) {
            this.logger.info(" invoke callback " + callback + " for " + chatEventType);
            callback.accept(event);
        }
        return true;
    }
    return false;
}
Also used : Consumer(java9.util.function.Consumer) ChatEvent(com.azure.android.communication.chat.models.ChatEvent) ChatEventType(com.azure.android.communication.chat.models.ChatEventType)

Aggregations

ChatEvent (com.azure.android.communication.chat.models.ChatEvent)1 ChatEventType (com.azure.android.communication.chat.models.ChatEventType)1 Consumer (java9.util.function.Consumer)1