react-native-qpush 0.0.0-stage → 1.0.0

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 (98) hide show
  1. package/README.md +439 -2
  2. package/android/build.gradle +77 -0
  3. package/android/gradle.properties +5 -0
  4. package/android/proguard-rules.pro +5 -0
  5. package/android/src/main/AndroidManifest.xml +29 -0
  6. package/android/src/main/java/com/qpush/reactnative/QPushDeviceInfo.kt +96 -0
  7. package/android/src/main/java/com/qpush/reactnative/QPushEventBus.kt +153 -0
  8. package/android/src/main/java/com/qpush/reactnative/QPushFcm.kt +108 -0
  9. package/android/src/main/java/com/qpush/reactnative/QPushHttp.kt +92 -0
  10. package/android/src/main/java/com/qpush/reactnative/QPushImages.kt +103 -0
  11. package/android/src/main/java/com/qpush/reactnative/QPushLog.kt +39 -0
  12. package/android/src/main/java/com/qpush/reactnative/QPushMessagingService.kt +77 -0
  13. package/android/src/main/java/com/qpush/reactnative/QPushNotificationOpenActivity.kt +121 -0
  14. package/android/src/main/java/com/qpush/reactnative/QPushNotificationRenderer.kt +256 -0
  15. package/android/src/main/java/com/qpush/reactnative/QPushPayload.kt +114 -0
  16. package/android/src/main/java/com/qpush/reactnative/QPushPushModule.kt +368 -0
  17. package/android/src/main/java/com/qpush/reactnative/QPushPushPackage.kt +15 -0
  18. package/android/src/main/java/com/qpush/reactnative/QPushStore.kt +108 -0
  19. package/android/src/main/res/values/qpush_strings.xml +6 -0
  20. package/app.plugin.js +1 -0
  21. package/ios/Extension/QPushNotificationServiceExtension.swift +261 -0
  22. package/ios/Extension/QPushPushExtension.podspec +34 -0
  23. package/ios/QPushPush.m +62 -0
  24. package/ios/QPushPush.swift +186 -0
  25. package/ios/QPushPushBridge.h +5 -0
  26. package/ios/QPushPushCore.swift +457 -0
  27. package/ios/QPushPushHooks.m +237 -0
  28. package/ios/QPushPushSupport.swift +249 -0
  29. package/ios_nse_template/Info.plist +38 -0
  30. package/ios_nse_template/NotificationService.entitlements +10 -0
  31. package/ios_nse_template/NotificationService.swift +44 -0
  32. package/lib/NativeQPushPush.d.ts +44 -0
  33. package/lib/NativeQPushPush.js +4 -0
  34. package/lib/QPush.d.ts +117 -0
  35. package/lib/QPush.js +206 -0
  36. package/lib/core/QPushCore.d.ts +148 -0
  37. package/lib/core/QPushCore.js +1387 -0
  38. package/lib/core/constants.d.ts +37 -0
  39. package/lib/core/constants.js +40 -0
  40. package/lib/core/events.d.ts +11 -0
  41. package/lib/core/events.js +40 -0
  42. package/lib/core/http.d.ts +41 -0
  43. package/lib/core/http.js +123 -0
  44. package/lib/core/logger.d.ts +18 -0
  45. package/lib/core/logger.js +43 -0
  46. package/lib/core/operationQueue.d.ts +117 -0
  47. package/lib/core/operationQueue.js +264 -0
  48. package/lib/core/operations.d.ts +80 -0
  49. package/lib/core/operations.js +88 -0
  50. package/lib/core/payload.d.ts +20 -0
  51. package/lib/core/payload.js +187 -0
  52. package/lib/core/platform.d.ts +72 -0
  53. package/lib/core/platform.js +7 -0
  54. package/lib/core/state.d.ts +51 -0
  55. package/lib/core/state.js +74 -0
  56. package/lib/core/storage.d.ts +34 -0
  57. package/lib/core/storage.js +68 -0
  58. package/lib/core/subscription.d.ts +67 -0
  59. package/lib/core/subscription.js +98 -0
  60. package/lib/core/tags.d.ts +39 -0
  61. package/lib/core/tags.js +123 -0
  62. package/lib/core/url.d.ts +17 -0
  63. package/lib/core/url.js +64 -0
  64. package/lib/core/uuid.d.ts +2 -0
  65. package/lib/core/uuid.js +18 -0
  66. package/lib/index.d.ts +7 -0
  67. package/lib/index.js +15 -0
  68. package/lib/notification.d.ts +67 -0
  69. package/lib/notification.js +73 -0
  70. package/lib/reactNativePlatform.d.ts +3 -0
  71. package/lib/reactNativePlatform.js +164 -0
  72. package/lib/types.d.ts +157 -0
  73. package/lib/types.js +31 -0
  74. package/package.json +70 -4
  75. package/plugin/withQPush.js +330 -0
  76. package/react-native-qpush.podspec +30 -0
  77. package/react-native.config.js +18 -0
  78. package/src/NativeQPushPush.ts +57 -0
  79. package/src/QPush.ts +292 -0
  80. package/src/core/QPushCore.ts +1515 -0
  81. package/src/core/constants.ts +42 -0
  82. package/src/core/events.ts +34 -0
  83. package/src/core/http.ts +146 -0
  84. package/src/core/logger.ts +42 -0
  85. package/src/core/operationQueue.ts +324 -0
  86. package/src/core/operations.ts +166 -0
  87. package/src/core/payload.ts +175 -0
  88. package/src/core/platform.ts +84 -0
  89. package/src/core/state.ts +127 -0
  90. package/src/core/storage.ts +76 -0
  91. package/src/core/subscription.ts +133 -0
  92. package/src/core/tags.ts +116 -0
  93. package/src/core/url.ts +58 -0
  94. package/src/core/uuid.ts +13 -0
  95. package/src/index.ts +23 -0
  96. package/src/notification.ts +113 -0
  97. package/src/reactNativePlatform.ts +172 -0
  98. package/src/types.ts +174 -0
package/src/types.ts ADDED
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Public types of react-native-qpush.
3
+ *
4
+ * Names and shapes intentionally mirror OneSignal's React Native SDK v5 so
5
+ * migrating code is mostly a search & replace of `OneSignal` -> `QPush`.
6
+ */
7
+
8
+ /** Log verbosity, same numeric values as OneSignal's `LogLevel`. */
9
+ export enum LogLevel {
10
+ None = 0,
11
+ Fatal = 1,
12
+ Error = 2,
13
+ Warn = 3,
14
+ Info = 4,
15
+ Debug = 5,
16
+ Verbose = 6,
17
+ }
18
+
19
+ /** Native permission state (mirrors OneSignal's `OSNotificationPermission`). */
20
+ export enum NotificationPermission {
21
+ NotDetermined = 0,
22
+ Denied = 1,
23
+ Authorized = 2,
24
+ Provisional = 3,
25
+ Ephemeral = 4,
26
+ }
27
+
28
+ /** Permission state as reported by the native layer. */
29
+ export type PermissionStatus = 'notDetermined' | 'denied' | 'granted' | 'provisional' | 'ephemeral';
30
+
31
+ /** Base URL of the qpush cloud API, used when no serverUrl is given. */
32
+ export const QPUSH_CLOUD_API_URL = 'https://qpush.dev/api/v1';
33
+
34
+ export interface QPushInitOptions {
35
+ /**
36
+ * API base URL. Defaults to the qpush cloud (`https://qpush.dev/api/v1`);
37
+ * set it only if you self-host. `/api/v1` is appended when missing.
38
+ */
39
+ serverUrl?: string;
40
+ /** Optional log level applied before anything else runs. */
41
+ logLevel?: LogLevel;
42
+ }
43
+
44
+ /** An action button attached to a notification. */
45
+ export interface ActionButton {
46
+ id: string;
47
+ text: string;
48
+ /** Android drawable resource name. */
49
+ icon?: string;
50
+ url?: string;
51
+ }
52
+
53
+ /** Normalized notification content (platform independent). */
54
+ export interface QPushNotificationData {
55
+ /** QPush notification id (uuid). */
56
+ notificationId: string;
57
+ title?: string;
58
+ subtitle?: string;
59
+ body?: string;
60
+ /** URL / deep link opened when the notification is tapped. */
61
+ launchURL?: string;
62
+ /** Custom JSON sent with the notification (`data`). */
63
+ additionalData?: Record<string, unknown>;
64
+ /** Big picture (Android) / attachment (iOS) image URL. */
65
+ bigPicture?: string;
66
+ largeIcon?: string;
67
+ smallIcon?: string;
68
+ /** ARGB hex, e.g. `FF0070F3` (Android). */
69
+ accentColor?: string;
70
+ sound?: string;
71
+ /** Android notification channel id. */
72
+ channelId?: string;
73
+ /** 10 = high, 5 = normal (Android). */
74
+ priority?: number;
75
+ /** Android group key / iOS thread-id. */
76
+ groupKey?: string;
77
+ collapseId?: string;
78
+ /** 1 public, 0 private, -1 secret (Android). */
79
+ visibility?: number;
80
+ /** iOS badge value from `aps.badge`. */
81
+ badge?: number;
82
+ /** iOS category identifier. */
83
+ category?: string;
84
+ /** iOS interruption level (`passive`, `active`, `time-sensitive`, `critical`). */
85
+ interruptionLevel?: string;
86
+ /** iOS relevance score (0..1). */
87
+ relevanceScore?: number;
88
+ /** `true` for background / silent pushes (iOS `content-available`). */
89
+ contentAvailable?: boolean;
90
+ actionButtons?: ActionButton[];
91
+ /** The untouched payload as received from the OS. */
92
+ rawPayload: Record<string, unknown>;
93
+ }
94
+
95
+ /** Result of a notification click. */
96
+ export interface NotificationClickResult {
97
+ /** Id of the tapped action button, when a button was tapped. */
98
+ actionId?: string;
99
+ /** URL that was (or would have been) opened. Button URL wins over the notification URL. */
100
+ url?: string;
101
+ }
102
+
103
+ export interface PushSubscriptionState {
104
+ id: string | null;
105
+ token: string | null;
106
+ optedIn: boolean;
107
+ }
108
+
109
+ export interface PushSubscriptionChangedState {
110
+ previous: PushSubscriptionState;
111
+ current: PushSubscriptionState;
112
+ }
113
+
114
+ export interface UserState {
115
+ qpushId: string | null;
116
+ externalId: string | null;
117
+ }
118
+
119
+ export interface UserChangedState {
120
+ current: UserState;
121
+ }
122
+
123
+ /** FCM parameters returned by `GET /apps/{app_id}/android_params.js`. */
124
+ export interface FcmParams {
125
+ project_id: string;
126
+ app_id: string;
127
+ api_key: string;
128
+ sender_id: string;
129
+ }
130
+
131
+ export interface AndroidParams {
132
+ app_id: string;
133
+ fcm: FcmParams | null;
134
+ use_identity_verification?: boolean;
135
+ }
136
+
137
+ export interface IosParams {
138
+ app_id: string;
139
+ apns_configured?: boolean;
140
+ environment?: string;
141
+ use_identity_verification?: boolean;
142
+ }
143
+
144
+ /** Subscription object as defined by the QPush protocol. */
145
+ export interface SubscriptionPayload {
146
+ id?: string;
147
+ type: 'AndroidPush' | 'iOSPush';
148
+ token?: string | null;
149
+ enabled: boolean;
150
+ notification_types: number;
151
+ session_count?: number;
152
+ device_model?: string;
153
+ device_os?: string;
154
+ sdk: string;
155
+ app_version?: string;
156
+ test_type?: number | null;
157
+ carrier?: string;
158
+ rooted?: boolean;
159
+ net_type?: number;
160
+ }
161
+
162
+ /** User object as defined by the QPush protocol. */
163
+ export interface UserPayload {
164
+ identity: Record<string, string>;
165
+ properties?: {
166
+ language?: string;
167
+ timezone_id?: string;
168
+ country?: string;
169
+ tags?: Record<string, string>;
170
+ first_active?: number;
171
+ last_active?: number;
172
+ };
173
+ subscriptions?: SubscriptionPayload[];
174
+ }