@webority/mobile-core 0.0.26 → 0.0.28
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.
- package/README.md +69 -1
- package/lib/commonjs/api/retry.js +17 -1
- package/lib/commonjs/api/userClient.js +1 -1
- package/lib/commonjs/auth/authStore.js +49 -16
- package/lib/commonjs/config/index.js +8 -2
- package/lib/commonjs/formatters/currency.js +2 -1
- package/lib/commonjs/formatters/date.js +5 -6
- package/lib/commonjs/formatters/dateMath.js +2 -1
- package/lib/commonjs/formatters/intlCache.js +37 -0
- package/lib/commonjs/formatters/number.js +4 -3
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/initSDK.js +1 -1
- package/lib/commonjs/network/networkStatus.js +40 -2
- package/lib/commonjs/push/index.js +18 -0
- package/lib/commonjs/push/push.js +177 -15
- package/lib/commonjs/push/task.js +43 -0
- package/lib/commonjs/utils/base64.js +24 -0
- package/lib/module/api/retry.js +17 -1
- package/lib/module/api/userClient.js +2 -2
- package/lib/module/auth/authStore.js +49 -16
- package/lib/module/config/index.js +7 -1
- package/lib/module/formatters/currency.js +2 -1
- package/lib/module/formatters/date.js +5 -6
- package/lib/module/formatters/dateMath.js +2 -1
- package/lib/module/formatters/intlCache.js +30 -0
- package/lib/module/formatters/number.js +4 -3
- package/lib/module/index.js +2 -0
- package/lib/module/initSDK.js +2 -2
- package/lib/module/network/networkStatus.js +37 -0
- package/lib/module/push/index.js +1 -1
- package/lib/module/push/push.js +170 -15
- package/lib/module/push/task.js +38 -0
- package/lib/module/utils/base64.js +19 -0
- package/lib/typescript/commonjs/config/index.d.ts +6 -0
- package/lib/typescript/commonjs/formatters/intlCache.d.ts +6 -0
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/initSDK.d.ts +1 -1
- package/lib/typescript/commonjs/network/networkStatus.d.ts +6 -0
- package/lib/typescript/commonjs/push/index.d.ts +2 -2
- package/lib/typescript/commonjs/push/push.d.ts +88 -0
- package/lib/typescript/commonjs/push/task.d.ts +15 -0
- package/lib/typescript/commonjs/utils/base64.d.ts +7 -0
- package/lib/typescript/module/config/index.d.ts +6 -0
- package/lib/typescript/module/formatters/intlCache.d.ts +6 -0
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/initSDK.d.ts +1 -1
- package/lib/typescript/module/network/networkStatus.d.ts +6 -0
- package/lib/typescript/module/push/index.d.ts +2 -2
- package/lib/typescript/module/push/push.d.ts +88 -0
- package/lib/typescript/module/push/task.d.ts +15 -0
- package/lib/typescript/module/utils/base64.d.ts +7 -0
- package/package.json +15 -1
|
@@ -26,6 +26,42 @@ export interface PushConfig {
|
|
|
26
26
|
/** Whether a notification shown while the app is open plays its sound. Defaults to true. */
|
|
27
27
|
playSoundInForeground?: () => boolean;
|
|
28
28
|
}
|
|
29
|
+
/** A button on a notification category. */
|
|
30
|
+
export interface PushCategoryAction {
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
/** Whether the tap brings the app to the foreground. Defaults to true. */
|
|
34
|
+
opensApp?: boolean;
|
|
35
|
+
/** iOS only: the title shows in red. */
|
|
36
|
+
destructive?: boolean;
|
|
37
|
+
/** Turns the button into a reply box; the text arrives as `userText`. */
|
|
38
|
+
textInput?: {
|
|
39
|
+
submitTitle: string;
|
|
40
|
+
placeholder: string;
|
|
41
|
+
};
|
|
42
|
+
/** iOS only: the phone must be unlocked before the action runs. */
|
|
43
|
+
authenticationRequired?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** A set of buttons a push names through its category id. */
|
|
46
|
+
export interface PushCategory {
|
|
47
|
+
id: string;
|
|
48
|
+
actions: PushCategoryAction[];
|
|
49
|
+
}
|
|
50
|
+
/** A button tap on a notification. */
|
|
51
|
+
export interface PushAction {
|
|
52
|
+
actionId: string;
|
|
53
|
+
/** What the person typed, for a `textInput` action. */
|
|
54
|
+
userText?: string;
|
|
55
|
+
data: Record<string, string>;
|
|
56
|
+
/** The notification's identifier on the phone, not a server id in `data`. */
|
|
57
|
+
notificationId: string;
|
|
58
|
+
}
|
|
59
|
+
export type PushActionHandler = (action: PushAction) => Promise<void> | void;
|
|
60
|
+
export interface PushLocalNotification {
|
|
61
|
+
title: string;
|
|
62
|
+
body: string;
|
|
63
|
+
data?: Record<string, string>;
|
|
64
|
+
}
|
|
29
65
|
export type PushStatus = 'unknown' | 'granted' | 'denied' | 'unavailable';
|
|
30
66
|
export interface PushState {
|
|
31
67
|
status: PushStatus;
|
|
@@ -41,15 +77,31 @@ interface SubscriptionLike {
|
|
|
41
77
|
}
|
|
42
78
|
interface NotificationResponseLike {
|
|
43
79
|
actionIdentifier: string;
|
|
80
|
+
userText?: string;
|
|
44
81
|
notification: {
|
|
45
82
|
request: {
|
|
46
83
|
identifier: string;
|
|
84
|
+
/** A background task receives the raw content, where data may still be a JSON `dataString`. */
|
|
47
85
|
content: {
|
|
48
86
|
data?: Record<string, unknown> | null;
|
|
87
|
+
dataString?: string;
|
|
49
88
|
};
|
|
50
89
|
};
|
|
51
90
|
};
|
|
52
91
|
}
|
|
92
|
+
interface NotificationActionLike {
|
|
93
|
+
identifier: string;
|
|
94
|
+
buttonTitle: string;
|
|
95
|
+
textInput?: {
|
|
96
|
+
submitButtonTitle: string;
|
|
97
|
+
placeholder: string;
|
|
98
|
+
};
|
|
99
|
+
options: {
|
|
100
|
+
opensAppToForeground: boolean;
|
|
101
|
+
isDestructive: boolean;
|
|
102
|
+
isAuthenticationRequired: boolean;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
53
105
|
interface DevicePushTokenLike {
|
|
54
106
|
type: string;
|
|
55
107
|
data: unknown;
|
|
@@ -76,10 +128,22 @@ export interface PushNotificationsLike {
|
|
|
76
128
|
importance: number;
|
|
77
129
|
}) => Promise<unknown>;
|
|
78
130
|
setBadgeCountAsync: (count: number) => Promise<boolean>;
|
|
131
|
+
setNotificationCategoryAsync: (identifier: string, actions: NotificationActionLike[]) => Promise<unknown>;
|
|
132
|
+
scheduleNotificationAsync: (request: {
|
|
133
|
+
content: {
|
|
134
|
+
title: string;
|
|
135
|
+
body: string;
|
|
136
|
+
data: Record<string, string>;
|
|
137
|
+
};
|
|
138
|
+
trigger: null;
|
|
139
|
+
}) => Promise<string>;
|
|
140
|
+
registerTaskAsync: (taskName: string) => Promise<unknown>;
|
|
79
141
|
AndroidImportance: {
|
|
80
142
|
DEFAULT: number;
|
|
81
143
|
HIGH: number;
|
|
82
144
|
};
|
|
145
|
+
/** The `actionIdentifier` of a plain tap on the notification body. */
|
|
146
|
+
DEFAULT_ACTION_IDENTIFIER: string;
|
|
83
147
|
}
|
|
84
148
|
export interface PushModules {
|
|
85
149
|
notifications: PushNotificationsLike;
|
|
@@ -92,6 +156,16 @@ export interface PushModules {
|
|
|
92
156
|
* included. Pass `null` to restore expo-notifications.
|
|
93
157
|
*/
|
|
94
158
|
export declare const setPushImplementation: (impl: PushModules | null) => void;
|
|
159
|
+
/**
|
|
160
|
+
* The only place expo-notifications and expo-application are named. Expo Go is
|
|
161
|
+
* checked first because expo-notifications refuses remote push there and its
|
|
162
|
+
* import throws on Android. Exported for `./task`; not on the `/push` entry.
|
|
163
|
+
*/
|
|
164
|
+
export declare const resolveModules: () => PushModules | null;
|
|
165
|
+
export declare const toPushAction: (response: NotificationResponseLike) => PushAction;
|
|
166
|
+
export declare const toNotificationActions: (actions: PushCategoryAction[]) => NotificationActionLike[];
|
|
167
|
+
/** The payload of the background notification task: routes button taps, ignores received pushes. */
|
|
168
|
+
export declare const routeTaskPayload: (payload: unknown) => Promise<void>;
|
|
95
169
|
/**
|
|
96
170
|
* Wires push at startup: the foreground handler, Android channels, and tap
|
|
97
171
|
* handling, including the tap that launched the app. Calling it again only
|
|
@@ -110,6 +184,20 @@ export declare const enablePush: () => Promise<"granted" | "denied" | "unavailab
|
|
|
110
184
|
export declare const disablePush: () => Promise<void>;
|
|
111
185
|
/** Sets the app icon badge; a no-op where push is unavailable or the launcher has no badge. */
|
|
112
186
|
export declare const setBadgeCount: (count: number) => Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Registers the button sets a push can name by category id. Call it at every
|
|
189
|
+
* start, with the same ids on both platforms. On Android the buttons show only
|
|
190
|
+
* on notifications expo-notifications draws, such as `notifyLocal`.
|
|
191
|
+
*/
|
|
192
|
+
export declare const setCategories: (categories: PushCategory[]) => Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Handles button taps while JavaScript is running; a plain tap still goes to
|
|
195
|
+
* `onOpen`. For taps on a killed app use `definePushActionTask` from
|
|
196
|
+
* `/push/task`, which sets this handler too. Returns a function that removes it.
|
|
197
|
+
*/
|
|
198
|
+
export declare const onAction: (handler: PushActionHandler) => (() => void);
|
|
199
|
+
/** Shows a notification from the phone itself, for example when a button's request failed. */
|
|
200
|
+
export declare const notifyLocal: ({ title, body, data }: PushLocalNotification) => Promise<void>;
|
|
113
201
|
/** Push status for a settings switch, re-rendering when it changes. */
|
|
114
202
|
export declare const usePush: () => PushState & {
|
|
115
203
|
enable: () => Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PushActionHandler } from './push.js';
|
|
2
|
+
export type { PushAction, PushActionHandler } from './push.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handles notification button taps in every app state, the killed app
|
|
5
|
+
* included. Call it once at module scope in the app's entry file (index.js),
|
|
6
|
+
* before the root component registers: a tap on a killed app starts the
|
|
7
|
+
* JavaScript bundle without the UI, so nothing later in the app runs.
|
|
8
|
+
*
|
|
9
|
+
* Android runs the handler from a background notification task
|
|
10
|
+
* (expo-task-manager). iOS has no such task for button taps: it launches the
|
|
11
|
+
* app in the background and the response reaches the listener this sets up.
|
|
12
|
+
* The handler's promise is awaited, so a request it makes can finish first.
|
|
13
|
+
*/
|
|
14
|
+
export declare const definePushActionTask: (handler: PushActionHandler) => void;
|
|
15
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64 of raw bytes, for a `data:` URI. Builds a Latin-1 string a chunk at a
|
|
3
|
+
* time and hands it to the engine's native `btoa` (Hermes ships it), which is
|
|
4
|
+
* many times faster on the JS thread than encoding byte by byte in JS.
|
|
5
|
+
*/
|
|
6
|
+
export declare const encodeBase64: (buffer: ArrayBuffer) => string;
|
|
7
|
+
//# sourceMappingURL=base64.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -171,6 +171,16 @@
|
|
|
171
171
|
"default": "./lib/commonjs/push/index.js"
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
|
+
"./push/task": {
|
|
175
|
+
"import": {
|
|
176
|
+
"types": "./lib/typescript/module/push/task.d.ts",
|
|
177
|
+
"default": "./lib/module/push/task.js"
|
|
178
|
+
},
|
|
179
|
+
"require": {
|
|
180
|
+
"types": "./lib/typescript/commonjs/push/task.d.ts",
|
|
181
|
+
"default": "./lib/commonjs/push/task.js"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
174
184
|
"./smsRetriever": {
|
|
175
185
|
"import": {
|
|
176
186
|
"types": "./lib/typescript/module/smsRetriever/index.d.ts",
|
|
@@ -242,6 +252,7 @@
|
|
|
242
252
|
"expo-secure-store": ">=57.0.0",
|
|
243
253
|
"expo-sharing": ">=57.0.0",
|
|
244
254
|
"expo-sqlite": ">=57.0.0",
|
|
255
|
+
"expo-task-manager": ">=57.0.0",
|
|
245
256
|
"react": "^19.1.0",
|
|
246
257
|
"react-native": ">=0.81.0"
|
|
247
258
|
},
|
|
@@ -275,6 +286,9 @@
|
|
|
275
286
|
},
|
|
276
287
|
"expo-sharing": {
|
|
277
288
|
"optional": true
|
|
289
|
+
},
|
|
290
|
+
"expo-task-manager": {
|
|
291
|
+
"optional": true
|
|
278
292
|
}
|
|
279
293
|
},
|
|
280
294
|
"publishConfig": {
|