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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +540 -0
  3. package/android/build.gradle +177 -0
  4. package/android/gradle.properties +15 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModuleImpl.kt +767 -0
  8. package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushPackage.kt +43 -0
  9. package/android/src/newarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +199 -0
  10. package/android/src/oldarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +249 -0
  11. package/appsonair-react-native-apppush.podspec +77 -0
  12. package/ios/AppsonairReactNativeApppush-Bridging-Header.h +12 -0
  13. package/ios/AppsonairReactNativeApppush.h +28 -0
  14. package/ios/AppsonairReactNativeApppush.mm +494 -0
  15. package/ios/AppsonairReactNativeApppushImpl.swift +594 -0
  16. package/lib/commonjs/NativeAppsonairApppush.js +48 -0
  17. package/lib/commonjs/NativeAppsonairApppush.js.map +1 -0
  18. package/lib/commonjs/index.js +686 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/types.js +2 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/module/NativeAppsonairApppush.js +47 -0
  23. package/lib/module/NativeAppsonairApppush.js.map +1 -0
  24. package/lib/module/index.js +612 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/types.js +2 -0
  27. package/lib/module/types.js.map +1 -0
  28. package/lib/typescript/commonjs/package.json +1 -0
  29. package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts +134 -0
  30. package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts.map +1 -0
  31. package/lib/typescript/commonjs/src/index.d.ts +392 -0
  32. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  33. package/lib/typescript/commonjs/src/types.d.ts +221 -0
  34. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  35. package/lib/typescript/module/package.json +1 -0
  36. package/lib/typescript/module/src/NativeAppsonairApppush.d.ts +134 -0
  37. package/lib/typescript/module/src/NativeAppsonairApppush.d.ts.map +1 -0
  38. package/lib/typescript/module/src/index.d.ts +392 -0
  39. package/lib/typescript/module/src/index.d.ts.map +1 -0
  40. package/lib/typescript/module/src/types.d.ts +221 -0
  41. package/lib/typescript/module/src/types.d.ts.map +1 -0
  42. package/package.json +119 -0
  43. package/react-native.config.js +14 -0
  44. package/src/NativeAppsonairApppush.ts +188 -0
  45. package/src/index.tsx +745 -0
  46. package/src/types.ts +284 -0
package/package.json ADDED
@@ -0,0 +1,119 @@
1
+ {
2
+ "name": "appsonair-react-native-apppush",
3
+ "version": "0.0.1-alpha",
4
+ "description": "AppsOnAir push notifications for React Native — wraps the native AppsOnAir iOS and Android Push SDKs",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./lib/typescript/module/src/index.d.ts",
13
+ "default": "./lib/module/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
17
+ "default": "./lib/commonjs/index.js"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "src",
23
+ "lib",
24
+ "android",
25
+ "ios",
26
+ "*.podspec",
27
+ "react-native.config.js",
28
+ "!ios/build",
29
+ "!android/build",
30
+ "!android/gradle",
31
+ "!android/gradlew",
32
+ "!android/gradlew.bat",
33
+ "!android/local.properties",
34
+ "!**/__tests__",
35
+ "!**/__fixtures__",
36
+ "!**/__mocks__",
37
+ "!**/.*"
38
+ ],
39
+ "workspaces": [
40
+ "example"
41
+ ],
42
+ "scripts": {
43
+ "typecheck": "tsc",
44
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
45
+ "clean": "del-cli android/build lib",
46
+ "prepare": "bob build"
47
+ },
48
+ "keywords": [
49
+ "react-native",
50
+ "ios",
51
+ "android",
52
+ "push",
53
+ "notifications",
54
+ "appsonair",
55
+ "turbomodule"
56
+ ],
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/apps-on-air/appsonair-react-native-push-notification.git"
60
+ },
61
+ "author": "Logicwind (https://github.com/devtools-logicwind)",
62
+ "license": "MIT",
63
+ "bugs": {
64
+ "url": "https://github.com/apps-on-air/appsonair-react-native-push-notification/issues"
65
+ },
66
+ "homepage": "https://github.com/apps-on-air/appsonair-react-native-push-notification#readme",
67
+ "publishConfig": {
68
+ "registry": "https://registry.npmjs.org/"
69
+ },
70
+ "devDependencies": {
71
+ "@react-native/eslint-config": "0.73.1",
72
+ "@types/react": "18.2.44",
73
+ "del-cli": "5.1.0",
74
+ "eslint": "8.51.0",
75
+ "eslint-config-prettier": "9.0.0",
76
+ "eslint-plugin-prettier": "5.0.1",
77
+ "prettier": "3.0.3",
78
+ "react": "18.3.1",
79
+ "react-native": "0.76.3",
80
+ "react-native-builder-bob": "0.33.3",
81
+ "typescript": "5.2.2"
82
+ },
83
+ "resolutions": {
84
+ "@types/react": "18.2.44"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "*",
88
+ "react-native": "*"
89
+ },
90
+ "codegenConfig": {
91
+ "name": "AppsonairReactNativeApppushSpec",
92
+ "type": "modules",
93
+ "jsSrcsDir": "src",
94
+ "android": {
95
+ "javaPackageName": "com.appsonairreactnativeapppush"
96
+ }
97
+ },
98
+ "react-native-builder-bob": {
99
+ "source": "src",
100
+ "output": "lib",
101
+ "targets": [
102
+ ["commonjs", { "esm": true }],
103
+ ["module", { "esm": true }],
104
+ ["typescript", { "project": "tsconfig.build.json", "esm": true }]
105
+ ]
106
+ },
107
+ "create-react-native-library": {
108
+ "type": "turbo-module",
109
+ "languages": "kotlin-swift",
110
+ "version": "0.48.9"
111
+ },
112
+ "prettier": {
113
+ "quoteProps": "consistent",
114
+ "singleQuote": true,
115
+ "tabWidth": 2,
116
+ "trailingComma": "es5",
117
+ "useTabs": false
118
+ }
119
+ }
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ ios: {},
5
+ android: {},
6
+ },
7
+ },
8
+ };
9
+
10
+ // No `spm` stanza: this package ships a podspec only. The sibling AppLink /
11
+ // AppSync / AppRemark wrappers declare one because they also ship an
12
+ // ios/Package.swift; adding the key without that manifest would advertise an
13
+ // SPM target that does not exist. See SPM_SUPPORT.md in AppRemark for the
14
+ // layout to copy if SPM support is added later.
@@ -0,0 +1,188 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
+
4
+ /**
5
+ * Codegen spec for the AppsOnAir Push TurboModule.
6
+ *
7
+ * This file is consumed by React Native Codegen and compiles to
8
+ * `NativeAppsonairApppushSpec` — a Java abstract class and an ObjC protocol that
9
+ * the native modules implement under the New Architecture. On the Old
10
+ * Architecture the same JS object is served by the legacy bridge module, which
11
+ * exposes an identical method set (see android/src/oldarch and the
12
+ * `RCT_NEW_ARCH_ENABLED` guard in ios/AppsonairReactNativeApppush.mm).
13
+ *
14
+ * Constraints this file must respect — codegen rejects or silently mistypes
15
+ * anything else, so do not "improve" the signatures below:
16
+ *
17
+ * - Parameters and returns are primitives, nullable primitives, `Array<T>`,
18
+ * or `UnsafeObject`. Named object types are avoided deliberately -- see the
19
+ * note above `Spec`.
20
+ * - No string-literal unions. `logLevel`, `importance` and `environment` are
21
+ * plain `string` here and are narrowed to their union types in `index.tsx`,
22
+ * which is the type-safe surface consumers actually import.
23
+ * - No `Record<K, V>` — use `UnsafeObject`.
24
+ * - Methods are `Promise`-returning or `void`; there are no sync methods, so
25
+ * the module never blocks the JS thread.
26
+ */
27
+
28
+ /**
29
+ * Object parameters are `UnsafeObject`, not named object types, and that is
30
+ * load-bearing rather than lazy.
31
+ *
32
+ * Codegen compiles a named object type into a generated C++ struct, so the
33
+ * ObjC signature becomes `JS::NativeAppsonairApppush::NativePushConfig &` under the
34
+ * New Architecture while the Old Architecture bridge still passes
35
+ * `NSDictionary *`. The two would no longer share a selector, and
36
+ * ios/AppsonairReactNativeApppush.mm could not implement both from one method body.
37
+ * `UnsafeObject` maps to `NSDictionary *` on both, and to `ReadableMap` on both
38
+ * on Android.
39
+ *
40
+ * The shapes these accept are typed for consumers in src/types.ts -- `PushConfig`,
41
+ * `NotificationChannelConfig` and `BackgroundSyncOptions` -- which is the surface
42
+ * anyone actually imports. Nothing here is untyped at the call site.
43
+ */
44
+
45
+ export interface Spec extends TurboModule {
46
+ // MARK: Lifecycle
47
+
48
+ /**
49
+ * Parity A1/A2: the native signatures share zero parameters — iOS takes
50
+ * `(debug:swizzle:)`, Android takes `(context, debug)`. Each
51
+ * bridge supplies what its platform needs; `Context` is never exposed to JS.
52
+ */
53
+ initialize(config: UnsafeObject): Promise<void>;
54
+
55
+ // MARK: Identity
56
+
57
+ getDeviceId(): Promise<string>;
58
+ getSubscriptionId(): Promise<string | null>;
59
+ setSubscriptionId(id: string): Promise<void>;
60
+ getExternalId(): Promise<string | null>;
61
+ login(externalId: string): Promise<void>;
62
+ logout(): Promise<void>;
63
+
64
+ // MARK: Token
65
+
66
+ /** APNs hex token on iOS, FCM token on Android. `null` before registration. */
67
+ getToken(): Promise<string | null>;
68
+ /** Parity D4: Android/FCM only. Resolves immediately as a no-op on iOS. */
69
+ refreshToken(): Promise<void>;
70
+ /** Parity B2: Android only. Resolves `null` on iOS. */
71
+ getInstallationId(): Promise<string | null>;
72
+ /** Parity C8: iOS only. Resolves `null` on Android. */
73
+ getApnsEnvironment(): Promise<string | null>;
74
+
75
+ // MARK: Permissions
76
+
77
+ requestPermission(fallbackToSettings: boolean): Promise<boolean>;
78
+ getPermission(): Promise<boolean>;
79
+ getPermissionStatus(): Promise<string>;
80
+ canRequestPermission(): Promise<boolean>;
81
+ /** Parity E5: iOS only. Resolves as a no-op on Android. */
82
+ registerForProvisionalAuthorization(): Promise<void>;
83
+
84
+ // MARK: Notifications
85
+
86
+ clearAllNotifications(): Promise<void>;
87
+ removeNotification(notificationId: string): Promise<void>;
88
+ removeNotifications(notificationIds: Array<string>): Promise<void>;
89
+ /** Parity F3: Android only. Resolves as a no-op on iOS. */
90
+ removeNotificationGroup(groupKey: string): Promise<void>;
91
+ /** Parity F4: Android only. Resolves as a no-op on iOS. */
92
+ createNotificationChannel(config: UnsafeObject): Promise<void>;
93
+ /** Parity F4: Android only. Resolves as a no-op on iOS. */
94
+ deleteNotificationChannel(channelId: string): Promise<void>;
95
+
96
+ // MARK: Badges
97
+
98
+ getBadgeCount(): Promise<number>;
99
+ setBadgeCount(count: number): Promise<void>;
100
+ incrementBadgeCount(delta: number): Promise<number>;
101
+ clearBadgeCount(): Promise<void>;
102
+ /** Parity G4: iOS only. Resolves as a no-op on Android. */
103
+ setAutoClearBadgeOnForeground(enabled: boolean): Promise<void>;
104
+
105
+ // MARK: APNs registration
106
+
107
+ /** iOS only. Resolves as a no-op on Android, where FCM always registers. */
108
+ setAutoRegisterForRemoteNotifications(enabled: boolean): Promise<void>;
109
+
110
+ // MARK: User — tags, aliases, emails, language
111
+
112
+ addTag(key: string, value: string): Promise<void>;
113
+ addTags(tags: UnsafeObject): Promise<void>;
114
+ removeTag(key: string): Promise<void>;
115
+ removeTags(keys: Array<string>): Promise<void>;
116
+ getTags(): Promise<UnsafeObject>;
117
+
118
+ addAlias(label: string, id: string): Promise<void>;
119
+ addAliases(aliases: UnsafeObject): Promise<void>;
120
+ removeAlias(label: string): Promise<void>;
121
+ removeAliases(labels: Array<string>): Promise<void>;
122
+
123
+ addEmail(address: string): Promise<void>;
124
+ removeEmail(address: string): Promise<void>;
125
+
126
+ setLanguage(languageCode: string): Promise<void>;
127
+ getLanguage(): Promise<string>;
128
+
129
+ // MARK: Push subscription
130
+
131
+ /** Resolves `{ id, token, optedIn }` from local state on both platforms. */
132
+ getPushSubscription(): Promise<UnsafeObject>;
133
+ optIn(): Promise<void>;
134
+ optOut(): Promise<void>;
135
+ /**
136
+ * The subscription's enabled state as the backend sees it. Android reads it
137
+ * back from /subscriptions; iOS computes the same flag it would send.
138
+ */
139
+ getOptedIn(): Promise<boolean>;
140
+
141
+ // MARK: Consent
142
+
143
+ setConsentRequired(required: boolean): Promise<void>;
144
+ getConsentRequired(): Promise<boolean>;
145
+ setConsentGiven(given: boolean): Promise<void>;
146
+ getConsentGiven(): Promise<boolean>;
147
+
148
+ // MARK: Test device
149
+
150
+ setTestDevice(enabled: boolean): Promise<void>;
151
+ isTestDevice(): Promise<boolean>;
152
+
153
+ // MARK: Background sync
154
+
155
+ scheduleBackgroundSync(options: UnsafeObject): Promise<void>;
156
+ cancelBackgroundSync(): Promise<void>;
157
+
158
+ // MARK: Debug
159
+
160
+ setLogLevel(level: string): Promise<void>;
161
+
162
+ // MARK: Foreground display control
163
+
164
+ /**
165
+ * Answers a pending `onNotificationWillDisplay` event. The native side holds
166
+ * the notification until this lands or the timeout elapses, which is what
167
+ * makes `preventDefault()` work across an async bridge.
168
+ *
169
+ * Not called directly — `onNotificationWillDisplay` wires it up.
170
+ */
171
+ completeNotificationWillDisplay(
172
+ notificationId: string,
173
+ display: boolean
174
+ ): Promise<void>;
175
+
176
+ // MARK: NativeEventEmitter plumbing
177
+
178
+ /**
179
+ * Required by `NativeEventEmitter` on both architectures. Under the New
180
+ * Architecture these also satisfy the TurboModule event-emitter contract.
181
+ */
182
+ addListener(eventName: string): void;
183
+ removeListeners(count: number): void;
184
+ }
185
+
186
+ export default TurboModuleRegistry.getEnforcing<Spec>(
187
+ 'AppsonairReactNativeApppush'
188
+ );