Notifications.js 2.69 KB
Newer Older
冷佳娟's avatar
冷佳娟 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const NativeCommandsSender_1 = require("./adapters/NativeCommandsSender");
const NativeEventsReceiver_1 = require("./adapters/NativeEventsReceiver");
const Commands_1 = require("./commands/Commands");
const EventsRegistry_1 = require("./events/EventsRegistry");
const EventsRegistryIOS_1 = require("./events/EventsRegistryIOS");
const UniqueIdProvider_1 = require("./adapters/UniqueIdProvider");
const CompletionCallbackWrapper_1 = require("./adapters/CompletionCallbackWrapper");
const NotificationsIOS_1 = require("./NotificationsIOS");
const NotificationsAndroid_1 = require("./NotificationsAndroid");
class NotificationsRoot {
    constructor() {
        this.nativeEventsReceiver = new NativeEventsReceiver_1.NativeEventsReceiver();
        this.nativeCommandsSender = new NativeCommandsSender_1.NativeCommandsSender();
        this.completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(this.nativeCommandsSender);
        this.uniqueIdProvider = new UniqueIdProvider_1.UniqueIdProvider();
        this.commands = new Commands_1.Commands(this.nativeCommandsSender, this.uniqueIdProvider);
        this.eventsRegistry = new EventsRegistry_1.EventsRegistry(this.nativeEventsReceiver, this.completionCallbackWrapper);
        this.eventsRegistryIOS = new EventsRegistryIOS_1.EventsRegistryIOS(this.nativeEventsReceiver);
        this.ios = new NotificationsIOS_1.NotificationsIOS(this.commands, this.eventsRegistryIOS);
        this.android = new NotificationsAndroid_1.NotificationsAndroid(this.commands);
    }
    /**
     * registerRemoteNotifications
     */
    registerRemoteNotifications() {
        this.ios.registerRemoteNotifications();
        this.android.registerRemoteNotifications();
    }
    /**
     * postLocalNotification
     */
    postLocalNotification(notification, id) {
        return this.commands.postLocalNotification(notification, id);
    }
    /**
     * getInitialNotification
     */
    getInitialNotification() {
        return this.commands.getInitialNotification();
    }
    /**
     * setCategories
     */
    setCategories(categories) {
        this.commands.setCategories(categories);
    }
    /**
     * cancelLocalNotification
    */
    cancelLocalNotification(notificationId) {
        return this.commands.cancelLocalNotification(notificationId);
    }
    /**
     * isRegisteredForRemoteNotifications
     */
    isRegisteredForRemoteNotifications() {
        return this.commands.isRegisteredForRemoteNotifications();
    }
    /**
     * Obtain the events registry instance
     */
    events() {
        return this.eventsRegistry;
    }
}
exports.NotificationsRoot = NotificationsRoot;