@intercom/intercom-react-native
Version:
React Native wrapper to bridge our iOS and Android SDK
125 lines (124 loc) • 5.64 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Visibility = exports.Space = exports.LogLevel = exports.IntercomEvents = exports.IntercomContent = exports.ContentType = void 0;
var _reactNative = require("react-native");
const {
IntercomModule,
IntercomEventEmitter
} = _reactNative.NativeModules;
let Visibility = exports.Visibility = /*#__PURE__*/function (Visibility) {
Visibility["GONE"] = "GONE";
Visibility["VISIBLE"] = "VISIBLE";
return Visibility;
}({});
let LogLevel = exports.LogLevel = /*#__PURE__*/function (LogLevel) {
LogLevel["ASSERT"] = "ASSERT";
LogLevel["DEBUG"] = "DEBUG";
LogLevel["DISABLED"] = "DISABLED";
LogLevel["ERROR"] = "ERROR";
LogLevel["INFO"] = "INFO";
LogLevel["VERBOSE"] = "VERBOSE";
LogLevel["WARN"] = "WARN";
return LogLevel;
}({});
const IntercomEvents = exports.IntercomEvents = {
IntercomUnreadCountDidChange: IntercomEventEmitter.UNREAD_COUNT_CHANGE_NOTIFICATION,
IntercomWindowDidHide: IntercomEventEmitter.WINDOW_DID_HIDE_NOTIFICATION,
IntercomWindowDidShow: IntercomEventEmitter.WINDOW_DID_SHOW_NOTIFICATION,
IntercomHelpCenterWindowDidShow: IntercomEventEmitter.WINDOW_DID_SHOW_NOTIFICATION,
IntercomHelpCenterWindowDidHide: IntercomEventEmitter.WINDOW_DID_HIDE_NOTIFICATION
};
let Space = exports.Space = /*#__PURE__*/function (Space) {
Space["home"] = "HOME";
Space["helpCenter"] = "HELP_CENTER";
Space["messages"] = "MESSAGES";
Space["tickets"] = "TICKETS";
return Space;
}({});
const Intercom = {
loginUnidentifiedUser: () => IntercomModule.loginUnidentifiedUser(),
loginUserWithUserAttributes: userAttributes => IntercomModule.loginUserWithUserAttributes(userAttributes),
logout: () => IntercomModule.logout(),
setUserHash: hash => IntercomModule.setUserHash(hash),
updateUser: userAttributes => IntercomModule.updateUser(userAttributes),
isUserLoggedIn: () => IntercomModule.isUserLoggedIn(),
fetchLoggedInUserAttributes: () => IntercomModule.fetchLoggedInUserAttributes(),
logEvent: (eventName, metaData = undefined) => IntercomModule.logEvent(eventName, metaData),
fetchHelpCenterCollections: () => IntercomModule.fetchHelpCenterCollections(),
fetchHelpCenterCollection: (id = '') => IntercomModule.fetchHelpCenterCollection(id),
searchHelpCenter: (term = '') => IntercomModule.searchHelpCenter(term),
present: () => IntercomModule.presentIntercom(),
presentSpace: space => IntercomModule.presentIntercomSpace(space),
presentContent: content => IntercomModule.presentContent(content),
presentMessageComposer: (initialMessage = undefined) => IntercomModule.presentMessageComposer(initialMessage),
getUnreadConversationCount: () => IntercomModule.getUnreadConversationCount(),
hideIntercom: () => IntercomModule.hideIntercom(),
setBottomPadding: paddingBottom => IntercomModule.setBottomPadding(paddingBottom),
setInAppMessageVisibility: visibility => IntercomModule.setInAppMessageVisibility(visibility),
setLauncherVisibility: visibility => IntercomModule.setLauncherVisibility(visibility),
setNeedsStatusBarAppearanceUpdate: _reactNative.Platform.select({
ios: IntercomModule.setNeedsStatusBarAppearanceUpdate,
default: async () => true
}),
handlePushMessage: _reactNative.Platform.select({
android: IntercomModule.handlePushMessage,
default: async () => true
}),
sendTokenToIntercom: token => IntercomModule.sendTokenToIntercom(token),
setLogLevel: logLevel => IntercomModule.setLogLevel(logLevel),
addEventListener: (event, callback) => {
event === IntercomEvents.IntercomUnreadCountDidChange && _reactNative.Platform.OS === 'android' && IntercomEventEmitter.startEventListener();
const eventEmitter = new _reactNative.NativeEventEmitter(IntercomEventEmitter);
const listener = eventEmitter.addListener(event, callback);
const originalRemove = listener.remove;
listener.remove = () => {
event === IntercomEvents.IntercomUnreadCountDidChange && _reactNative.Platform.OS === 'android' && IntercomEventEmitter.removeEventListener();
originalRemove();
};
return listener;
}
};
var _default = exports.default = Intercom;
let ContentType = exports.ContentType = /*#__PURE__*/function (ContentType) {
ContentType["Article"] = "ARTICLE";
ContentType["Carousel"] = "CAROUSEL";
ContentType["Survey"] = "SURVEY";
ContentType["HelpCenterCollections"] = "HELP_CENTER_COLLECTIONS";
ContentType["Conversation"] = "CONVERSATION";
return ContentType;
}({});
const IntercomContent = exports.IntercomContent = {
articleWithArticleId(articleId) {
let articleContent = {};
articleContent.type = ContentType.Article;
articleContent.id = articleId;
return articleContent;
},
carouselWithCarouselId(carouselId) {
let carouselContent = {};
carouselContent.type = ContentType.Carousel;
carouselContent.id = carouselId;
return carouselContent;
},
surveyWithSurveyId(surveyId) {
let surveyContent = {};
surveyContent.type = ContentType.Survey;
surveyContent.id = surveyId;
return surveyContent;
},
helpCenterCollectionsWithIds(collectionIds) {
let helpCenterCollectionsContent = {};
helpCenterCollectionsContent.type = ContentType.HelpCenterCollections;
helpCenterCollectionsContent.ids = collectionIds;
return helpCenterCollectionsContent;
},
conversationWithConversationId(conversationId) {
let conversationContent = {};
conversationContent.type = ContentType.Conversation;
conversationContent.id = conversationId;
return conversationContent;
}
};
//# sourceMappingURL=index.js.map
;