appsonair-react-native-apppush 0.0.1-alpha
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/LICENSE +21 -0
- package/README.md +540 -0
- package/android/build.gradle +177 -0
- package/android/gradle.properties +15 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModuleImpl.kt +767 -0
- package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushPackage.kt +43 -0
- package/android/src/newarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +199 -0
- package/android/src/oldarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +249 -0
- package/appsonair-react-native-apppush.podspec +77 -0
- package/ios/AppsonairReactNativeApppush-Bridging-Header.h +12 -0
- package/ios/AppsonairReactNativeApppush.h +28 -0
- package/ios/AppsonairReactNativeApppush.mm +494 -0
- package/ios/AppsonairReactNativeApppushImpl.swift +594 -0
- package/lib/commonjs/NativeAppsonairApppush.js +48 -0
- package/lib/commonjs/NativeAppsonairApppush.js.map +1 -0
- package/lib/commonjs/index.js +686 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/NativeAppsonairApppush.js +47 -0
- package/lib/module/NativeAppsonairApppush.js.map +1 -0
- package/lib/module/index.js +612 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts +134 -0
- package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +392 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +221 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeAppsonairApppush.d.ts +134 -0
- package/lib/typescript/module/src/NativeAppsonairApppush.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +392 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +221 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +119 -0
- package/react-native.config.js +14 -0
- package/src/NativeAppsonairApppush.ts +188 -0
- package/src/index.tsx +745 -0
- package/src/types.ts +284 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import type { InstallationIdEvent, LogLevel, NotificationOpenedEvent, NotificationReceivedEvent, NotificationWillDisplayEvent, PermissionChangedEvent, PermissionStatus, PushConfig, PushErrorEvent, PushSubscriptionChangedEvent, PushSubscriptionState, RequestPermissionOptions, SilentNotificationEvent, Subscription, TokenUpdatedEvent, UserStateChangedEvent } from './types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Starts the SDK. Await this once, before any other call.
|
|
5
|
+
*
|
|
6
|
+
* On Android the wrapper supplies the `Context` itself; on iOS it resolves the
|
|
7
|
+
* App Group and enables AppDelegate swizzling. Neither detail is exposed here.
|
|
8
|
+
*/
|
|
9
|
+
export declare function initialize(config?: PushConfig): Promise<void>;
|
|
10
|
+
/** Whether {@link initialize} has completed in this JS context. */
|
|
11
|
+
export declare function isInitialized(): boolean;
|
|
12
|
+
/** The AppsOnAir-assigned device id. */
|
|
13
|
+
export declare function getDeviceId(): Promise<string>;
|
|
14
|
+
/** The backend-assigned subscription id. `null` until the device registers. */
|
|
15
|
+
export declare function getSubscriptionId(): Promise<string | null>;
|
|
16
|
+
/** The external id linked via {@link login}. `null` while anonymous. */
|
|
17
|
+
export declare function getExternalId(): Promise<string | null>;
|
|
18
|
+
/** Associates this device with your own user id. */
|
|
19
|
+
export declare function login(externalId: string): Promise<void>;
|
|
20
|
+
/** Unlinks the external id, returning the device to an anonymous subscription. */
|
|
21
|
+
export declare function logout(): Promise<void>;
|
|
22
|
+
/** Alias of {@link login}, for teams that prefer the noun. */
|
|
23
|
+
export declare const setUserId: typeof login;
|
|
24
|
+
/** APNs hex token on iOS, FCM token on Android. `null` before registration. */
|
|
25
|
+
export declare function getToken(): Promise<string | null>;
|
|
26
|
+
/** Alias of {@link getToken}. */
|
|
27
|
+
export declare const getDeviceToken: typeof getToken;
|
|
28
|
+
/**
|
|
29
|
+
* Prompts for notification permission and resolves the resulting grant state.
|
|
30
|
+
*
|
|
31
|
+
* Parity E1: Android needs a live Activity. The bridge resolves the current one
|
|
32
|
+
* and rejects if none is attached rather than crashing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function requestPermission(options?: RequestPermissionOptions): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Whether notifications are currently permitted.
|
|
37
|
+
*
|
|
38
|
+
* Parity E3/E4/E6: iOS reads a cache and Android reads live, so the iOS bridge
|
|
39
|
+
* refreshes first. The two native shapes (`async` vs sync, `permission` vs
|
|
40
|
+
* `isPermissionGranted`) are collapsed into this one promise.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getPermission(): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* The granular permission state.
|
|
45
|
+
*
|
|
46
|
+
* Parity C7: iOS reports all five values. **Android reports only `authorized`
|
|
47
|
+
* or `denied`** — it never returns `notDetermined`, so do not gate a
|
|
48
|
+
* cross-platform pre-prompt on that value.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPermissionStatus(): Promise<PermissionStatus>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a permission prompt can still be shown.
|
|
53
|
+
*
|
|
54
|
+
* Parity E2 — **known divergence, not yet fixed in the native SDKs.** iOS
|
|
55
|
+
* returns `true` only before the user has ever been asked. Android returns
|
|
56
|
+
* `true` whenever permission is not granted, *including after a permanent
|
|
57
|
+
* denial*. Treat a `true` on Android as "not granted", not as "never asked".
|
|
58
|
+
*/
|
|
59
|
+
export declare function canRequestPermission(): Promise<boolean>;
|
|
60
|
+
/** Quiet iOS 12+ provisional authorization. **iOS only** — a no-op on Android. */
|
|
61
|
+
export declare function registerForProvisionalAuthorization(): Promise<void>;
|
|
62
|
+
export declare const notifications: {
|
|
63
|
+
/** Dismisses every notification this app has posted. */
|
|
64
|
+
clearAll(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Dismisses one notification by its payload `notification_id`.
|
|
67
|
+
*
|
|
68
|
+
* Parity F2: on Android the id is hashed to find the posted notification, so
|
|
69
|
+
* two ids that hash alike could collide. iOS matches the request identifier
|
|
70
|
+
* exactly.
|
|
71
|
+
*/
|
|
72
|
+
remove(notificationId: string): Promise<void>;
|
|
73
|
+
/** Dismisses several notifications. Android loops; iOS removes them in one call. */
|
|
74
|
+
removeMany(notificationIds: string[]): Promise<void>;
|
|
75
|
+
/** Dismisses a notification group. **Android only** — a no-op on iOS. */
|
|
76
|
+
removeGroup(groupKey: string): Promise<void>;
|
|
77
|
+
};
|
|
78
|
+
export declare const badge: {
|
|
79
|
+
/**
|
|
80
|
+
* The SDK's badge count.
|
|
81
|
+
*
|
|
82
|
+
* Parity G1/G3: iOS reads the OS badge. Android has no OS read API, so this
|
|
83
|
+
* returns the SDK's own persisted value, which can drift from what the
|
|
84
|
+
* launcher actually shows.
|
|
85
|
+
*/
|
|
86
|
+
get(): Promise<number>;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the badge count.
|
|
89
|
+
*
|
|
90
|
+
* Parity G3: reliable on iOS. On Android this is a best-effort launcher
|
|
91
|
+
* broadcast that silently does nothing outside Samsung / MIUI / ASUS — which
|
|
92
|
+
* is why nothing here reports success.
|
|
93
|
+
*/
|
|
94
|
+
set(count: number): Promise<void>;
|
|
95
|
+
/** Adds `delta` to the badge and resolves the new value, clamped at 0. */
|
|
96
|
+
increment(delta?: number): Promise<number>;
|
|
97
|
+
/** Clears the badge. */
|
|
98
|
+
clear(): Promise<void>;
|
|
99
|
+
/** Clears the badge whenever the app foregrounds. **iOS only.** */
|
|
100
|
+
setAutoClearOnForeground(enabled: boolean): Promise<void>;
|
|
101
|
+
};
|
|
102
|
+
export declare const user: {
|
|
103
|
+
/** The AppsOnAir device id. */
|
|
104
|
+
getAppsOnAirId(): Promise<string>;
|
|
105
|
+
getExternalId: typeof getExternalId;
|
|
106
|
+
addTag(key: string, value: string): Promise<void>;
|
|
107
|
+
addTags(tags: Record<string, string>): Promise<void>;
|
|
108
|
+
removeTag(key: string): Promise<void>;
|
|
109
|
+
removeTags(keys: string[]): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* The user's tags.
|
|
112
|
+
*
|
|
113
|
+
* **Android round-trips to the backend** once the device has a
|
|
114
|
+
* `subscriptionId`, replacing its local cache with the result; before
|
|
115
|
+
* registration it resolves the local cache without a network call. **iOS reads
|
|
116
|
+
* its local cache only.** So a tag set on another device shows up on Android
|
|
117
|
+
* and not on iOS, and the Android call can reject on a network failure where
|
|
118
|
+
* iOS cannot.
|
|
119
|
+
*/
|
|
120
|
+
getTags(): Promise<Record<string, string>>;
|
|
121
|
+
addAlias(label: string, id: string): Promise<void>;
|
|
122
|
+
addAliases(aliases: Record<string, string>): Promise<void>;
|
|
123
|
+
removeAlias(label: string): Promise<void>;
|
|
124
|
+
removeAliases(labels: string[]): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Adds an email identifier.
|
|
127
|
+
*
|
|
128
|
+
* Parity A5 — **known Android bug.** Android persists emails but never reads
|
|
129
|
+
* them back on restart, so an email added here silently vanishes when the app
|
|
130
|
+
* relaunches. The wrapper cannot work around it; it needs an SDK fix.
|
|
131
|
+
*/
|
|
132
|
+
addEmail(address: string): Promise<void>;
|
|
133
|
+
removeEmail(address: string): Promise<void>;
|
|
134
|
+
setLanguage(languageCode: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* The device language.
|
|
137
|
+
*
|
|
138
|
+
* Parity 1.5 — Android reads this live; iOS snapshots it once at init and
|
|
139
|
+
* never refreshes, so a mid-session language change is stale on iOS.
|
|
140
|
+
*/
|
|
141
|
+
getLanguage(): Promise<string>;
|
|
142
|
+
/** The current push subscription: `{ id, token, optedIn }`. */
|
|
143
|
+
getPushSubscription(): Promise<PushSubscriptionState>;
|
|
144
|
+
/** Opts this device back in to push delivery. */
|
|
145
|
+
optIn(): Promise<void>;
|
|
146
|
+
/** Opts this device out of push delivery without unregistering the token. */
|
|
147
|
+
optOut(): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* The subscription's enabled state as the backend sees it.
|
|
150
|
+
*
|
|
151
|
+
* Distinct from `getPushSubscription().optedIn`, which is the purely local
|
|
152
|
+
* `!optedOut` flag on both platforms. The two derive it differently and
|
|
153
|
+
* converge only in steady state:
|
|
154
|
+
*
|
|
155
|
+
* - **Android** reads it back from `/subscriptions`, so it reflects what the
|
|
156
|
+
* server actually stored. Before the device registers it falls back to the
|
|
157
|
+
* local value without a network call.
|
|
158
|
+
* - **iOS** computes the same flag it would send: an APNs token exists, the
|
|
159
|
+
* user has not opted out, *and* the OS currently grants permission. So
|
|
160
|
+
* revoking permission in Settings flips this to `false` on iOS while
|
|
161
|
+
* Android keeps reporting the server's stored value.
|
|
162
|
+
*/
|
|
163
|
+
getOptedIn(): Promise<boolean>;
|
|
164
|
+
};
|
|
165
|
+
export declare const consent: {
|
|
166
|
+
setRequired(required: boolean): Promise<void>;
|
|
167
|
+
getRequired(): Promise<boolean>;
|
|
168
|
+
setGiven(given: boolean): Promise<void>;
|
|
169
|
+
getGiven(): Promise<boolean>;
|
|
170
|
+
};
|
|
171
|
+
export declare const debug: {
|
|
172
|
+
/** Sets SDK log verbosity. Safe to call before {@link initialize}. */
|
|
173
|
+
setLogLevel(level: LogLevel): Promise<void>;
|
|
174
|
+
};
|
|
175
|
+
/** Fires when a notification arrives while the app is in the foreground. */
|
|
176
|
+
export declare function onNotificationReceived(callback: (event: NotificationReceivedEvent) => void): Subscription;
|
|
177
|
+
/** Fires when the user taps a notification or one of its action buttons. */
|
|
178
|
+
export declare function onNotificationOpened(callback: (event: NotificationOpenedEvent) => void): Subscription;
|
|
179
|
+
/**
|
|
180
|
+
* Fires in the foreground *before* the notification is displayed, giving you a
|
|
181
|
+
* chance to suppress it.
|
|
182
|
+
*
|
|
183
|
+
* `preventDefault()` must be called synchronously inside the handler — the
|
|
184
|
+
* native side is holding the notification until this returns, and releases it
|
|
185
|
+
* anyway after a short timeout so a throwing handler cannot wedge delivery.
|
|
186
|
+
*
|
|
187
|
+
* All registered handlers run; the notification is suppressed if *any* of them
|
|
188
|
+
* calls `preventDefault()`.
|
|
189
|
+
*
|
|
190
|
+
* **`preventDefault()` is honoured on Android only.** iOS decides presentation
|
|
191
|
+
* synchronously and cannot wait for a JS answer — see
|
|
192
|
+
* {@link NotificationWillDisplayEvent.preventDefault}. The event itself fires on
|
|
193
|
+
* both platforms.
|
|
194
|
+
*/
|
|
195
|
+
export declare function onNotificationWillDisplay(callback: (event: NotificationWillDisplayEvent) => void): Subscription;
|
|
196
|
+
/** Fires when the OS notification permission changes. */
|
|
197
|
+
export declare function onPermissionChanged(callback: (event: PermissionChangedEvent) => void): Subscription;
|
|
198
|
+
/** Fires when the push subscription's token or opt-in state changes. */
|
|
199
|
+
export declare function onSubscriptionChanged(callback: (event: PushSubscriptionChangedEvent) => void): Subscription;
|
|
200
|
+
/** Fires on {@link login} / {@link logout}. */
|
|
201
|
+
export declare function onUserStateChanged(callback: (event: UserStateChangedEvent) => void): Subscription;
|
|
202
|
+
/**
|
|
203
|
+
* Fires when the device registration token is issued or refreshed.
|
|
204
|
+
*
|
|
205
|
+
* This is the push-side counterpart to {@link getToken}: the getter answers
|
|
206
|
+
* "what is the token now", this answers "the token just changed" — which is when
|
|
207
|
+
* your backend needs to hear about it. A token can rotate at any point in a
|
|
208
|
+
* session, so a one-shot `getToken()` at startup will eventually go stale.
|
|
209
|
+
*
|
|
210
|
+
* `environment` is the APNs endpoint the backend must send to. It is
|
|
211
|
+
* `'sandbox'` or `'production'` on iOS and always `null` on Android, where FCM
|
|
212
|
+
* routes for you.
|
|
213
|
+
*
|
|
214
|
+
* Events raised before the first subscriber exists are dropped rather than
|
|
215
|
+
* queued on both platforms, so read {@link getToken} once after subscribing if
|
|
216
|
+
* you need the current value too.
|
|
217
|
+
*/
|
|
218
|
+
export declare function onTokenUpdated(callback: (event: TokenUpdatedEvent) => void): Subscription;
|
|
219
|
+
/**
|
|
220
|
+
* Fires on an SDK-level failure — token registration, a denied permission, a
|
|
221
|
+
* missing Firebase config.
|
|
222
|
+
*
|
|
223
|
+
* These are conditions the SDK hits on its own schedule, outside any call you
|
|
224
|
+
* made, so they surface here rather than as a rejected promise. A promise
|
|
225
|
+
* rejection from a method you called carries the same `code` values.
|
|
226
|
+
*
|
|
227
|
+
* Without a subscriber these failures are silent, which is why this is worth
|
|
228
|
+
* wiring even if it only ever logs.
|
|
229
|
+
*/
|
|
230
|
+
export declare function onError(callback: (event: PushErrorEvent) => void): Subscription;
|
|
231
|
+
/**
|
|
232
|
+
* Fires for a data-only push that is delivered without being displayed.
|
|
233
|
+
*
|
|
234
|
+
* Supported on both platforms, but they are triggered differently and your
|
|
235
|
+
* backend has to send for both: iOS uses the APNs `content-available` flag,
|
|
236
|
+
* while Android keys off a `silent: "true"` data entry, since FCM has no
|
|
237
|
+
* transport-level equivalent. See {@link SilentNotificationEvent}.
|
|
238
|
+
*
|
|
239
|
+
* iOS invokes the OS completion handler as soon as this event is emitted, so
|
|
240
|
+
* the handler cannot extend the app's background execution window: treat it as
|
|
241
|
+
* a notification that the payload arrived, not as a place to await work.
|
|
242
|
+
*/
|
|
243
|
+
export declare function onSilentNotification(callback: (event: SilentNotificationEvent) => void): Subscription;
|
|
244
|
+
/**
|
|
245
|
+
* Fires when the Firebase Installation ID becomes available.
|
|
246
|
+
*
|
|
247
|
+
* **Android only** — the event name is registered on iOS so the two bridges
|
|
248
|
+
* stay diffable, but nothing ever emits it there.
|
|
249
|
+
*/
|
|
250
|
+
export declare function onInstallationIdUpdated(callback: (event: InstallationIdEvent) => void): Subscription;
|
|
251
|
+
declare const AppPushService: {
|
|
252
|
+
initialize: typeof initialize;
|
|
253
|
+
isInitialized: typeof isInitialized;
|
|
254
|
+
getDeviceId: typeof getDeviceId;
|
|
255
|
+
getSubscriptionId: typeof getSubscriptionId;
|
|
256
|
+
getExternalId: typeof getExternalId;
|
|
257
|
+
login: typeof login;
|
|
258
|
+
logout: typeof logout;
|
|
259
|
+
setUserId: typeof login;
|
|
260
|
+
getToken: typeof getToken;
|
|
261
|
+
getDeviceToken: typeof getToken;
|
|
262
|
+
requestPermission: typeof requestPermission;
|
|
263
|
+
getPermission: typeof getPermission;
|
|
264
|
+
getPermissionStatus: typeof getPermissionStatus;
|
|
265
|
+
canRequestPermission: typeof canRequestPermission;
|
|
266
|
+
registerForProvisionalAuthorization: typeof registerForProvisionalAuthorization;
|
|
267
|
+
notifications: {
|
|
268
|
+
/** Dismisses every notification this app has posted. */
|
|
269
|
+
clearAll(): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Dismisses one notification by its payload `notification_id`.
|
|
272
|
+
*
|
|
273
|
+
* Parity F2: on Android the id is hashed to find the posted notification, so
|
|
274
|
+
* two ids that hash alike could collide. iOS matches the request identifier
|
|
275
|
+
* exactly.
|
|
276
|
+
*/
|
|
277
|
+
remove(notificationId: string): Promise<void>;
|
|
278
|
+
/** Dismisses several notifications. Android loops; iOS removes them in one call. */
|
|
279
|
+
removeMany(notificationIds: string[]): Promise<void>;
|
|
280
|
+
/** Dismisses a notification group. **Android only** — a no-op on iOS. */
|
|
281
|
+
removeGroup(groupKey: string): Promise<void>;
|
|
282
|
+
};
|
|
283
|
+
badge: {
|
|
284
|
+
/**
|
|
285
|
+
* The SDK's badge count.
|
|
286
|
+
*
|
|
287
|
+
* Parity G1/G3: iOS reads the OS badge. Android has no OS read API, so this
|
|
288
|
+
* returns the SDK's own persisted value, which can drift from what the
|
|
289
|
+
* launcher actually shows.
|
|
290
|
+
*/
|
|
291
|
+
get(): Promise<number>;
|
|
292
|
+
/**
|
|
293
|
+
* Sets the badge count.
|
|
294
|
+
*
|
|
295
|
+
* Parity G3: reliable on iOS. On Android this is a best-effort launcher
|
|
296
|
+
* broadcast that silently does nothing outside Samsung / MIUI / ASUS — which
|
|
297
|
+
* is why nothing here reports success.
|
|
298
|
+
*/
|
|
299
|
+
set(count: number): Promise<void>;
|
|
300
|
+
/** Adds `delta` to the badge and resolves the new value, clamped at 0. */
|
|
301
|
+
increment(delta?: number): Promise<number>;
|
|
302
|
+
/** Clears the badge. */
|
|
303
|
+
clear(): Promise<void>;
|
|
304
|
+
/** Clears the badge whenever the app foregrounds. **iOS only.** */
|
|
305
|
+
setAutoClearOnForeground(enabled: boolean): Promise<void>;
|
|
306
|
+
};
|
|
307
|
+
user: {
|
|
308
|
+
/** The AppsOnAir device id. */
|
|
309
|
+
getAppsOnAirId(): Promise<string>;
|
|
310
|
+
getExternalId: typeof getExternalId;
|
|
311
|
+
addTag(key: string, value: string): Promise<void>;
|
|
312
|
+
addTags(tags: Record<string, string>): Promise<void>;
|
|
313
|
+
removeTag(key: string): Promise<void>;
|
|
314
|
+
removeTags(keys: string[]): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* The user's tags.
|
|
317
|
+
*
|
|
318
|
+
* **Android round-trips to the backend** once the device has a
|
|
319
|
+
* `subscriptionId`, replacing its local cache with the result; before
|
|
320
|
+
* registration it resolves the local cache without a network call. **iOS reads
|
|
321
|
+
* its local cache only.** So a tag set on another device shows up on Android
|
|
322
|
+
* and not on iOS, and the Android call can reject on a network failure where
|
|
323
|
+
* iOS cannot.
|
|
324
|
+
*/
|
|
325
|
+
getTags(): Promise<Record<string, string>>;
|
|
326
|
+
addAlias(label: string, id: string): Promise<void>;
|
|
327
|
+
addAliases(aliases: Record<string, string>): Promise<void>;
|
|
328
|
+
removeAlias(label: string): Promise<void>;
|
|
329
|
+
removeAliases(labels: string[]): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Adds an email identifier.
|
|
332
|
+
*
|
|
333
|
+
* Parity A5 — **known Android bug.** Android persists emails but never reads
|
|
334
|
+
* them back on restart, so an email added here silently vanishes when the app
|
|
335
|
+
* relaunches. The wrapper cannot work around it; it needs an SDK fix.
|
|
336
|
+
*/
|
|
337
|
+
addEmail(address: string): Promise<void>;
|
|
338
|
+
removeEmail(address: string): Promise<void>;
|
|
339
|
+
setLanguage(languageCode: string): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* The device language.
|
|
342
|
+
*
|
|
343
|
+
* Parity 1.5 — Android reads this live; iOS snapshots it once at init and
|
|
344
|
+
* never refreshes, so a mid-session language change is stale on iOS.
|
|
345
|
+
*/
|
|
346
|
+
getLanguage(): Promise<string>;
|
|
347
|
+
/** The current push subscription: `{ id, token, optedIn }`. */
|
|
348
|
+
getPushSubscription(): Promise<PushSubscriptionState>;
|
|
349
|
+
/** Opts this device back in to push delivery. */
|
|
350
|
+
optIn(): Promise<void>;
|
|
351
|
+
/** Opts this device out of push delivery without unregistering the token. */
|
|
352
|
+
optOut(): Promise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* The subscription's enabled state as the backend sees it.
|
|
355
|
+
*
|
|
356
|
+
* Distinct from `getPushSubscription().optedIn`, which is the purely local
|
|
357
|
+
* `!optedOut` flag on both platforms. The two derive it differently and
|
|
358
|
+
* converge only in steady state:
|
|
359
|
+
*
|
|
360
|
+
* - **Android** reads it back from `/subscriptions`, so it reflects what the
|
|
361
|
+
* server actually stored. Before the device registers it falls back to the
|
|
362
|
+
* local value without a network call.
|
|
363
|
+
* - **iOS** computes the same flag it would send: an APNs token exists, the
|
|
364
|
+
* user has not opted out, *and* the OS currently grants permission. So
|
|
365
|
+
* revoking permission in Settings flips this to `false` on iOS while
|
|
366
|
+
* Android keeps reporting the server's stored value.
|
|
367
|
+
*/
|
|
368
|
+
getOptedIn(): Promise<boolean>;
|
|
369
|
+
};
|
|
370
|
+
consent: {
|
|
371
|
+
setRequired(required: boolean): Promise<void>;
|
|
372
|
+
getRequired(): Promise<boolean>;
|
|
373
|
+
setGiven(given: boolean): Promise<void>;
|
|
374
|
+
getGiven(): Promise<boolean>;
|
|
375
|
+
};
|
|
376
|
+
debug: {
|
|
377
|
+
/** Sets SDK log verbosity. Safe to call before {@link initialize}. */
|
|
378
|
+
setLogLevel(level: LogLevel): Promise<void>;
|
|
379
|
+
};
|
|
380
|
+
onNotificationReceived: typeof onNotificationReceived;
|
|
381
|
+
onNotificationOpened: typeof onNotificationOpened;
|
|
382
|
+
onNotificationWillDisplay: typeof onNotificationWillDisplay;
|
|
383
|
+
onPermissionChanged: typeof onPermissionChanged;
|
|
384
|
+
onSubscriptionChanged: typeof onSubscriptionChanged;
|
|
385
|
+
onUserStateChanged: typeof onUserStateChanged;
|
|
386
|
+
onTokenUpdated: typeof onTokenUpdated;
|
|
387
|
+
onError: typeof onError;
|
|
388
|
+
onSilentNotification: typeof onSilentNotification;
|
|
389
|
+
onInstallationIdUpdated: typeof onInstallationIdUpdated;
|
|
390
|
+
};
|
|
391
|
+
export default AppPushService;
|
|
392
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,mBAAmB,EACnB,QAAQ,EACR,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,cAAc,EAEd,4BAA4B,EAC5B,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAqGxB;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC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C;QAI9C;;;;;;WAMG;0BACe,MAAM,GAAG,QAAQ,IAAI,CAAC;6BAKnB,MAAM,GAAG,QAAQ,IAAI,CAAC;kCAKjB,MAAM,GAAG,QAAQ,IAAI,CAAC;QAOhD;;;;;WAKG;uBACY,QAAQ,MAAM,CAAC;QAI9B,+DAA+D;+BACxC,QAAQ,qBAAqB,CAAC;QAMrD,iDAAiD;iBACxC,QAAQ,IAAI,CAAC;QAItB,6EAA6E;kBACnE,QAAQ,IAAI,CAAC;QAIvB;;;;;;;;;;;;;;WAcG;sBACW,QAAQ,OAAO,CAAC;;;8BAYR,OAAO,GAAG,QAAQ,IAAI,CAAC;uBAK9B,QAAQ,OAAO,CAAC;wBAGf,OAAO,GAAG,QAAQ,IAAI,CAAC;oBAG3B,QAAQ,OAAO,CAAC;;;QAQ5B,sEAAsE;2BACnD,QAAQ,GAAG,QAAQ,IAAI,CAAC;;;;;;;;;;;;CA+O5C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform types for the AppsOnAir Push SDK.
|
|
3
|
+
*
|
|
4
|
+
* Where the two native SDKs disagree, this file defines the single shape the
|
|
5
|
+
* wrapper exposes and the native bridges normalise to. Every such decision
|
|
6
|
+
* traces to a row in `appsonair-push-notification-android/CROSS_PLATFORM_PARITY.md`;
|
|
7
|
+
* the row id is cited so the reason survives.
|
|
8
|
+
*/
|
|
9
|
+
export interface PushConfig {
|
|
10
|
+
/** Print SDK logs to the console. Keep `false` in production. */
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* There is deliberately no `appGroupId` option.
|
|
15
|
+
*
|
|
16
|
+
* The parity audit's A1 row proposes one, but the native iOS initializer is
|
|
17
|
+
* `initialize(debug:swizzle:)` — it takes no App Group argument. iOS resolves the
|
|
18
|
+
* group itself, from an `AppsOnAirAppGroup` string in the app's Info.plist, else
|
|
19
|
+
* the convention `group.<bundle-id>.appsonair`. Accepting the value here would be
|
|
20
|
+
* a knob that silently does nothing, so it is configured where it is actually
|
|
21
|
+
* read. See the README's iOS setup section.
|
|
22
|
+
*/
|
|
23
|
+
/** An action button attached to the notification payload. */
|
|
24
|
+
export interface NotificationActionButton {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
/** A media attachment, or one entry synthesised from `imageUrl`. */
|
|
29
|
+
export interface NotificationAttachment {
|
|
30
|
+
id: string | null;
|
|
31
|
+
url: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A received or tapped notification.
|
|
35
|
+
*
|
|
36
|
+
* Parity C1: iOS emits 14 fields, Android 6. This is the union — fields the
|
|
37
|
+
* running platform cannot source resolve to `null` (or `[]`), never `undefined`.
|
|
38
|
+
* The per-field platform notes below are the authoritative support matrix.
|
|
39
|
+
*/
|
|
40
|
+
export interface PushNotification {
|
|
41
|
+
/** Payload `notification_id`. */
|
|
42
|
+
id: string | null;
|
|
43
|
+
/** Payload `campaign_id`. **iOS only** — `null` on Android. */
|
|
44
|
+
campaignId: string | null;
|
|
45
|
+
/** Payload `template_id`. **iOS only** — `null` on Android. */
|
|
46
|
+
templateId: string | null;
|
|
47
|
+
/** Payload `sent_at`, ISO-8601 exactly as received. **iOS only.** */
|
|
48
|
+
sentAt: string | null;
|
|
49
|
+
title: string | null;
|
|
50
|
+
/** Second line above the body. **iOS only** — Android has no subtitle concept. */
|
|
51
|
+
subtitle: string | null;
|
|
52
|
+
body: string | null;
|
|
53
|
+
/** Payload `url` — deep link opened on tap. */
|
|
54
|
+
launchUrl: string | null;
|
|
55
|
+
/** Payload `image_url`. On iOS this loses to `attachments` when both are present. */
|
|
56
|
+
imageUrl: string | null;
|
|
57
|
+
/** Payload `attachments`. **iOS only** — always `[]` on Android. */
|
|
58
|
+
attachments: NotificationAttachment[];
|
|
59
|
+
/** Payload `actions`. Supported on both platforms. */
|
|
60
|
+
actionButtons: NotificationActionButton[];
|
|
61
|
+
/** Payload `badge_increment`. **iOS only** — `null` on Android. */
|
|
62
|
+
badgeIncrement: number | null;
|
|
63
|
+
/** Payload `collapse_id` (iOS) / `collapse_key` (Android). */
|
|
64
|
+
collapseId: string | null;
|
|
65
|
+
/** Sound file name in `res/raw`, no extension. **Android only** — `null` on iOS. */
|
|
66
|
+
sound: string | null;
|
|
67
|
+
/** Notification channel id. **Android only** — `null` on iOS. */
|
|
68
|
+
channelId: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Flattened string map of the payload's custom keys.
|
|
71
|
+
*
|
|
72
|
+
* Parity C1: Android's native `data` map is already `Map<String, String>`;
|
|
73
|
+
* the iOS bridge flattens `userInfo` to match, so this field has the same
|
|
74
|
+
* meaning on both platforms.
|
|
75
|
+
*/
|
|
76
|
+
data: Record<string, string>;
|
|
77
|
+
/**
|
|
78
|
+
* The complete unmodified payload. Shapes differ per platform (APNs `userInfo`
|
|
79
|
+
* vs the FCM data bundle) — reach for `data` first, and use this only for keys
|
|
80
|
+
* that survive neither flattening nor the typed fields above.
|
|
81
|
+
*/
|
|
82
|
+
rawPayload: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
export interface TokenUpdatedEvent {
|
|
85
|
+
/** APNs hex token on iOS, FCM registration token on Android. */
|
|
86
|
+
token: string;
|
|
87
|
+
/**
|
|
88
|
+
* Parity B1/C8: which APNs endpoint the backend must use.
|
|
89
|
+
* **iOS only** — always `null` on Android, where FCM routes for you.
|
|
90
|
+
*/
|
|
91
|
+
environment: 'sandbox' | 'production' | null;
|
|
92
|
+
}
|
|
93
|
+
export interface NotificationOpenedEvent {
|
|
94
|
+
notification: PushNotification;
|
|
95
|
+
/** `null` when the notification body was tapped; set for an action-button tap. */
|
|
96
|
+
actionId: string | null;
|
|
97
|
+
/** The payload's launch URL, if any. */
|
|
98
|
+
url: string | null;
|
|
99
|
+
}
|
|
100
|
+
export interface NotificationReceivedEvent {
|
|
101
|
+
notification: PushNotification;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Fired while the app is in the foreground, before the notification is displayed.
|
|
105
|
+
*
|
|
106
|
+
* Parity B4/F7: `preventDefault()` is exposed, presentation options are not —
|
|
107
|
+
* iOS lets the OS present, Android builds the notification itself, so any
|
|
108
|
+
* option set would mean different things on each platform.
|
|
109
|
+
*/
|
|
110
|
+
export interface NotificationWillDisplayEvent {
|
|
111
|
+
notification: PushNotification;
|
|
112
|
+
/**
|
|
113
|
+
* Suppress the system notification. Must be called synchronously in the handler.
|
|
114
|
+
*
|
|
115
|
+
* **Honoured on Android only.** The Android SDK calls its foreground listeners
|
|
116
|
+
* on FCM's background thread, so the bridge can park there while JS decides.
|
|
117
|
+
* iOS's `handleWillPresent(notification:)` returns its presentation options
|
|
118
|
+
* synchronously with no completion handler to hold open, so by the time a JS
|
|
119
|
+
* handler runs the notification has already been presented. On iOS this event
|
|
120
|
+
* is informational and calling `preventDefault()` does nothing.
|
|
121
|
+
*/
|
|
122
|
+
preventDefault: () => void;
|
|
123
|
+
}
|
|
124
|
+
export interface PermissionChangedEvent {
|
|
125
|
+
granted: boolean;
|
|
126
|
+
}
|
|
127
|
+
export interface PushSubscriptionState {
|
|
128
|
+
id: string | null;
|
|
129
|
+
token: string | null;
|
|
130
|
+
optedIn: boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface PushSubscriptionChangedEvent {
|
|
133
|
+
previous: PushSubscriptionState;
|
|
134
|
+
current: PushSubscriptionState;
|
|
135
|
+
}
|
|
136
|
+
export interface UserState {
|
|
137
|
+
/** The external id linked via `login()`. `null` while anonymous. */
|
|
138
|
+
externalId: string | null;
|
|
139
|
+
/** The AppsOnAir-assigned device id. */
|
|
140
|
+
appsOnAirId: string;
|
|
141
|
+
}
|
|
142
|
+
export interface UserStateChangedEvent {
|
|
143
|
+
current: UserState;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A data-only push that is delivered without being displayed.
|
|
147
|
+
*
|
|
148
|
+
* Parity F5 — supported on both platforms, but the two are triggered
|
|
149
|
+
* differently and your backend has to send for both:
|
|
150
|
+
*
|
|
151
|
+
* - **iOS** uses the APNs transport flag, `content-available: 1`.
|
|
152
|
+
* - **Android** has no transport-level equivalent in FCM, so the SDK keys off a
|
|
153
|
+
* `silent: "true"` entry in the data payload. A data push *without* that key
|
|
154
|
+
* renders as a visible notification and fires no listener here.
|
|
155
|
+
*
|
|
156
|
+
* On iOS the OS completion handler is invoked as soon as the event is emitted,
|
|
157
|
+
* so a handler cannot extend the background execution window.
|
|
158
|
+
*/
|
|
159
|
+
export interface SilentNotificationEvent {
|
|
160
|
+
data: Record<string, string>;
|
|
161
|
+
}
|
|
162
|
+
/** Firebase Installation ID. Parity B2: **Android only.** */
|
|
163
|
+
export interface InstallationIdEvent {
|
|
164
|
+
id: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Parity C5: the union of both platforms' error codes in one casing.
|
|
168
|
+
* `tokenRegistrationFailed` is the shared name for iOS `apnsRegistrationFailed`
|
|
169
|
+
* and Android `TOKEN_FETCH_FAILED`.
|
|
170
|
+
*
|
|
171
|
+
* Native `PushError.cause` is dropped — a `Throwable` does not cross the bridge.
|
|
172
|
+
*/
|
|
173
|
+
export type PushErrorCode = 'notInitialized' | 'permissionDenied'
|
|
174
|
+
/** **Android only.** No `google-services.json`, or the plugin was not applied. */
|
|
175
|
+
| 'firebaseNotConfigured' | 'tokenRegistrationFailed' | 'installationIdFetchFailed' | 'unknown';
|
|
176
|
+
export interface PushErrorEvent {
|
|
177
|
+
code: PushErrorCode;
|
|
178
|
+
message: string;
|
|
179
|
+
}
|
|
180
|
+
/** Parity C6: one casing for both platforms; the bridge maps to the native enum. */
|
|
181
|
+
export type LogLevel = 'none' | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'verbose';
|
|
182
|
+
/**
|
|
183
|
+
* Parity C7: iOS reports all five states. Android has no granular type and
|
|
184
|
+
* reports only `authorized` or `denied` — it can never return `notDetermined`,
|
|
185
|
+
* so do not branch on that value for a cross-platform pre-prompt.
|
|
186
|
+
*/
|
|
187
|
+
export type PermissionStatus = 'notDetermined' | 'denied' | 'authorized' | 'provisional' | 'ephemeral';
|
|
188
|
+
export interface RequestPermissionOptions {
|
|
189
|
+
/**
|
|
190
|
+
* When permission was already permanently denied, send the user to the OS
|
|
191
|
+
* settings screen instead of failing silently. Defaults to `false`.
|
|
192
|
+
*/
|
|
193
|
+
fallbackToSettings?: boolean;
|
|
194
|
+
}
|
|
195
|
+
/** Mirrors `NotificationManager.IMPORTANCE_*`. */
|
|
196
|
+
export type NotificationChannelImportance = 'none' | 'min' | 'low' | 'default' | 'high' | 'max';
|
|
197
|
+
/** Parity F4: **Android only.** A no-op on iOS, which has no channel concept. */
|
|
198
|
+
export interface NotificationChannelConfig {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
importance?: NotificationChannelImportance;
|
|
202
|
+
description?: string;
|
|
203
|
+
/** Sound file name in `res/raw`, without extension. */
|
|
204
|
+
sound?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Parity H1: the two native APIs share no method name, parameter, or unit —
|
|
208
|
+
* iOS takes seconds via BGTaskScheduler, Android minutes via WorkManager. This
|
|
209
|
+
* is the single shape; each bridge converts.
|
|
210
|
+
*/
|
|
211
|
+
export interface BackgroundSyncOptions {
|
|
212
|
+
/** Defaults to 60. iOS converts to seconds and treats it as a *minimum* delay. */
|
|
213
|
+
intervalMinutes?: number;
|
|
214
|
+
/** Android WorkManager constraint. Ignored on iOS. Defaults to `true`. */
|
|
215
|
+
requireNetwork?: boolean;
|
|
216
|
+
}
|
|
217
|
+
/** Returned by every `on*` subscribe helper. Call `remove()` to unsubscribe. */
|
|
218
|
+
export interface Subscription {
|
|
219
|
+
remove: () => void;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d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