"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_native_1 = require("react-native"); const Notification_1 = require("../DTO/Notification"); const NotificationActionResponse_1 = require("../interfaces/NotificationActionResponse"); class NativeEventsReceiver { constructor() { this.emitter = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.RNEventEmitter); } registerRemoteNotificationsRegistered(callback) { return this.emitter.addListener('remoteNotificationsRegistered', callback); } registerPushKitRegistered(callback) { return this.emitter.addListener('pushKitRegistered', callback); } registerRemoteNotificationReceived(callback) { return this.emitter.addListener('notificationReceived', (payload) => { callback(new Notification_1.Notification(payload)); }); } registerPushKitNotificationReceived(callback) { return this.emitter.addListener('pushKitNotificationReceived', callback); } registerRemoteNotificationOpened(callback) { return this.emitter.addListener('notificationOpened', (response, completion) => { const action = response.action ? new NotificationActionResponse_1.NotificationActionResponse(response.action) : undefined; callback(new Notification_1.Notification(response.notification), completion, action); }); } registerRemoteNotificationsRegistrationFailed(callback) { return this.emitter.addListener('remoteNotificationsRegistrationFailed', callback); } } exports.NativeEventsReceiver = NativeEventsReceiver;