UNPKG

react-native-firebase-compiled

Version:

A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto

199 lines (154 loc) 4.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _log = require("../../utils/log"); var _native = require("../../utils/native"); 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; } class IOSNotification { // alertAction | N/A // N/A | attachments // applicationIconBadgeNumber | badge // hasAction | N/A // alertLaunchImage | launchImageName // N/A | threadIdentifier constructor(notification, notifications, data) { _defineProperty(this, "_alertAction", void 0); _defineProperty(this, "_attachments", void 0); _defineProperty(this, "_badge", void 0); _defineProperty(this, "_category", void 0); _defineProperty(this, "_hasAction", void 0); _defineProperty(this, "_launchImage", void 0); _defineProperty(this, "_notification", void 0); _defineProperty(this, "_threadIdentifier", void 0); _defineProperty(this, "_complete", void 0); this._notification = notification; if (data) { this._alertAction = data.alertAction; this._attachments = data.attachments; this._badge = data.badge; this._category = data.category; this._hasAction = data.hasAction; this._launchImage = data.launchImage; this._threadIdentifier = data.threadIdentifier; } const complete = fetchResult => { const notificationId = notification.notificationId; (0, _log.getLogger)(notifications).debug(`Completion handler called for notificationId=${notificationId}`); (0, _native.getNativeModule)(notifications).complete(notificationId, fetchResult); }; if (notifications.ios.shouldAutoComplete) { complete(notifications.ios.backgroundFetchResult.noData); } else { this._complete = complete; } // Defaults this._attachments = this._attachments || []; } get alertAction() { return this._alertAction; } get attachments() { return this._attachments; } get badge() { return this._badge; } get category() { return this._category; } get hasAction() { return this._hasAction; } get launchImage() { return this._launchImage; } get threadIdentifier() { return this._threadIdentifier; } get complete() { return this._complete; } /** * * @param identifier * @param url * @param options * @returns {Notification} */ addAttachment(identifier, url, options) { this._attachments.push({ identifier, options, url }); return this._notification; } /** * * @param alertAction * @returns {Notification} */ setAlertAction(alertAction) { this._alertAction = alertAction; return this._notification; } /** * * @param badge * @returns {Notification} */ setBadge(badge) { this._badge = badge; return this._notification; } /** * * @param category * @returns {Notification} */ setCategory(category) { this._category = category; return this._notification; } /** * * @param hasAction * @returns {Notification} */ setHasAction(hasAction) { this._hasAction = hasAction; return this._notification; } /** * * @param launchImage * @returns {Notification} */ setLaunchImage(launchImage) { this._launchImage = launchImage; return this._notification; } /** * * @param threadIdentifier * @returns {Notification} */ setThreadIdentifier(threadIdentifier) { this._threadIdentifier = threadIdentifier; return this._notification; } build() { // TODO: Validation of required fields return { alertAction: this._alertAction, attachments: this._attachments, badge: this._badge, category: this._category, hasAction: this._hasAction, launchImage: this._launchImage, threadIdentifier: this._threadIdentifier }; } } exports.default = IOSNotification;