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,612 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeEventEmitter, NativeModules, Platform, TurboModuleRegistry } from 'react-native';
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
const LINKING_ERROR = `The package 'appsonair-react-native-apppush' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
6
|
+
ios: "- You have run 'pod install'\n",
|
|
7
|
+
default: ''
|
|
8
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the native module on both architectures.
|
|
12
|
+
*
|
|
13
|
+
* `TurboModuleRegistry.get` returns the TurboModule when the New Architecture is
|
|
14
|
+
* on and falls back to the legacy `NativeModules` entry when it is off, so one
|
|
15
|
+
* lookup covers both. The `NativeModules` read is the belt-and-braces path for
|
|
16
|
+
* hosts where the registry is unavailable; the Proxy then turns a missing module
|
|
17
|
+
* into an actionable message instead of `undefined is not an object`.
|
|
18
|
+
*/
|
|
19
|
+
const NativePush = TurboModuleRegistry.get('AppsonairReactNativeApppush') ?? NativeModules.AppsonairReactNativeApppush ?? new Proxy({}, {
|
|
20
|
+
get() {
|
|
21
|
+
throw new Error(LINKING_ERROR);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const emitter = new NativeEventEmitter(
|
|
25
|
+
// The legacy bridge needs the module instance to route `addListener`;
|
|
26
|
+
// the New Architecture ignores this argument entirely.
|
|
27
|
+
NativeModules.AppsonairReactNativeApppush ?? undefined);
|
|
28
|
+
|
|
29
|
+
// MARK: - Event names
|
|
30
|
+
// Kept in one place because the native bridges hardcode these same strings — a
|
|
31
|
+
// rename has to happen in four files at once: here,
|
|
32
|
+
// AppsonairReactNativeApppushModuleImpl.kt, AppsonairReactNativeApppushImpl.swift and
|
|
33
|
+
// the supportedEvents list in AppsonairReactNativeApppush.mm.
|
|
34
|
+
|
|
35
|
+
const EVENT = {
|
|
36
|
+
notificationReceived: 'AppsonairPush:onNotificationReceived',
|
|
37
|
+
notificationOpened: 'AppsonairPush:onNotificationOpened',
|
|
38
|
+
notificationWillDisplay: 'AppsonairPush:onNotificationWillDisplay',
|
|
39
|
+
permissionChanged: 'AppsonairPush:onPermissionChanged',
|
|
40
|
+
subscriptionChanged: 'AppsonairPush:onSubscriptionChanged',
|
|
41
|
+
userStateChanged: 'AppsonairPush:onUserStateChanged',
|
|
42
|
+
tokenUpdated: 'AppsonairPush:onTokenUpdated',
|
|
43
|
+
silentNotification: 'AppsonairPush:onSilentNotification',
|
|
44
|
+
installationIdUpdated: 'AppsonairPush:onInstallationIdUpdated',
|
|
45
|
+
error: 'AppsonairPush:onError'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// MARK: - Initialization guard
|
|
49
|
+
//
|
|
50
|
+
// Parity I1: calling before `initialize()` emits a catchable error on iOS but
|
|
51
|
+
// throws `IllegalStateException` on Android — a hard crash. The wrapper tracks
|
|
52
|
+
// initialisation itself so the same misuse produces the same rejected promise
|
|
53
|
+
// on both platforms and the Android `check()` never reaches the app.
|
|
54
|
+
|
|
55
|
+
let initialized = false;
|
|
56
|
+
class PushNotInitializedError extends Error {
|
|
57
|
+
code = 'notInitialized';
|
|
58
|
+
constructor(method) {
|
|
59
|
+
super(`AppPushService.${method}() was called before initialize(). ` + 'Await initialize() once at app start before using the SDK.');
|
|
60
|
+
this.name = 'PushNotInitializedError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class PushArgumentError extends Error {
|
|
64
|
+
code = 'invalidArgument';
|
|
65
|
+
constructor(message) {
|
|
66
|
+
super(message);
|
|
67
|
+
this.name = 'PushArgumentError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function guard(method, call) {
|
|
71
|
+
if (!initialized) {
|
|
72
|
+
return Promise.reject(new PushNotInitializedError(method));
|
|
73
|
+
}
|
|
74
|
+
return call();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Parity I2: `login("")` logs and returns on iOS but throws
|
|
79
|
+
* `IllegalArgumentException` on Android. Validated here so neither happens.
|
|
80
|
+
*/
|
|
81
|
+
function requireNonEmpty(value, label) {
|
|
82
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
83
|
+
throw new PushArgumentError(`${label} must be a non-empty string.`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// MARK: - Lifecycle
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Starts the SDK. Await this once, before any other call.
|
|
91
|
+
*
|
|
92
|
+
* On Android the wrapper supplies the `Context` itself; on iOS it resolves the
|
|
93
|
+
* App Group and enables AppDelegate swizzling. Neither detail is exposed here.
|
|
94
|
+
*/
|
|
95
|
+
export async function initialize(config = {}) {
|
|
96
|
+
await NativePush.initialize({
|
|
97
|
+
debug: config.debug ?? false
|
|
98
|
+
});
|
|
99
|
+
initialized = true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Whether {@link initialize} has completed in this JS context. */
|
|
103
|
+
export function isInitialized() {
|
|
104
|
+
return initialized;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// MARK: - Identity
|
|
108
|
+
|
|
109
|
+
/** The AppsOnAir-assigned device id. */
|
|
110
|
+
export function getDeviceId() {
|
|
111
|
+
return guard('getDeviceId', () => NativePush.getDeviceId());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The backend-assigned subscription id. `null` until the device registers. */
|
|
115
|
+
export function getSubscriptionId() {
|
|
116
|
+
return guard('getSubscriptionId', () => NativePush.getSubscriptionId());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The external id linked via {@link login}. `null` while anonymous. */
|
|
120
|
+
export function getExternalId() {
|
|
121
|
+
return guard('getExternalId', () => NativePush.getExternalId());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Associates this device with your own user id. */
|
|
125
|
+
export function login(externalId) {
|
|
126
|
+
requireNonEmpty(externalId, 'externalId');
|
|
127
|
+
return guard('login', () => NativePush.login(externalId));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Unlinks the external id, returning the device to an anonymous subscription. */
|
|
131
|
+
export function logout() {
|
|
132
|
+
return guard('logout', () => NativePush.logout());
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Alias of {@link login}, for teams that prefer the noun. */
|
|
136
|
+
export const setUserId = login;
|
|
137
|
+
|
|
138
|
+
// MARK: - Token
|
|
139
|
+
|
|
140
|
+
/** APNs hex token on iOS, FCM token on Android. `null` before registration. */
|
|
141
|
+
export function getToken() {
|
|
142
|
+
return guard('getToken', () => NativePush.getToken());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Alias of {@link getToken}. */
|
|
146
|
+
export const getDeviceToken = getToken;
|
|
147
|
+
|
|
148
|
+
// MARK: - Permissions
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Prompts for notification permission and resolves the resulting grant state.
|
|
152
|
+
*
|
|
153
|
+
* Parity E1: Android needs a live Activity. The bridge resolves the current one
|
|
154
|
+
* and rejects if none is attached rather than crashing.
|
|
155
|
+
*/
|
|
156
|
+
export function requestPermission(options = {}) {
|
|
157
|
+
return guard('requestPermission', () => NativePush.requestPermission(options.fallbackToSettings ?? false));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Whether notifications are currently permitted.
|
|
162
|
+
*
|
|
163
|
+
* Parity E3/E4/E6: iOS reads a cache and Android reads live, so the iOS bridge
|
|
164
|
+
* refreshes first. The two native shapes (`async` vs sync, `permission` vs
|
|
165
|
+
* `isPermissionGranted`) are collapsed into this one promise.
|
|
166
|
+
*/
|
|
167
|
+
export function getPermission() {
|
|
168
|
+
return guard('getPermission', () => NativePush.getPermission());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The granular permission state.
|
|
173
|
+
*
|
|
174
|
+
* Parity C7: iOS reports all five values. **Android reports only `authorized`
|
|
175
|
+
* or `denied`** — it never returns `notDetermined`, so do not gate a
|
|
176
|
+
* cross-platform pre-prompt on that value.
|
|
177
|
+
*/
|
|
178
|
+
export function getPermissionStatus() {
|
|
179
|
+
return guard('getPermissionStatus', () => NativePush.getPermissionStatus());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Whether a permission prompt can still be shown.
|
|
184
|
+
*
|
|
185
|
+
* Parity E2 — **known divergence, not yet fixed in the native SDKs.** iOS
|
|
186
|
+
* returns `true` only before the user has ever been asked. Android returns
|
|
187
|
+
* `true` whenever permission is not granted, *including after a permanent
|
|
188
|
+
* denial*. Treat a `true` on Android as "not granted", not as "never asked".
|
|
189
|
+
*/
|
|
190
|
+
export function canRequestPermission() {
|
|
191
|
+
return guard('canRequestPermission', () => NativePush.canRequestPermission());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Quiet iOS 12+ provisional authorization. **iOS only** — a no-op on Android. */
|
|
195
|
+
export function registerForProvisionalAuthorization() {
|
|
196
|
+
return guard('registerForProvisionalAuthorization', () => NativePush.registerForProvisionalAuthorization());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// MARK: - Notifications namespace
|
|
200
|
+
|
|
201
|
+
export const notifications = {
|
|
202
|
+
/** Dismisses every notification this app has posted. */
|
|
203
|
+
clearAll() {
|
|
204
|
+
return guard('notifications.clearAll', () => NativePush.clearAllNotifications());
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Dismisses one notification by its payload `notification_id`.
|
|
208
|
+
*
|
|
209
|
+
* Parity F2: on Android the id is hashed to find the posted notification, so
|
|
210
|
+
* two ids that hash alike could collide. iOS matches the request identifier
|
|
211
|
+
* exactly.
|
|
212
|
+
*/
|
|
213
|
+
remove(notificationId) {
|
|
214
|
+
requireNonEmpty(notificationId, 'notificationId');
|
|
215
|
+
return guard('notifications.remove', () => NativePush.removeNotification(notificationId));
|
|
216
|
+
},
|
|
217
|
+
/** Dismisses several notifications. Android loops; iOS removes them in one call. */
|
|
218
|
+
removeMany(notificationIds) {
|
|
219
|
+
if (!Array.isArray(notificationIds)) {
|
|
220
|
+
throw new PushArgumentError('notificationIds must be an array of strings.');
|
|
221
|
+
}
|
|
222
|
+
return guard('notifications.removeMany', () => NativePush.removeNotifications(notificationIds));
|
|
223
|
+
},
|
|
224
|
+
/** Dismisses a notification group. **Android only** — a no-op on iOS. */
|
|
225
|
+
removeGroup(groupKey) {
|
|
226
|
+
requireNonEmpty(groupKey, 'groupKey');
|
|
227
|
+
return guard('notifications.removeGroup', () => NativePush.removeNotificationGroup(groupKey));
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// MARK: - Badges
|
|
232
|
+
|
|
233
|
+
export const badge = {
|
|
234
|
+
/**
|
|
235
|
+
* The SDK's badge count.
|
|
236
|
+
*
|
|
237
|
+
* Parity G1/G3: iOS reads the OS badge. Android has no OS read API, so this
|
|
238
|
+
* returns the SDK's own persisted value, which can drift from what the
|
|
239
|
+
* launcher actually shows.
|
|
240
|
+
*/
|
|
241
|
+
get() {
|
|
242
|
+
return guard('badge.get', () => NativePush.getBadgeCount());
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* Sets the badge count.
|
|
246
|
+
*
|
|
247
|
+
* Parity G3: reliable on iOS. On Android this is a best-effort launcher
|
|
248
|
+
* broadcast that silently does nothing outside Samsung / MIUI / ASUS — which
|
|
249
|
+
* is why nothing here reports success.
|
|
250
|
+
*/
|
|
251
|
+
set(count) {
|
|
252
|
+
if (!Number.isFinite(count) || count < 0) {
|
|
253
|
+
throw new PushArgumentError('badge count must be a non-negative number.');
|
|
254
|
+
}
|
|
255
|
+
return guard('badge.set', () => NativePush.setBadgeCount(count));
|
|
256
|
+
},
|
|
257
|
+
/** Adds `delta` to the badge and resolves the new value, clamped at 0. */
|
|
258
|
+
increment(delta = 1) {
|
|
259
|
+
if (!Number.isFinite(delta)) {
|
|
260
|
+
throw new PushArgumentError('badge delta must be a number.');
|
|
261
|
+
}
|
|
262
|
+
return guard('badge.increment', () => NativePush.incrementBadgeCount(delta));
|
|
263
|
+
},
|
|
264
|
+
/** Clears the badge. */
|
|
265
|
+
clear() {
|
|
266
|
+
return guard('badge.clear', () => NativePush.clearBadgeCount());
|
|
267
|
+
},
|
|
268
|
+
/** Clears the badge whenever the app foregrounds. **iOS only.** */
|
|
269
|
+
setAutoClearOnForeground(enabled) {
|
|
270
|
+
return guard('badge.setAutoClearOnForeground', () => NativePush.setAutoClearBadgeOnForeground(enabled));
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// MARK: - User namespace
|
|
275
|
+
|
|
276
|
+
export const user = {
|
|
277
|
+
/** The AppsOnAir device id. */
|
|
278
|
+
getAppsOnAirId() {
|
|
279
|
+
return guard('user.getAppsOnAirId', () => NativePush.getDeviceId());
|
|
280
|
+
},
|
|
281
|
+
getExternalId,
|
|
282
|
+
addTag(key, value) {
|
|
283
|
+
requireNonEmpty(key, 'tag key');
|
|
284
|
+
return guard('user.addTag', () => NativePush.addTag(key, value));
|
|
285
|
+
},
|
|
286
|
+
addTags(tags) {
|
|
287
|
+
return guard('user.addTags', () => NativePush.addTags(tags));
|
|
288
|
+
},
|
|
289
|
+
removeTag(key) {
|
|
290
|
+
requireNonEmpty(key, 'tag key');
|
|
291
|
+
return guard('user.removeTag', () => NativePush.removeTag(key));
|
|
292
|
+
},
|
|
293
|
+
removeTags(keys) {
|
|
294
|
+
return guard('user.removeTags', () => NativePush.removeTags(keys));
|
|
295
|
+
},
|
|
296
|
+
/**
|
|
297
|
+
* The user's tags.
|
|
298
|
+
*
|
|
299
|
+
* **Android round-trips to the backend** once the device has a
|
|
300
|
+
* `subscriptionId`, replacing its local cache with the result; before
|
|
301
|
+
* registration it resolves the local cache without a network call. **iOS reads
|
|
302
|
+
* its local cache only.** So a tag set on another device shows up on Android
|
|
303
|
+
* and not on iOS, and the Android call can reject on a network failure where
|
|
304
|
+
* iOS cannot.
|
|
305
|
+
*/
|
|
306
|
+
getTags() {
|
|
307
|
+
return guard('user.getTags', () => NativePush.getTags());
|
|
308
|
+
},
|
|
309
|
+
addAlias(label, id) {
|
|
310
|
+
requireNonEmpty(label, 'alias label');
|
|
311
|
+
requireNonEmpty(id, 'alias id');
|
|
312
|
+
return guard('user.addAlias', () => NativePush.addAlias(label, id));
|
|
313
|
+
},
|
|
314
|
+
addAliases(aliases) {
|
|
315
|
+
return guard('user.addAliases', () => NativePush.addAliases(aliases));
|
|
316
|
+
},
|
|
317
|
+
removeAlias(label) {
|
|
318
|
+
requireNonEmpty(label, 'alias label');
|
|
319
|
+
return guard('user.removeAlias', () => NativePush.removeAlias(label));
|
|
320
|
+
},
|
|
321
|
+
removeAliases(labels) {
|
|
322
|
+
return guard('user.removeAliases', () => NativePush.removeAliases(labels));
|
|
323
|
+
},
|
|
324
|
+
/**
|
|
325
|
+
* Adds an email identifier.
|
|
326
|
+
*
|
|
327
|
+
* Parity A5 — **known Android bug.** Android persists emails but never reads
|
|
328
|
+
* them back on restart, so an email added here silently vanishes when the app
|
|
329
|
+
* relaunches. The wrapper cannot work around it; it needs an SDK fix.
|
|
330
|
+
*/
|
|
331
|
+
addEmail(address) {
|
|
332
|
+
requireNonEmpty(address, 'email address');
|
|
333
|
+
return guard('user.addEmail', () => NativePush.addEmail(address));
|
|
334
|
+
},
|
|
335
|
+
removeEmail(address) {
|
|
336
|
+
requireNonEmpty(address, 'email address');
|
|
337
|
+
return guard('user.removeEmail', () => NativePush.removeEmail(address));
|
|
338
|
+
},
|
|
339
|
+
setLanguage(languageCode) {
|
|
340
|
+
requireNonEmpty(languageCode, 'languageCode');
|
|
341
|
+
return guard('user.setLanguage', () => NativePush.setLanguage(languageCode));
|
|
342
|
+
},
|
|
343
|
+
/**
|
|
344
|
+
* The device language.
|
|
345
|
+
*
|
|
346
|
+
* Parity 1.5 — Android reads this live; iOS snapshots it once at init and
|
|
347
|
+
* never refreshes, so a mid-session language change is stale on iOS.
|
|
348
|
+
*/
|
|
349
|
+
getLanguage() {
|
|
350
|
+
return guard('user.getLanguage', () => NativePush.getLanguage());
|
|
351
|
+
},
|
|
352
|
+
/** The current push subscription: `{ id, token, optedIn }`. */
|
|
353
|
+
getPushSubscription() {
|
|
354
|
+
return guard('user.getPushSubscription', () => NativePush.getPushSubscription());
|
|
355
|
+
},
|
|
356
|
+
/** Opts this device back in to push delivery. */
|
|
357
|
+
optIn() {
|
|
358
|
+
return guard('user.optIn', () => NativePush.optIn());
|
|
359
|
+
},
|
|
360
|
+
/** Opts this device out of push delivery without unregistering the token. */
|
|
361
|
+
optOut() {
|
|
362
|
+
return guard('user.optOut', () => NativePush.optOut());
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* The subscription's enabled state as the backend sees it.
|
|
366
|
+
*
|
|
367
|
+
* Distinct from `getPushSubscription().optedIn`, which is the purely local
|
|
368
|
+
* `!optedOut` flag on both platforms. The two derive it differently and
|
|
369
|
+
* converge only in steady state:
|
|
370
|
+
*
|
|
371
|
+
* - **Android** reads it back from `/subscriptions`, so it reflects what the
|
|
372
|
+
* server actually stored. Before the device registers it falls back to the
|
|
373
|
+
* local value without a network call.
|
|
374
|
+
* - **iOS** computes the same flag it would send: an APNs token exists, the
|
|
375
|
+
* user has not opted out, *and* the OS currently grants permission. So
|
|
376
|
+
* revoking permission in Settings flips this to `false` on iOS while
|
|
377
|
+
* Android keeps reporting the server's stored value.
|
|
378
|
+
*/
|
|
379
|
+
getOptedIn() {
|
|
380
|
+
return guard('user.getOptedIn', () => NativePush.getOptedIn());
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// MARK: - Consent
|
|
385
|
+
//
|
|
386
|
+
// Parity I5: both SDKs store these flags but neither enforces them. They are
|
|
387
|
+
// exposed because they round-trip, but they are not a compliance control yet —
|
|
388
|
+
// setting `consentGiven` to false does not currently gate anything.
|
|
389
|
+
|
|
390
|
+
export const consent = {
|
|
391
|
+
setRequired(required) {
|
|
392
|
+
return guard('consent.setRequired', () => NativePush.setConsentRequired(required));
|
|
393
|
+
},
|
|
394
|
+
getRequired() {
|
|
395
|
+
return guard('consent.getRequired', () => NativePush.getConsentRequired());
|
|
396
|
+
},
|
|
397
|
+
setGiven(given) {
|
|
398
|
+
return guard('consent.setGiven', () => NativePush.setConsentGiven(given));
|
|
399
|
+
},
|
|
400
|
+
getGiven() {
|
|
401
|
+
return guard('consent.getGiven', () => NativePush.getConsentGiven());
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// MARK: - Debug
|
|
406
|
+
|
|
407
|
+
export const debug = {
|
|
408
|
+
/** Sets SDK log verbosity. Safe to call before {@link initialize}. */
|
|
409
|
+
setLogLevel(level) {
|
|
410
|
+
return NativePush.setLogLevel(level);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// MARK: - Events
|
|
415
|
+
|
|
416
|
+
function subscribe(eventName, callback) {
|
|
417
|
+
const sub = emitter.addListener(eventName, callback);
|
|
418
|
+
return {
|
|
419
|
+
remove: () => sub.remove()
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Fires when a notification arrives while the app is in the foreground. */
|
|
424
|
+
export function onNotificationReceived(callback) {
|
|
425
|
+
return subscribe(EVENT.notificationReceived, callback);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Fires when the user taps a notification or one of its action buttons. */
|
|
429
|
+
export function onNotificationOpened(callback) {
|
|
430
|
+
return subscribe(EVENT.notificationOpened, callback);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Fires in the foreground *before* the notification is displayed, giving you a
|
|
435
|
+
* chance to suppress it.
|
|
436
|
+
*
|
|
437
|
+
* `preventDefault()` must be called synchronously inside the handler — the
|
|
438
|
+
* native side is holding the notification until this returns, and releases it
|
|
439
|
+
* anyway after a short timeout so a throwing handler cannot wedge delivery.
|
|
440
|
+
*
|
|
441
|
+
* All registered handlers run; the notification is suppressed if *any* of them
|
|
442
|
+
* calls `preventDefault()`.
|
|
443
|
+
*
|
|
444
|
+
* **`preventDefault()` is honoured on Android only.** iOS decides presentation
|
|
445
|
+
* synchronously and cannot wait for a JS answer — see
|
|
446
|
+
* {@link NotificationWillDisplayEvent.preventDefault}. The event itself fires on
|
|
447
|
+
* both platforms.
|
|
448
|
+
*/
|
|
449
|
+
export function onNotificationWillDisplay(callback) {
|
|
450
|
+
willDisplayHandlers.add(callback);
|
|
451
|
+
ensureWillDisplayBridge();
|
|
452
|
+
return {
|
|
453
|
+
remove: () => {
|
|
454
|
+
willDisplayHandlers.delete(callback);
|
|
455
|
+
if (willDisplayHandlers.size === 0) {
|
|
456
|
+
willDisplayBridge?.remove();
|
|
457
|
+
willDisplayBridge = null;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
const willDisplayHandlers = new Set();
|
|
463
|
+
let willDisplayBridge = null;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* One emitter subscription fans out to every handler, so
|
|
467
|
+
* `completeNotificationWillDisplay` is called exactly once per notification no
|
|
468
|
+
* matter how many handlers are registered. Completing twice would release the
|
|
469
|
+
* same held notification twice on the native side.
|
|
470
|
+
*/
|
|
471
|
+
function ensureWillDisplayBridge() {
|
|
472
|
+
if (willDisplayBridge) return;
|
|
473
|
+
willDisplayBridge = emitter.addListener(EVENT.notificationWillDisplay, payload => {
|
|
474
|
+
let prevented = false;
|
|
475
|
+
const event = {
|
|
476
|
+
notification: payload.notification,
|
|
477
|
+
preventDefault: () => {
|
|
478
|
+
prevented = true;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
for (const handler of willDisplayHandlers) {
|
|
482
|
+
try {
|
|
483
|
+
handler(event);
|
|
484
|
+
} catch (error) {
|
|
485
|
+
// A throwing handler must not stop the remaining handlers, and must
|
|
486
|
+
// not prevent the completion call below — otherwise the native side
|
|
487
|
+
// holds the notification until its timeout for no reason.
|
|
488
|
+
console.error('[AppPushService] onNotificationWillDisplay handler threw', error);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const id = payload.notification?.id;
|
|
492
|
+
if (id != null) {
|
|
493
|
+
NativePush.completeNotificationWillDisplay(id, !prevented).catch(() => {
|
|
494
|
+
// The native side falls back to displaying the notification when the
|
|
495
|
+
// completion never lands, so there is nothing to recover here.
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** Fires when the OS notification permission changes. */
|
|
502
|
+
export function onPermissionChanged(callback) {
|
|
503
|
+
return subscribe(EVENT.permissionChanged, callback);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Fires when the push subscription's token or opt-in state changes. */
|
|
507
|
+
export function onSubscriptionChanged(callback) {
|
|
508
|
+
return subscribe(EVENT.subscriptionChanged, callback);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** Fires on {@link login} / {@link logout}. */
|
|
512
|
+
export function onUserStateChanged(callback) {
|
|
513
|
+
return subscribe(EVENT.userStateChanged, callback);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Fires when the device registration token is issued or refreshed.
|
|
518
|
+
*
|
|
519
|
+
* This is the push-side counterpart to {@link getToken}: the getter answers
|
|
520
|
+
* "what is the token now", this answers "the token just changed" — which is when
|
|
521
|
+
* your backend needs to hear about it. A token can rotate at any point in a
|
|
522
|
+
* session, so a one-shot `getToken()` at startup will eventually go stale.
|
|
523
|
+
*
|
|
524
|
+
* `environment` is the APNs endpoint the backend must send to. It is
|
|
525
|
+
* `'sandbox'` or `'production'` on iOS and always `null` on Android, where FCM
|
|
526
|
+
* routes for you.
|
|
527
|
+
*
|
|
528
|
+
* Events raised before the first subscriber exists are dropped rather than
|
|
529
|
+
* queued on both platforms, so read {@link getToken} once after subscribing if
|
|
530
|
+
* you need the current value too.
|
|
531
|
+
*/
|
|
532
|
+
export function onTokenUpdated(callback) {
|
|
533
|
+
return subscribe(EVENT.tokenUpdated, callback);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Fires on an SDK-level failure — token registration, a denied permission, a
|
|
538
|
+
* missing Firebase config.
|
|
539
|
+
*
|
|
540
|
+
* These are conditions the SDK hits on its own schedule, outside any call you
|
|
541
|
+
* made, so they surface here rather than as a rejected promise. A promise
|
|
542
|
+
* rejection from a method you called carries the same `code` values.
|
|
543
|
+
*
|
|
544
|
+
* Without a subscriber these failures are silent, which is why this is worth
|
|
545
|
+
* wiring even if it only ever logs.
|
|
546
|
+
*/
|
|
547
|
+
export function onError(callback) {
|
|
548
|
+
return subscribe(EVENT.error, callback);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Fires for a data-only push that is delivered without being displayed.
|
|
553
|
+
*
|
|
554
|
+
* Supported on both platforms, but they are triggered differently and your
|
|
555
|
+
* backend has to send for both: iOS uses the APNs `content-available` flag,
|
|
556
|
+
* while Android keys off a `silent: "true"` data entry, since FCM has no
|
|
557
|
+
* transport-level equivalent. See {@link SilentNotificationEvent}.
|
|
558
|
+
*
|
|
559
|
+
* iOS invokes the OS completion handler as soon as this event is emitted, so
|
|
560
|
+
* the handler cannot extend the app's background execution window: treat it as
|
|
561
|
+
* a notification that the payload arrived, not as a place to await work.
|
|
562
|
+
*/
|
|
563
|
+
export function onSilentNotification(callback) {
|
|
564
|
+
return subscribe(EVENT.silentNotification, callback);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Fires when the Firebase Installation ID becomes available.
|
|
569
|
+
*
|
|
570
|
+
* **Android only** — the event name is registered on iOS so the two bridges
|
|
571
|
+
* stay diffable, but nothing ever emits it there.
|
|
572
|
+
*/
|
|
573
|
+
export function onInstallationIdUpdated(callback) {
|
|
574
|
+
return subscribe(EVENT.installationIdUpdated, callback);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// MARK: - Default export
|
|
578
|
+
|
|
579
|
+
const AppPushService = {
|
|
580
|
+
initialize,
|
|
581
|
+
isInitialized,
|
|
582
|
+
getDeviceId,
|
|
583
|
+
getSubscriptionId,
|
|
584
|
+
getExternalId,
|
|
585
|
+
login,
|
|
586
|
+
logout,
|
|
587
|
+
setUserId,
|
|
588
|
+
getToken,
|
|
589
|
+
getDeviceToken,
|
|
590
|
+
requestPermission,
|
|
591
|
+
getPermission,
|
|
592
|
+
getPermissionStatus,
|
|
593
|
+
canRequestPermission,
|
|
594
|
+
registerForProvisionalAuthorization,
|
|
595
|
+
notifications,
|
|
596
|
+
badge,
|
|
597
|
+
user,
|
|
598
|
+
consent,
|
|
599
|
+
debug,
|
|
600
|
+
onNotificationReceived,
|
|
601
|
+
onNotificationOpened,
|
|
602
|
+
onNotificationWillDisplay,
|
|
603
|
+
onPermissionChanged,
|
|
604
|
+
onSubscriptionChanged,
|
|
605
|
+
onUserStateChanged,
|
|
606
|
+
onTokenUpdated,
|
|
607
|
+
onError,
|
|
608
|
+
onSilentNotification,
|
|
609
|
+
onInstallationIdUpdated
|
|
610
|
+
};
|
|
611
|
+
export default AppPushService;
|
|
612
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","TurboModuleRegistry","LINKING_ERROR","select","ios","default","NativePush","get","AppsonairReactNativeApppush","Proxy","Error","emitter","undefined","EVENT","notificationReceived","notificationOpened","notificationWillDisplay","permissionChanged","subscriptionChanged","userStateChanged","tokenUpdated","silentNotification","installationIdUpdated","error","initialized","PushNotInitializedError","code","constructor","method","name","PushArgumentError","message","guard","call","Promise","reject","requireNonEmpty","value","label","trim","length","initialize","config","debug","isInitialized","getDeviceId","getSubscriptionId","getExternalId","login","externalId","logout","setUserId","getToken","getDeviceToken","requestPermission","options","fallbackToSettings","getPermission","getPermissionStatus","canRequestPermission","registerForProvisionalAuthorization","notifications","clearAll","clearAllNotifications","remove","notificationId","removeNotification","removeMany","notificationIds","Array","isArray","removeNotifications","removeGroup","groupKey","removeNotificationGroup","badge","getBadgeCount","set","count","Number","isFinite","setBadgeCount","increment","delta","incrementBadgeCount","clear","clearBadgeCount","setAutoClearOnForeground","enabled","setAutoClearBadgeOnForeground","user","getAppsOnAirId","addTag","key","addTags","tags","removeTag","removeTags","keys","getTags","addAlias","id","addAliases","aliases","removeAlias","removeAliases","labels","addEmail","address","removeEmail","setLanguage","languageCode","getLanguage","getPushSubscription","optIn","optOut","getOptedIn","consent","setRequired","required","setConsentRequired","getRequired","getConsentRequired","setGiven","given","setConsentGiven","getGiven","getConsentGiven","setLogLevel","level","subscribe","eventName","callback","sub","addListener","onNotificationReceived","onNotificationOpened","onNotificationWillDisplay","willDisplayHandlers","add","ensureWillDisplayBridge","delete","size","willDisplayBridge","Set","payload","prevented","event","notification","preventDefault","handler","console","completeNotificationWillDisplay","catch","onPermissionChanged","onSubscriptionChanged","onUserStateChanged","onTokenUpdated","onError","onSilentNotification","onInstallationIdUpdated","AppPushService"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,EACRC,mBAAmB,QAEd,cAAc;AAu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,KAAK,CAACU,KAAK,EAAE6G,QAAQ,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS2B,oBAAoBA,CAClC3B,QAAkD,EACpC;EACd,OAAOF,SAAS,CAACrH,KAAK,CAACQ,kBAAkB,EAAE+G,QAAQ,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS4B,uBAAuBA,CACrC5B,QAA8C,EAChC;EACd,OAAOF,SAAS,CAACrH,KAAK,CAACS,qBAAqB,EAAE8G,QAAQ,CAAC;AACzD;;AAEA;;AAEA,MAAM6B,cAAc,GAAG;EACrBxH,UAAU;EACVG,aAAa;EAEbC,WAAW;EACXC,iBAAiB;EACjBC,aAAa;EACbC,KAAK;EACLE,MAAM;EACNC,SAAS;EAETC,QAAQ;EACRC,cAAc;EAEdC,iBAAiB;EACjBG,aAAa;EACbC,mBAAmB;EACnBC,oBAAoB;EACpBC,mCAAmC;EAEnCC,aAAa;EACbc,KAAK;EACLe,IAAI;EACJ2B,OAAO;EACP1E,KAAK;EAEL4F,sBAAsB;EACtBC,oBAAoB;EACpBC,yBAAyB;EACzBiB,mBAAmB;EACnBC,qBAAqB;EACrBC,kBAAkB;EAClBC,cAAc;EACdC,OAAO;EACPC,oBAAoB;EACpBC;AACF,CAAC;AAED,eAAeC,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|