Source

externalCode/configApi.js

/**
 * @typedef {Object} IntercomButtonProps
 * @property {Object} insets
 * @property {Object} style
 * @property {Boolean} isEnabled Returns `true` if Intercom is enabled
 */

/**
 * @typedef {Function} RegisterIntercomUserCallback
 * @param {User} user
 * @return {void}
 */
/**
 * @class
 * Configuration Hooks.
 * Instance name: configApi
 
   The ConfigApi enables you to configure various setup options within your app.
 * @example
 * externalCodeSetup.configApi.METHOD_NAME
 */
export class ConfigApi {
	/**
	 * @deprecated
	 */
	multisiteDrawerEnabled = false;
	setMultisiteDrawerEnabled = enabled => {
		this.multisiteDrawerEnabled = enabled;
	};

	/**
	 * @deprecated
	 */
	features = {followingEnabled: true, friendshipEnabled: true};
	provideCustomFeatures = features => Object.assign(this.features, features);

	/**
	 * @deprecated
	 */
	appName = null;
	setAppName = name => {
		this.appName = name;
	};

	guestLoginEnabled = true;
	/**
	 * Toggles the guest login feature.
	 * This will override the setting found in BuddyBoss site > BuddyBoss App > Settings > General > Registration > Privacy.
	 * If set to true, it will always show "Continue without logging in" on the login screen.
	 * @param {Boolean} enabled
	 * @example
	 *
	 * externalCodeSetup.configApi.setGuestLoginEnabled(true);
	 */
	setGuestLoginEnabled = enabled => {
		this.guestLoginEnabled = enabled;
	};

	appSwitchEnabled = false;
	/**
	 * You can enable the option to switch apps when you shake your phone.
	 * If you set the option to true it will show a "Switch App" option in your screen that you can select to switch between different apps.
	 * @param {Boolean} enabled
	 * @example
	 * externalCodeSetup.configApi.setAppSwitchEnabled(true);
	 */
	setAppSwitchEnabled = enabled => {
		this.appSwitchEnabled = enabled;
	};

	trackPlayerEnabled = false;
	/**
	 * If enabled, app will initialize TrackPlayer from "react-native-track-player" package.
	 * You can get more information on react native track player {@link https://github.com/DoubleSymmetry/react-native-track-player}.
	 * @example
	 * externalCodeSetup.configApi.setTrackPlayerEnabled();
	 */
	setTrackPlayerEnabled = () => {
		this.trackPlayerEnabled = true;
	};

	codeVerificationEnabled = null;
	/**
	 * You can use this hook to set the default behavior for when a user creates an account, the app navigates to the code verification screen where the user can enter the verification code.
	 * @example
	 * externalCodeSetup.configApi.setCodeVerificationEnabled(false);
	 */
	setCodeVerificationEnabled = enabled => {
		this.codeVerificationEnabled = enabled;
	};

	IntercomButton = null;

	/**
	 * @ignore
	 * You can use this to customize the Intercom button.
	 * If Intercom is enabled, the component will be visible in different screens such as the ForumsList, LearnTopic, and Notifications screens etc.
	 * @method
	 * @param {React.ComponentType<IntercomButtonProps>} IntercomButton
	 * @example
	 *
	 * ...
	 *
	 * import { Image, TouchableOpacity, Platform } from "react-native"
	 * import Intercom from "react-native-intercom";
	 * import { correctBottomSafeArea } from "@src/styles/global";
	 *
	 * export const applyCustomCode = (externalCodeSetup: any) => {
	 *
	 *     externalCodeSetup.configApi.setIntercomButton(({
	 *         style,
	 *         insets
	 *     }) => (<TouchableOpacity
	 *         style={[
	 *             {
	 *                 position: "absolute",
	 *                 bottom:
	 *                     Platform.OS === "ios"
	 *                         ? correctBottomSafeArea(insets.bottom) + 50
	 *                         : 30,
	 *                 right: 20,
	 *                 backgroundColor: "#EB675E",
	 *                 width: 60,
	 *                 height: 60,
	 *                 alignItems: "center",
	 *                 justifyContent: "center",
	 *                 borderRadius: 30,
	 *                 zIndex: 1
	 *             },
	 *             style
	 *         ]}
	 *         onPress={Intercom.displayMessageComposer}
	 *     >
	 *         <Image
	 *             style={{
	 *                 width: 24,
	 *                 height: 30,
	 *                 tintColor: "white"
	 *             }}
	 *             resizeMode="cover"
	 *             source={require("@src/assets/img/intercom.png")}
	 *         />
	 *     </TouchableOpacity>))
	 * }
	 */
	setIntercomButton = IntercomButton => {
		this.IntercomButton = IntercomButton;
	};

	registerIntercomUser = null;

	/**
	 * @ignore
	 * You can use this to modify how the app register the intercome user.
	 * @method
	 * @param {RegisterIntercomUserCallback} registerIntercomUser
	 * @example
	 *
	 * configApi.setRegisterIntercomUser(user => {
	 *   Intercom.registerIdentifiedUser({
	 *       userId: user.name
	 *   });
	 *   Intercom.updateUser({
	 *       name: user.name,
	 *       email: user.member_rest.user_email
	 *   });
	 * });
	 */
	setRegisterIntercomUser = callback => {
		this.registerIntercomUser = callback;
	};
}