UNPKG

urbanairship-gimbal-adapter-react-native

Version:
176 lines (145 loc) 4.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RegionEventType = exports.ConsentType = exports.ConsentState = exports.ConsentRequirement = exports.AirshipGimbalAdapter = void 0; var _reactNative = require("react-native"); var _AirshipGimbalEventEmitter = _interopRequireDefault(require("./AirshipGimbalEventEmitter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @hidden */ const AirshipGimbalAdapterModule = _reactNative.NativeModules.AirshipGimbalAdapterModule; /** * @hidden */ const eventEmitter = new _AirshipGimbalEventEmitter.default(); /** * Region event types. */ let RegionEventType; /** * Gimbal consent types. */ exports.RegionEventType = RegionEventType; (function (RegionEventType) { RegionEventType["Enter"] = "regionEnter"; RegionEventType["Exit"] = "regionExit"; })(RegionEventType || (exports.RegionEventType = RegionEventType = {})); let ConsentType; /** * Gimbal consent state. */ exports.ConsentType = ConsentType; (function (ConsentType) { ConsentType["Places"] = "places"; })(ConsentType || (exports.ConsentType = ConsentType = {})); let ConsentState; /** * GDPR consent requirement. */ exports.ConsentState = ConsentState; (function (ConsentState) { ConsentState["Unknown"] = "unknown"; ConsentState["Granted"] = "granted"; ConsentState["Refused"] = "refused"; })(ConsentState || (exports.ConsentState = ConsentState = {})); let ConsentRequirement; /** * A Gimbal place. */ exports.ConsentRequirement = ConsentRequirement; (function (ConsentRequirement) { ConsentRequirement["Unknown"] = "unknown"; ConsentRequirement["NotRequired"] = "notRequired"; ConsentRequirement["Required"] = "required"; })(ConsentRequirement || (exports.ConsentRequirement = ConsentRequirement = {})); /** * @hidden */ function convertEventEnum(eventType) { if (eventType === RegionEventType.Enter) { return "com.urbanairship.gimbal.region_enter"; } else if (eventType === RegionEventType.Exit) { return "com.urbanairship.gimbal.region_exit"; } throw new Error("Invalid event type: " + eventType); } /** * Airship Gimbal Adapter. */ const AirshipGimbalAdapter = { /** * Sets the Gimbal API key. * @param apiKey The Gimbal API key. */ setGimbalApiKey(apiKey) { return AirshipGimbalAdapterModule.setGimbalApiKey(apiKey); }, /** * Starts the adapter. * @return A promise with the result. */ start() { return AirshipGimbalAdapterModule.start(); }, /** * Stops the Gimbal Adapter. */ stop() { AirshipGimbalAdapterModule.stop(); }, /** * Checks if the adapter is started. * @return A promise with the result. */ isStarted() { return AirshipGimbalAdapterModule.isStarted(); }, /** * Checks if GDPR consent is required to use Gimbal. * @return A promise with the result. */ getGdprConsentRequirement() { return AirshipGimbalAdapterModule.getGdprConsentRequirement(); }, /** * Sets the GDPR consent result for the consent type. * @param consentType The consent type. * @param consentState The consent state. */ setUserConsent(consentType, consentState) { AirshipGimbalAdapterModule.setUserConsent(consentType, consentState); }, /** * Gets the GDPR consent for the consent type. * @param consentType The consent type. * @return A promise with the result. */ getUserConsent(consentType) { return AirshipGimbalAdapterModule.getUserConsent(consentType); }, /** * Adds a listener for an Airship Gimbal event. * * @param eventType The event type. Either regionEnter or regionExit. * @param listener The event listener. * @return An emitter subscription. */ addListener(eventType, listener) { var name = convertEventEnum(eventType); return eventEmitter.addListener(name, listener); }, /** * Adds a listener for an Airship Gimbal event. * * @param eventType The event type. Either regionEnter or regionExit. * @param listener The event listener. */ removeListener(eventType, listener) { var name = convertEventEnum(eventType); eventEmitter.removeListener(name, listener); } }; exports.AirshipGimbalAdapter = AirshipGimbalAdapter; //# sourceMappingURL=AirshipGimbalAdapter.js.map