UNPKG

react-native-notificare-push-ui

Version:
72 lines (56 loc) 2.69 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { NativeEventEmitter, NativeModules, Platform } from 'react-native'; const LINKING_ERROR = `The package 'react-native-notificare-push-ui' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n'; const NativeModule = NativeModules.NotificarePushUIModule ? NativeModules.NotificarePushUIModule : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); export class NotificarePushUI { // // Methods // static async presentNotification(notification) { await NativeModule.presentNotification(notification); } static async presentAction(notification, action) { await NativeModule.presentAction(notification, action); } // // Events // static onNotificationWillPresent(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.notification_will_present', callback); } static onNotificationPresented(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.notification_presented', callback); } static onNotificationFinishedPresenting(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.notification_finished_presenting', callback); } static onNotificationFailedToPresent(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.notification_failed_to_present', callback); } static onNotificationUrlClicked(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.notification_url_clicked', callback); } static onActionWillExecute(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.action_will_execute', callback); } static onActionExecuted(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.action_executed', callback); } static onActionNotExecuted(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.action_not_executed', callback); } static onActionFailedToExecute(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.action_failed_to_execute', callback); } static onCustomActionReceived(callback) { return this.eventEmitter.addListener('re.notifica.push.ui.custom_action_received', callback); } } _defineProperty(NotificarePushUI, "eventEmitter", new NativeEventEmitter(NativeModule)); //# sourceMappingURL=notificare-push-ui.js.map