@ua/react-native-airship
Version:
Airship plugin for React Native apps.
109 lines (100 loc) • 3.37 kB
JavaScript
;
import { AirshipActions } from "./AirshipActions.js";
import { AirshipAnalytics } from "./AirshipAnalytics.js";
import { AirshipChannel } from "./AirshipChannel.js";
import { AirshipContact } from "./AirshipContact.js";
import { AirshipInApp } from "./AirshipInApp.js";
import { AirshipLocale } from "./AirshipLocale.js";
import { AirshipMessageCenter } from "./AirshipMessageCenter.js";
import { AirshipPreferenceCenter } from "./AirshipPreferenceCenter.js";
import { AirshipPrivacyManager } from "./AirshipPrivacyManager.js";
import { AirshipPush } from "./AirshipPush.js";
import { AirshipFeatureFlagManager } from "./AirshipFeatureFlagManager.js";
import { Subscription, UAEventEmitter } from "./UAEventEmitter.js";
import { AirshipLiveActivityManager } from "./AirshipLiveActivityManager.js";
import { AirshipLiveUpdateManager } from "./AirshipLiveUpdateManager.js";
/**
* Airship
*/
export class AirshipRoot {
/**
* iOS only accessors
*/
/**
* iOS only accessors
*/
constructor(module) {
this.module = module;
this.eventEmitter = new UAEventEmitter(module);
this.actions = new AirshipActions(module);
this.analytics = new AirshipAnalytics(module);
this.channel = new AirshipChannel(module);
this.contact = new AirshipContact(module);
this.inApp = new AirshipInApp(module, this.eventEmitter);
this.locale = new AirshipLocale(module);
this.messageCenter = new AirshipMessageCenter(module);
this.preferenceCenter = new AirshipPreferenceCenter(module);
this.privacyManager = new AirshipPrivacyManager(module);
this.push = new AirshipPush(module);
this.featureFlagManager = new AirshipFeatureFlagManager(module);
this.iOS = new AirshipRootIOS(module);
this.android = new AirshipRootAndroid(module);
}
/**
* Calls takeOff. If Airship is already configured for
* the app session, the new config will be applied on the next
* app init.
* @param config The config.
* @returns A promise with the result. `true` if airship is ready.
*/
takeOff(config) {
return this.module.takeOff(config);
}
/**
* Checks if Airship is ready.
* @returns A promise with the result.
*/
isFlying() {
return this.module.isFlying();
}
/**
* Adds a listener.
* @param eventType The listener type.
* @param listener The listener.
* @returns A subscription.
*/
addListener(eventType, listener) {
this.eventEmitter.addListener(eventType, listener);
return new Subscription(() => {
this.removeListener(eventType, listener);
});
}
/**
* Removes a listener.
*
* @param eventType The event type.
* @param listener The event listener. Should be a reference to the function passed into addListener.
*/
removeListener(eventType, listener) {
this.eventEmitter.removeListener(eventType, listener);
}
/**
* Removes all listeners for a given type.
*
* @param eventType The event type.
*/
removeAllListeners(eventType) {
this.eventEmitter.removeAllListeners(eventType);
}
}
export class AirshipRootIOS {
constructor(module) {
this.liveActivityManager = new AirshipLiveActivityManager(module);
}
}
export class AirshipRootAndroid {
constructor(module) {
this.liveUpdateManager = new AirshipLiveUpdateManager(module);
}
}
//# sourceMappingURL=AirshipRoot.js.map