import { BadgeUpSettings } from '../config'; import { BadgeUpNotificationType, BadgeUpPartialEvent, BadgeUpStorage } from '../declarations'; import { BadgeUp as BadgeUpJSClient } from '@badgeup/badgeup-browser-client'; import { BadgeUpLogger } from './badgeUpLogger'; import { BadgeUpNotification } from './badgeUpNotification'; import { SubjectProvider } from './providers/subject'; export declare class BadgeUpClient { private subjectProvider; private badgeUpLogger; private badgeUpNotification; private badgeUpSettings; private badgeUpStorage; badgeUpJSClient: BadgeUpJSClient; /** * Notification callback used to receive BadgeUp notifications * about user achievements and awards. * * @callback notificationCallback * @param notificationType - The type of the notification. * @param data - Any data that type of notification has. This can be cast depending on the type of notification. */ private notificationCallbacks; /** * BadgeUp Ionic client constructor * @param badgeUpLogger - Internal logger. * @param badgeUpNotification - Provides toast notifications to users. * @param badgeUpSettings - Client settings. * @param badgeUpStorage - Storage engine for events. * @param browserClient - Underlying browser client that the ionic client relies on. https://github.com/BadgeUp/badgeup-browser-client */ constructor(subjectProvider: SubjectProvider, badgeUpLogger: BadgeUpLogger, badgeUpNotification: BadgeUpNotification, badgeUpSettings: BadgeUpSettings, badgeUpStorage: BadgeUpStorage, badgeUpJSClient: BadgeUpJSClient); private init(); /** * Allows you to configure the default subject provider. If at any point the subject is undefined * for some events, this provider will be called. * * As an input, you get eventKey, which lets you return different subject values based on the event key. * For some event keys, you might want to use deviceId as a subject, for others, the user's email. * @param subjectProvider - The subject provider to use. */ setSubject(subject: string): void; /** * Subscribe to BadgeUp notifications and receive new notifications about the state of system. * * For example, you can receive 'new achievement' notification that you can use to learn about * new achievements user has earned, and display some kind of congratulations modal. * @param notificationCallback - The callback to use when notification is received */ subscribe(notificationCallback: (notificationType: BadgeUpNotificationType, data: any) => void): void; /** * Unsubscribe from BadgeUp notifications. * * Unsubscribe if you're done, as failure to do so will lead to memory leaks. * @param notificationCallback - The callback to unsubscribe from. */ unsubscribe(notificationCallback: (notificationType: BadgeUpNotificationType, data: any) => void): void; /** * Send a new BadgeUp event * * This method works without internet as well, using local storage to store the events. * Events will be synced to server once internet is available again. * @param badgeUpEvent - The event to send */ emit(e: BadgeUpPartialEvent): void; private fire(eventType, data); private progressHandler(progress); /** * Sends all events in storage, clearing storage */ private flush(); }