starti.app 2.0.3 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/EventTarget.d.ts +17 -0
  2. package/dist/getIntegrations.d.ts +2 -0
  3. package/dist/index.d.ts +9 -38
  4. package/dist/integrationWrapper.d.ts +69 -0
  5. package/dist/integrations/App/AppIntegration.d.ts +114 -0
  6. package/dist/integrations/App/typings.d.ts +14 -0
  7. package/dist/integrations/Biometrics/BiometricsIntegration.d.ts +69 -0
  8. package/dist/integrations/Developer/DeveloperIntegration.d.ts +15 -0
  9. package/dist/integrations/Device/DeviceIntegration.d.ts +28 -0
  10. package/dist/integrations/InAppPurchase/InAppPurchaseIntegration.d.ts +39 -0
  11. package/dist/integrations/Location/LocationIntegration.d.ts +6 -0
  12. package/dist/integrations/{network.d.ts → Network/NetworkIntegration.d.ts} +25 -11
  13. package/dist/integrations/NfcScanner/NfcScannerIntegration.d.ts +39 -0
  14. package/dist/integrations/PushNotification/PushNotificationIntegration.d.ts +78 -0
  15. package/dist/integrations/PushNotification/Topic.d.ts +15 -0
  16. package/dist/integrations/QrScanner/QrScannerIntegration.d.ts +34 -0
  17. package/dist/integrations/Share/ShareIntegration.d.ts +30 -0
  18. package/dist/integrations/Storage/StorageIntegration.d.ts +15 -0
  19. package/dist/integrations/Trigger/TriggerIntegration.d.ts +7 -0
  20. package/dist/integrations/User/UserIntegration.d.ts +16 -0
  21. package/dist/integrations.d.ts +127 -0
  22. package/dist/lib/EnvironmentGetter.d.ts +1 -1
  23. package/dist/lib/Logger.d.ts +3 -3
  24. package/dist/services/flowLink-service.d.ts +1 -1
  25. package/dist/services/ui-service.d.ts +1 -1
  26. package/dist/startiapp.d.ts +93 -0
  27. package/package.json +27 -31
  28. package/dist/@types/EventHandlerWithTypes.d.ts +0 -5
  29. package/dist/@types/integrations.d.ts +0 -107
  30. package/dist/@types/types.d.ts +0 -31
  31. package/dist/app.d.ts +0 -80
  32. package/dist/clientUser.d.ts +0 -14
  33. package/dist/getIntegration.d.ts +0 -18
  34. package/dist/index.js +0 -1
  35. package/dist/integrations/biometrics.d.ts +0 -33
  36. package/dist/integrations/developer.d.ts +0 -10
  37. package/dist/integrations/device.d.ts +0 -18
  38. package/dist/integrations/iap.d.ts +0 -27
  39. package/dist/integrations/nfc.d.ts +0 -19
  40. package/dist/integrations/pushnotification.d.ts +0 -45
  41. package/dist/integrations/qrscanner.d.ts +0 -14
  42. package/dist/integrations/share.d.ts +0 -18
  43. package/dist/integrations/storage.d.ts +0 -5
  44. package/dist/integrations/trigger.d.ts +0 -14
@@ -0,0 +1,17 @@
1
+ type EventListenerOrEventListenerObjectWithType<T> = EventListenerWithType<T> | EventListenerObjectWithType<T>;
2
+ interface EventListenerWithType<T> {
3
+ (evt: T): void;
4
+ }
5
+ interface EventListenerObjectWithType<T> {
6
+ handleEvent(evt: T): void;
7
+ }
8
+ declare class EventTarget {
9
+ addEventListener(type: unknown, listener: unknown, options?: unknown): void;
10
+ removeEventListener(type: unknown, listener: unknown, options?: unknown): void;
11
+ protected dispatchEvent(event: Event): boolean;
12
+ }
13
+ export declare class EventTargetWithType<T extends Record<string | number | symbol, Event>> extends EventTarget {
14
+ addEventListener<K extends keyof T>(type: K, callback: EventListenerOrEventListenerObjectWithType<T[K]>, options?: boolean | AddEventListenerOptions): void;
15
+ removeEventListener<K extends keyof T>(type: K, callback: EventListenerOrEventListenerObjectWithType<T[K]>, options?: boolean | EventListenerOptions): void;
16
+ }
17
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Integrations } from "./integrations";
2
+ export declare function getIntegration<T extends keyof Integrations>(integration: T): Integrations[T];
package/dist/index.d.ts CHANGED
@@ -1,39 +1,10 @@
1
- import { InitializeParams } from "./@types/types";
2
- declare const startiappModuleEvents: readonly ["app-integrations-are-ready"];
3
- declare type StartiappEvents = "ready" | "error" | typeof startiappModuleEvents[number];
4
- declare class StartiappClass extends EventTarget {
5
- get appIntegration(): import("./@types/integrations").AppIntegration;
6
- /** Basic calls to the app. */
7
- App: import("./app").IApp;
8
- /** Access to device functionality. */
9
- Device: import("./integrations/device").IDevice;
10
- /** The biometric functionality. */
11
- Biometrics: import("./integrations/biometrics").IBiometrics;
12
- /** Access to client user functionality. */
13
- User: import("./clientUser").IClientUser;
14
- /** The NFC scanning functionality. */
15
- NfcScanner: import("./integrations/nfc").INFC;
16
- /** Access to push notifications using Firebase. */
17
- PushNotification: import("./integrations/pushnotification").IPushNotification;
18
- /** The QR- and barcode scanning functionality. */
19
- QrScanner: import("./integrations/qrscanner").IQrScanner;
20
- /** The share functionality. */
21
- Share: import("./integrations/share").IShare;
22
- /** The network functionality. */
23
- Network: import("./integrations/network").INetwork;
24
- /** The storage functionality. */
25
- Storage: import("./integrations/storage").IStorage;
26
- /** Trigger functionality */
27
- Trigger: import("./integrations/trigger").ITrigger;
28
- /** The In App Purchases functionality */
29
- Iap: import("./integrations/iap").IIap;
30
- Developer: import("./integrations/developer").IDeveloper;
31
- /** Call this method to initialize the starti.app API integration. This method should be called AFTER all integrations are ready (see onIntegrationsAreReady). */
32
- initialize(options?: InitializeParams): void;
33
- /** Call this method to check if the app is running in the starti.app app. */
34
- isRunningInApp(): boolean;
35
- addEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
36
- removeEventListener(type: StartiappEvents, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1
+ import "./polyfills/eventTarget.js";
2
+ import { StartiappClass } from "./startiapp";
3
+ declare global {
4
+ const startiapp: StartiappClass;
5
+ interface Window {
6
+ startiapp: StartiappClass;
7
+ }
37
8
  }
38
- declare let startiapp: StartiappClass;
39
- export default startiapp;
9
+ declare const _default: StartiappClass;
10
+ export default _default;
@@ -0,0 +1,69 @@
1
+ import { Integrations } from "./integrations";
2
+ type FunctionOfIntegrationMethod<TIntegrationKey extends keyof Integrations, TIntegrationMethodKey extends keyof Integrations[TIntegrationKey]> = Integrations[TIntegrationKey][TIntegrationMethodKey] extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => TReturn : never;
3
+ type MethodFunction = (...args: any) => any;
4
+ type PromiseResolve<T> = (value?: T | PromiseLike<T>) => void;
5
+ type AsyncIntegrationResolverCallOptions<TMethodKey, TMethodResponse> = {
6
+ methodName: TMethodKey;
7
+ shouldResolve?: (value: TMethodResponse) => boolean;
8
+ };
9
+ declare class AsyncIntegrationResolver<TIntegrationKey extends keyof Integrations> {
10
+ private integrationKey;
11
+ promises: Record<string, Array<{
12
+ resolve: PromiseResolve<any>;
13
+ shouldResolve?: (value: any) => boolean;
14
+ }>>;
15
+ events: Record<string, Array<(...args: any[]) => void>>;
16
+ private get integration();
17
+ constructor(integrationKey: TIntegrationKey);
18
+ /**
19
+ * Asynchronously calls a method on the integration, handling its execution and promise resolution.
20
+ *
21
+ * @param methodName The name of the method to call on the integration.
22
+ * @param args The arguments to pass to the method.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const result: Promise<MethodNameResult> = await <integration>.call("methodName", ...args);
27
+ * ```
28
+ */
29
+ call<TIntegrationMethodKey extends keyof Integrations[TIntegrationKey], TMethod extends MethodFunction = FunctionOfIntegrationMethod<TIntegrationKey, TIntegrationMethodKey>, TMethodReturnType = ReturnType<TMethod>>(optionsOrMethodName: AsyncIntegrationResolverCallOptions<TIntegrationMethodKey, TMethodReturnType> | TIntegrationMethodKey, ...args: Parameters<TMethod>): Promise<TMethodReturnType>;
30
+ /**
31
+ * Registers an event listener for a specified event name.
32
+ *
33
+ * @param eventName The name of the event to listen for. Should match the name emitted by the app.
34
+ * @param listener The function to call when the event is emitted.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * <integration>.listen("eventName", (args) => {
39
+ * console.log(args);
40
+ * });
41
+ * ```
42
+ */
43
+ listen(eventName: string, listener: (...args: any[]) => void): Promise<void>;
44
+ private callIntegration;
45
+ }
46
+ /**
47
+ * Creates a wrapper around an integration, allowing for asynchronous method calls and event listening.
48
+ *
49
+ * @param integration The name of the integration to wrap
50
+ * @param overrideResolverName The name of the window object to register the integration on. Defaults to `startiapp${integration.replace("Integration", "")}`
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ *
55
+ * // Create a wrapper around the AppIntegration and register it on the window object
56
+ * // This allows the app to call methods on the integration and listen for events
57
+ * const appIntegration = createIntegrationWrapper("AppIntegration");
58
+ *
59
+ * // Call a method on the integration
60
+ * const brandId = await appIntegration.call("brandId");
61
+ *
62
+ * // Listen for an event emitted by the integration
63
+ * appIntegration.listen("navigatingPage", (args) => {
64
+ * console.log(args);
65
+ * });
66
+ * ```
67
+ */
68
+ export declare function createIntegrationWrapper<TIntegrationKey extends keyof Integrations>(integration: TIntegrationKey, overrideResolverName?: string): AsyncIntegrationResolver<TIntegrationKey>;
69
+ export {};
@@ -0,0 +1,114 @@
1
+ import { EventTargetWithType } from "../../EventTarget";
2
+ import { SetStatusBarOptions, SpinnerOptions, Startiapp } from "../../startiapp";
3
+ import { NavigatingPageEvent } from "./typings";
4
+ export declare class App extends EventTargetWithType<{
5
+ navigatingPage: CustomEvent<NavigatingPageEvent>;
6
+ appInForeground: CustomEvent<void>;
7
+ }> {
8
+ private readonly startiapp;
9
+ private appIntegration;
10
+ private alternateIconsIntegration;
11
+ private hasStartiappLoaded;
12
+ constructor(startiapp: Startiapp);
13
+ isStartiappLoaded(): boolean;
14
+ /**
15
+ * Get the brand id of the app.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // "example-brand"
20
+ * const brandId = await startiapp.App.brandId();
21
+ * ```
22
+ */
23
+ brandId: () => Promise<string>;
24
+ /**
25
+ * Get the device id of the app.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // "00000000-0000-0000-0000-000000000000"
30
+ * const deviceId = await startiapp.App.deviceId();
31
+ * ```
32
+ */
33
+ deviceId: () => Promise<string>;
34
+ /**
35
+ * Get the version of the app.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // "1.0.0"
40
+ * const version = await startiapp.App.version();
41
+ * ```
42
+ */
43
+ version: () => Promise<string>;
44
+ /**
45
+ * Add an internal domain to the app.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * await startiapp.App.addInternalDomain("example.com");
50
+ * ```
51
+ */
52
+ addInternalDomain: (domain: string) => Promise<void>;
53
+ /**
54
+ * Remove an internal domain from the app.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * await startiapp.App.removeInternalDomain("example.com");
59
+ * ```
60
+ */
61
+ removeInternalDomain: (domain: string) => Promise<void>;
62
+ /** Sets the status bar options for the app. */
63
+ setStatusBar: (options: SetStatusBarOptions) => Promise<void>;
64
+ /** Sets the navigation spinner options for the app. */
65
+ setSpinner: (options: SpinnerOptions) => Promise<void>;
66
+ /** Enables the screen to rotate */
67
+ enableScreenRotation: () => Promise<void>;
68
+ /** Prevents the screen from rotation */
69
+ disableScreenRotation: () => Promise<void>;
70
+ /** Enables swipe gestures for navigation */
71
+ enableSwipeNavigation: () => Promise<void>;
72
+ /** Disables swipe gestures for navigation */
73
+ disableSwipeNavigation: () => Promise<void>;
74
+ /**
75
+ * Set the app icon.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * await startiapp.App.setAppIcon("icon-name");
80
+ * ```
81
+ */
82
+ setAppIcon: (iconName: string) => Promise<void>;
83
+ /**
84
+ * Get the current app icon.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const currentIcon = await startiapp.App.getCurrentIcon();
89
+ * console.log(currentIcon);
90
+ */
91
+ getCurrentIcon: () => Promise<string>;
92
+ /**
93
+ * Get the available app icons.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const availableIcons = await startiapp.App.getAvailableIcons();
98
+ * console.log(availableIcons);
99
+ * ```
100
+ */
101
+ getAvailableIcons: () => Promise<string[]>;
102
+ /**
103
+ * Prompt the user to review the app.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * await startiapp.App.requestReview();
108
+ * ```
109
+ */
110
+ requestReview: () => Promise<void>;
111
+ private onStartiappReady;
112
+ private handleNavigatingPageEvent;
113
+ private handleAppInForegroundEvent;
114
+ }
@@ -0,0 +1,14 @@
1
+ export interface NavigatingPageEvent {
2
+ url: string;
3
+ opensExternalbrowser: boolean;
4
+ }
5
+ export interface NavigationSpinnerOptions {
6
+ show: boolean;
7
+ color: string;
8
+ delay: number;
9
+ excludedDomains: string[];
10
+ }
11
+ export interface RegexDto {
12
+ pattern: string;
13
+ flags: string;
14
+ }
@@ -0,0 +1,69 @@
1
+ import { Startiapp } from "../../startiapp";
2
+ export declare class Biometrics extends EventTarget {
3
+ private readonly startiapp;
4
+ private biometricsIntegration;
5
+ private SECURED_CONTENT_KEY;
6
+ private SECURED_LOGIN_KEY;
7
+ private defaultScanTitle;
8
+ private defaultScanReason;
9
+ constructor(startiapp: Startiapp);
10
+ /**
11
+ * Starts a biometrics scan
12
+ *
13
+ * @param title - The title of the scan.
14
+ * @param reason - The reason for the scan.
15
+ * @returns A boolean indicating if the scan was successful.
16
+ */
17
+ scan(title?: string, reason?: string): Promise<boolean>;
18
+ /**
19
+ * Retrieves the authentication type from the biometrics integration.
20
+ */
21
+ getAuthenticationType(): Promise<BiometricsAuthenticationType>;
22
+ /**
23
+ * Saves secured content.
24
+ */
25
+ setSecuredContent(content: unknown): Promise<void>;
26
+ /**
27
+ * Saves the username and password.
28
+ */
29
+ setUsernameAndPassword(username: string, password: string): Promise<void>;
30
+ /**
31
+ * Retrieves the saved username and password.
32
+ */
33
+ getUsernameAndPassword(title?: string, reason?: string): Promise<{
34
+ username: string;
35
+ password: string;
36
+ } | null>;
37
+ /**
38
+ * Checks if there's a saved username and password.
39
+ */
40
+ hasUsernameAndPassword(): Promise<BiometricsResultReponse<boolean>>;
41
+ /**
42
+ * Removes the saved username and password.
43
+ */
44
+ removeUsernameAndPassword(): Promise<void>;
45
+ /**
46
+ * Retrieves secured content.
47
+ *
48
+ * @param title - The title of the secured content.
49
+ * @param reason - The reason for retrieving the secured content.
50
+ * @returns The secured content.
51
+ */
52
+ getSecuredContent<T>(title?: string, reason?: string): Promise<T | null>;
53
+ /**
54
+ * Checks if there's secured content.
55
+ * @returns Returns true if the secured content exists, false otherwise.
56
+ */
57
+ hasSecuredContent(): Promise<BiometricsResultReponse<boolean>>;
58
+ /**
59
+ * Removes secured content.
60
+ *
61
+ * @returns A promise that resolves when the secured content is successfully removed.
62
+ */
63
+ removeSecuredContent(): Promise<void>;
64
+ }
65
+ export type BiometricsAuthenticationType = "None" | "Face" | "Fingerprint";
66
+ export type BiometricsResultReponse<T> = {
67
+ key: string;
68
+ result: T;
69
+ };
@@ -0,0 +1,15 @@
1
+ import { Startiapp } from "../../startiapp";
2
+ export declare class Developer extends EventTarget {
3
+ private readonly startiapp;
4
+ private integration;
5
+ constructor(startiapp: Startiapp);
6
+ /**
7
+ * Intentionally crashes the app.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * await startiapp.Developer.closeApp();
12
+ * ```
13
+ */
14
+ closeApp: () => Promise<void>;
15
+ }
@@ -0,0 +1,28 @@
1
+ import { EventTargetWithType } from "../../EventTarget";
2
+ import { Startiapp } from "../../startiapp";
3
+ export declare class Device extends EventTargetWithType<{
4
+ shake: CustomEvent<never>;
5
+ }> {
6
+ private readonly startiapp;
7
+ private deviceIntegration;
8
+ constructor(startiapp: Startiapp);
9
+ /**
10
+ * Starts the accelerometer.
11
+ *
12
+ * @returns A promise that resolves when the accelerometer has started.
13
+ */
14
+ startAccelerometer(): Promise<void>;
15
+ /**
16
+ * Stops the accelerometer.
17
+ *
18
+ * @returns A promise that resolves when the accelerometer is stopped.
19
+ */
20
+ stopAccelerometer(): Promise<void>;
21
+ /**
22
+ * Checks if the accelerometer is started.
23
+ *
24
+ * @returns True if the accelerometer is started, false otherwise.
25
+ */
26
+ isAccelerometerStarted(): Promise<boolean>;
27
+ protected onShakeEvent(): void;
28
+ }
@@ -0,0 +1,39 @@
1
+ import { Startiapp } from "../../startiapp";
2
+ export declare class InAppPurchase extends EventTarget {
3
+ private readonly startiapp;
4
+ private inAppPurchaseIntegration;
5
+ constructor(startiapp: Startiapp);
6
+ /**
7
+ * Purchases a product.
8
+ *
9
+ * @param productId - The ID of the product to purchase.
10
+ * @param purchaseType - The type of purchase.
11
+ * @returns A promise that resolves when the purchase is completed.
12
+ */
13
+ purchaseProduct(productId: string, purchaseType: InApPurchasePurchaseType): Promise<InAppPurchaseResponse<InAppPurchaseProductResponse>>;
14
+ /**
15
+ * Retrieves the product with the specified ID and purchase type.
16
+ *
17
+ * @param productId - The ID of the product to retrieve.
18
+ * @param purchaseType - The type of purchase.
19
+ * @returns The retrieved product.
20
+ */
21
+ getProduct(productId: string, purchaseType: InApPurchasePurchaseType): Promise<InAppPurchaseResponse<InAppPurchaseGetProductResponse>>;
22
+ }
23
+ export type InAppPurchaseResponse<T extends InAppPurchaseProductResponse | InAppPurchaseGetProductResponse> = {
24
+ success: true;
25
+ value: T;
26
+ } | {
27
+ success: false;
28
+ errorMessage: string;
29
+ };
30
+ export type InAppPurchaseProductResponse = {
31
+ transactionIdentifier: string;
32
+ };
33
+ export type InAppPurchaseGetProductResponse = {
34
+ name: string;
35
+ description: string;
36
+ localizedPrice: string;
37
+ currencyCode: string;
38
+ };
39
+ export type InApPurchasePurchaseType = "nonconsumable" | "consumable";
@@ -0,0 +1,6 @@
1
+ import { Startiapp } from "../../startiapp";
2
+ export declare class Location extends EventTarget {
3
+ private readonly startiapp;
4
+ private locationIntegration;
5
+ constructor(startiapp: Startiapp);
6
+ }
@@ -1,16 +1,12 @@
1
- import { EventTargetMethods } from "../@types/EventHandlerWithTypes";
2
- declare type ListenResponse = {
3
- success: boolean;
4
- message?: string;
5
- };
6
- declare type NetworkAccess = "ConstrainedInternet" | "Internet" | "Local" | "None" | "Unknown";
7
- export declare const Network: INetwork;
8
- declare type NetworkEvents = {
1
+ import { EventTargetWithType } from "../../EventTarget";
2
+ import { Startiapp } from "../../startiapp";
3
+ export declare class Network extends EventTargetWithType<{
9
4
  connectionStateChanged: CustomEvent<ConnectionChangeEvent>;
10
5
  udpPacketReceived: CustomEvent<UdpPacketReceivedEvent>;
11
- };
12
- export interface INetwork extends EventTargetMethods<NetworkEvents> {
13
- /** Returns the current SSID of the device. */
6
+ }> {
7
+ private readonly startiapp;
8
+ private networkIntegration;
9
+ constructor(startiapp: Startiapp);
14
10
  /** Sends a UDP broadcast to the local network. */
15
11
  sendUdpBroadcast(port: number, message: string): Promise<boolean>;
16
12
  /** Returns the current connectivity state. */
@@ -23,5 +19,23 @@ export interface INetwork extends EventTargetMethods<NetworkEvents> {
23
19
  startListeningForConnectionChanges(): Promise<ListenResponse>;
24
20
  /** Stops listening for changes in the network connection. */
25
21
  stopListeningForConnectionChanges(): Promise<ListenResponse>;
22
+ private handleConnectionStateChanged;
23
+ private handleUdpPacketReceived;
26
24
  }
25
+ export type NetworkAccess = "ConstrainedInternet" | "Internet" | "Local" | "None" | "Unknown";
26
+ type ConnectionProfile = "Bluetooth" | "Cellular" | "Ethernet" | "WiFi" | "Unknown";
27
+ type ConnectionChangeEvent = {
28
+ networkAccess: NetworkAccess;
29
+ connectionProfiles: ConnectionProfile;
30
+ };
31
+ type UdpPacketReceivedEvent = {
32
+ detail: {
33
+ message: string;
34
+ ip: string;
35
+ };
36
+ };
37
+ export type ListenResponse = {
38
+ success: boolean;
39
+ message?: string;
40
+ };
27
41
  export {};
@@ -0,0 +1,39 @@
1
+ import { EventTargetWithType } from "../../EventTarget";
2
+ import { Startiapp } from "../../startiapp";
3
+ export declare class NfcScanner extends EventTargetWithType<{
4
+ nfcTagScanned: CustomEvent<NfcTagResultRecieved>;
5
+ }> {
6
+ private readonly startiapp;
7
+ private nfcIntegration;
8
+ constructor(startiapp: Startiapp);
9
+ /**
10
+ * Checks if NFC is supported.
11
+ * @returns True if NFC is supported, false otherwise.
12
+ */
13
+ isNfcSupported(): Promise<boolean>;
14
+ /**
15
+ * Checks if NFC is enabled.
16
+ *
17
+ * @returns A boolean indicating if NFC is enabled.
18
+ */
19
+ isNfcEnabled(): Promise<boolean>;
20
+ /**
21
+ * Starts the NFC scanner.
22
+ *
23
+ * @returns A promise that resolves when the NFC scanner starts listening.
24
+ */
25
+ startNfcScanner(): Promise<void>;
26
+ /**
27
+ * Stops the NFC scanner from listening for NFC events.
28
+ *
29
+ * @returns A promise that resolves when the NFC scanner has stopped listening.
30
+ */
31
+ stopNfcScanner(): Promise<void>;
32
+ private nfcTagScannedEvent;
33
+ }
34
+ type NfcTagResultRecieved = Array<{
35
+ mimeType: string;
36
+ message: string;
37
+ typeFormat: string;
38
+ }>;
39
+ export {};
@@ -0,0 +1,78 @@
1
+ import { EventTargetWithType } from "../../EventTarget";
2
+ import { Startiapp } from "../../startiapp";
3
+ import { Topic } from "./Topic";
4
+ export declare class PushNotification extends EventTargetWithType<{
5
+ tokenRefreshed: CustomEvent<string>;
6
+ notificationReceived: CustomEvent<{
7
+ title: string;
8
+ body: string;
9
+ }>;
10
+ }> {
11
+ private readonly startiapp;
12
+ private pushNotificationIntegration;
13
+ constructor(startiapp: Startiapp);
14
+ /**
15
+ * This method returns the token which should be used to send push notifications.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const fcmToken = await pushNotification.getToken();
20
+ * console.log(fcmToken);
21
+ * ```
22
+ */
23
+ getToken(): Promise<string>;
24
+ /**
25
+ * This method requests access to send push notifications to the user.
26
+ *
27
+ * @returns Boolean indicating whether the request was successful
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const granted = await pushNotification.requestAccess();
32
+ * console.log(granted);
33
+ * ```
34
+ */
35
+ requestAccess(): Promise<boolean>;
36
+ /**
37
+ * Sets the badge count for the app.
38
+ *
39
+ * @param count - The number to set as the badge count.
40
+ */
41
+ setBadgeCount(count: number): void;
42
+ /**
43
+ * Retrieves the topics for push notifications.
44
+ *
45
+ * @returns An array of Topic objects representing the available topics.
46
+ * @throws Error if the request to get topics fails.
47
+ */
48
+ getTopics(): Promise<Topic[]>;
49
+ /**
50
+ * This method subscribes to a list of topics.
51
+ *
52
+ * @param topics List of topics to subscribe to
53
+ * @param shouldCheckAccess Boolean indicating whether to check for push notification permissions
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * await pushNotification.subscribeToTopics(["topic1", "topic2"]);
58
+ * ```
59
+ */
60
+ subscribeToTopics(topics: string[], shouldCheckAccess?: boolean): Promise<void>;
61
+ /**
62
+ * This method unsubscribes to a list of topics.
63
+ *
64
+ * @param topics List of topics to unsubscribe from
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * await pushNotification.unsubscribeFromTopics(["topic1", "topic2"]);
69
+ * ```
70
+ */
71
+ unsubscribeFromTopics(topics: string[]): Promise<void>;
72
+ private subscribeToAllTopicAsync;
73
+ private updateSubscribedStatusAsync;
74
+ private updateSubscribedTopics;
75
+ private getSubscribedTopics;
76
+ private onTokenReceived;
77
+ private onNotificationReceived;
78
+ }
@@ -0,0 +1,15 @@
1
+ import { StartiappClass } from "../../startiapp";
2
+ export declare class Topic {
3
+ topic: string;
4
+ name: string;
5
+ subscribed: boolean;
6
+ private startiapp;
7
+ constructor(topic: string, name: string, subscribed: boolean, startiapp: StartiappClass);
8
+ toJSON(): {
9
+ topic: string;
10
+ name: string;
11
+ subscribed: boolean;
12
+ };
13
+ subscribe(): void;
14
+ unsubscribe(): void;
15
+ }
@@ -0,0 +1,34 @@
1
+ import { Startiapp } from "../../startiapp";
2
+ export declare class QrScanner extends EventTarget {
3
+ private readonly startiapp;
4
+ private qrIntegration;
5
+ constructor(startiapp: Startiapp);
6
+ /**
7
+ * Starts the QR code scanner.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * await qrScanner.scan();
12
+ * ```
13
+ */
14
+ scan(): Promise<void>;
15
+ /**
16
+ * Check if camera access is granted.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const isGranted = await qrScanner.isCameraAccessGranted();
21
+ * console.log(isGranted);
22
+ * ```
23
+ */
24
+ isCameraAccessGranted(): Promise<boolean>;
25
+ /**
26
+ * Requests the camera access.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * await qrScanner.requestCameraAccess();
31
+ * ```
32
+ */
33
+ requestCameraAccess(): Promise<boolean>;
34
+ }