@tef-novum/webview-bridge
Version:
JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.
207 lines (206 loc) • 8.09 kB
TypeScript
import { NativeAppResponsePayload } from './post-message';
export declare const attachToEmail: ({ url, subject, fileName, recipient, body, }: {
url: string;
subject?: string | undefined;
fileName: string;
recipient?: string | undefined;
body?: string | undefined;
}) => Promise<void>;
export declare type ShareOptions = {
text: string;
} | {
url: string;
fileName: string;
text?: string;
};
export declare const share: (options: ShareOptions) => Promise<void>;
export declare type NavigationBarIcon = Readonly<{
/** Identifier. The native side will notify the WebView when the icon is clicked using this id*/
id: string;
/** URL to be opened by the app as a deep-link if present */
url?: string;
/**
* Accessibility label for the icon. When isButton=true you should always set a name, when isButton=false if you don't want it to be
* read by screen readers, then explicitly set it to an empty string.
* */
name: string;
/** default: true, set to false if the Icon is decorative */
isButton?: boolean;
/**
* This is a string whose value will be mapped to a local resource that the app already knows.
* See https://void.tuenti.io/idl-server/files/TopNavbarIcon/1.1 for available values.
* A fallback icon will be used if the app doesn't recognize the value.
*/
iconEnum?: string;
/**
* Set of urls that the app will use to render the icon.
* If both iconEnum and icon are received, the iconEnum should be used as a fallback in case there's some issue with the urls.
*/
icon?: {
/**
* Those urls should be icons in PNG format.
* The icons will not be rendered until the image has been downloaded by the app.
* The URLs should be inmutable to allow the app to cache those icons for an arbitrary amount of time.
*/
url: string;
/** To be used if present when dark mode is activated. */
urlDark?: string;
};
badge?: {
/**
* Boolean to determine if the badge should be shown
* If `show` is `true` and number and nativeLogic are not present, the badge will be shown as a dot
*/
show: boolean;
/** Same logic and current same supported values as in nativeLogic field from API */
nativeLogic?: 'INBOX' | 'PROFILE';
/** Hardcoded value to set as the badge count. It will have more priority than nativeLogic. */
number?: number;
};
/**
* Tracking properties to be sent to analytics when the icon is clicked.
* These properties will be merged to the tracking event produced by the native side
*/
trackingProperties?: Record<string, string>;
/**
* Identifies the action, native app can then do specific logic for this action.
* Ex: if sectionName matches a maintenanceMode id, it may show a maintenance message instead of the usual behaviour
*/
sectionName?: string;
}>;
/**
* Related doc: https://confluence.tid.es/pages/viewpage.action?spaceKey=CTO&title=%5BAPPS%5D+Shared+Spec%3A+Top+Bar+customization#id-[APPS]SharedSpec:TopBarcustomization-Tracking
*/
export declare const updateNavigationBar: (options: Readonly<{
title?: string;
expandedTitle?: string;
showBackButton?: boolean;
showReloadButton?: boolean;
/** @deprecated New apps will ignore this field */
showProfileButton?: boolean;
backgroundColor?: string;
leftActions?: ReadonlyArray<NavigationBarIcon>;
rightActions?: ReadonlyArray<NavigationBarIcon>;
/**
* It defines how the icons and the text of the top bar should be tinted.
* If null or unknown value is received, the initial colors set by the app or the last colorVariant set will be used
*/
colorVariant?: 'INVERSE' | 'REGULAR' | null;
/**
* This is a flag used to indicate that the appearance of the top bar should be restored to its original state.
* The other fields that may come in the same bridge call will be applied after the reset
*/
resetToDefaultState?: boolean;
}>) => Promise<void>;
/**
* Returns the unsubscribe function. Should be called when the component is unmounted.
*/
export declare const onNavigationBarIconClicked: (handler: (payload: {
id: string;
}) => void) => (() => void);
/**
* @deprecated
*/
export declare const setWebViewTitle: (title: string) => Promise<void>;
export declare const notifyPageLoaded: () => Promise<void>;
export declare const notifyBridgeReady: () => Promise<void>;
declare type RemoteConfig = {
result: {
[s: string]: string;
};
};
export declare const getRemoteConfig: () => Promise<RemoteConfig>;
export declare const isABTestingAvailable: (key: string) => Promise<boolean>;
export declare const reportStatus: ({ feature, status, reason, }: {
feature: 'ACCOUNT';
status: 'CRITICAL' | 'GOOD' | 'BAD';
reason: string;
}) => Promise<NativeAppResponsePayload<'STATUS_REPORT'>>;
export declare const fetch: ({ url, method, headers, body, }: {
url: string;
method: 'GET' | 'POST';
headers: {
[key: string]: string;
};
body: string;
}) => Promise<NativeAppResponsePayload<'FETCH'>>;
declare type PermissionsStatus = 'notifications' | 'read-contacts' | 'write-contacts';
export declare const checkPermissionStatus: (feature: PermissionsStatus, params?: {
[key: string]: string;
} | undefined) => Promise<boolean>;
export declare const getAppMetadata: (appToken: string) => Promise<{
isInstalled: boolean;
marketUrl: string;
appUrl: string;
}>;
export declare const getNetworkConnectionInfo: () => Promise<NativeAppResponsePayload<'DATA_CONNECTION_INFO'>>;
declare type ActionBehavior = {
behavior: 'confirm';
title: string;
message: string;
acceptText: string;
cancelText: string;
} | {
behavior: 'default';
} | {
behavior: 'cancel';
};
export declare const setActionBehavior: (actions: {
webviewClose?: ActionBehavior;
navigationBack?: ActionBehavior;
}) => Promise<void>;
/**
* Returns the Topaz SDK Token
* https://www.topaz.com.br/ofd/index.php
*/
export declare const getTopazToken: (options?: {
timeout?: number;
}) => Promise<{
token: string;
}>;
export declare const getTopazValues: () => Promise<{
syncId?: string;
}>;
export declare const getPincodeInfo: () => Promise<{
status: 'enabled' | 'disabled';
}>;
export declare const triggerPinOrBiometricAuthentication: (maxSecondsSinceLastValidation: number) => Promise<NativeAppResponsePayload<'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION'>>;
export declare const focusNavbar: () => Promise<{
focused: boolean;
}>;
export declare const showLoadingOverlay: (payload: {
/**
* Whether the in animation is enabled (false by default)
*/
inAnimation?: boolean;
/**
* Whether the out animation is enabled (false by default)
*/
outAnimation?: boolean;
/**
* Minimum duration of the loop animation in milliseconds (0 by default)
*/
minimumLoopDurationMs?: number;
/**
* whether the loop animation should be stopped immediately or not (true by default)
*/
stopAnimationCycle?: boolean;
/**
* List of description texts to be shown one after the other
*/
descriptions?: Array<string>;
/**
* Duration of each description in milliseconds (3000 by default)
*/
descriptionDurationMs?: number;
/**
* After this timeout loading screen would be hidden automatically (20000 by default)
*/
timeoutMs?: number;
/**
* (Only Android) If true, after loading screen has been hidden, if user presses android back button, webview window will close (true by default)
*/
closeOnBackButtonPressAfterFinish?: boolean;
}) => Promise<void>;
export declare const hideLoadingOverlay: () => Promise<void>;
export {};