UNPKG

react-firehooks

Version:

Lightweight dependency-free collection of React hooks for Firebase

20 lines (19 loc) 970 B
import { Messaging, GetTokenOptions } from "firebase/messaging"; import { ValueHookResult } from "../common/index.js"; export type UseMessagingTokenResult = ValueHookResult<string, Error>; /** * Options to configure how the token will be fetched */ export interface UseMessagingTokenOptions { getTokenOptions?: GetTokenOptions | undefined; } /** * Returns the messaging token. The token never updates. * @param messaging Firebase Messaging instance * @param options Options to configure how the token will be fetched * @returns Token, loading state, and error * - value: Messaging token; `undefined` if token is currently being fetched, or an error occurred * - loading: `true` while fetching the token; `false` if the token was fetched successfully or an error occurred * - error: `undefined` if no error occurred */ export declare function useMessagingToken(messaging: Messaging, options?: UseMessagingTokenOptions | undefined): UseMessagingTokenResult;