vibes-react-native 1.1.7 → 5.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 (31) hide show
  1. package/android/build.gradle +16 -8
  2. package/android/libs/maven/com/vibes/vibes-android-push-sdk/5.0.0/vibes-android-push-sdk-5.0.0.aar +0 -0
  3. package/android/libs/maven/com/vibes/vibes-android-push-sdk/5.0.0/vibes-android-push-sdk-5.0.0.pom +32 -0
  4. package/android/src/main/java/com/vibes/push/rn/plugin/VibesModule.java +38 -55
  5. package/android/src/main/java/com/vibes/push/rn/plugin/notifications/VibesPushReceiver.java +30 -0
  6. package/ios/Vibes.m +6 -2
  7. package/ios/Vibes.swift +67 -14
  8. package/lib/commonjs/index.js +68 -22
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/types.js +2 -0
  11. package/lib/commonjs/types.js.map +1 -0
  12. package/lib/module/index.js +67 -23
  13. package/lib/module/index.js.map +1 -1
  14. package/lib/module/types.js +2 -0
  15. package/lib/module/types.js.map +1 -0
  16. package/lib/typescript/index.d.ts +27 -32
  17. package/lib/typescript/types.d.ts +27 -0
  18. package/package.json +44 -54
  19. package/src/index.tsx +99 -56
  20. package/src/types.ts +31 -0
  21. package/vibes-react-native.podspec +2 -2
  22. package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
  23. package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
  24. package/android/.gradle/6.8/gc.properties +0 -0
  25. package/android/.gradle/checksums/checksums.lock +0 -0
  26. package/android/.gradle/configuration-cache/gc.properties +0 -0
  27. package/android/.gradle/nb-cache/trust/0FE3017D1D91C06BBB23B2D967E1CF942770CADF1DE28563D6C5A7D96E872CFD +0 -1
  28. package/android/.gradle/vcs-1/gc.properties +0 -0
  29. package/ios/Vibes.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  30. package/ios/Vibes.xcodeproj/project.xcworkspace/xcuserdata/ed.lafoy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  31. package/ios/Vibes.xcodeproj/xcuserdata/ed.lafoy.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/src/index.tsx CHANGED
@@ -1,4 +1,20 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import { NativeModules, PermissionsAndroid, Platform } from 'react-native';
2
+
3
+ import type {
4
+ AssociatePersonResponse,
5
+ DeviceInfoResponse,
6
+ DeviceResponse,
7
+ InboxMessage,
8
+ PersonResponse,
9
+ } from './types';
10
+
11
+ export type {
12
+ AssociatePersonResponse,
13
+ DeviceInfoResponse,
14
+ DeviceResponse,
15
+ InboxMessage,
16
+ PersonResponse,
17
+ } from './types';
2
18
 
3
19
  const LINKING_ERROR =
4
20
  `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \n\n` +
@@ -6,41 +22,24 @@ const LINKING_ERROR =
6
22
  '- You rebuilt the app after installing the package\n' +
7
23
  '- You are not using Expo managed workflow\n';
8
24
 
9
- const Vibes = NativeModules.Vibes
25
+ const NativeVibes = NativeModules.Vibes
10
26
  ? NativeModules.Vibes
11
27
  : new Proxy(
12
- {},
13
- {
14
- get() {
15
- throw new Error(LINKING_ERROR);
16
- },
17
- }
18
- );
19
-
20
- export interface DeviceResponse {
21
- device_id?: string;
22
- }
23
- export interface DeviceInfoResponse extends DeviceResponse {
24
- push_token?: string;
25
- }
26
-
27
- export interface PersonResponse {
28
- person_key?: string;
29
- external_person_id?: string;
30
- }
28
+ {},
29
+ {
30
+ get() {
31
+ throw new Error(LINKING_ERROR);
32
+ },
33
+ }
34
+ );
31
35
 
32
- export interface InboxMessage {
33
- content?: string;
34
- created_at?: string;
35
- expires_at?: string;
36
- message_uid?: string;
37
- read?: boolean;
38
- subject?: string;
39
- detail?: string;
40
- collapse_key?: string;
41
- apprefdata?: any;
42
- images?: any;
43
- inbox_custom_data: any;
36
+ /**
37
+ * Returns the wrapper SDK version string.
38
+ *
39
+ * @return {Promise<string>}
40
+ */
41
+ export function getSDKVersion(): Promise<string> {
42
+ return NativeVibes.getSDKVersion();
44
43
  }
45
44
 
46
45
  /**
@@ -49,7 +48,7 @@ export interface InboxMessage {
49
48
  * @return {Promise<DeviceResponse>}
50
49
  */
51
50
  export function registerDevice(): Promise<DeviceResponse> {
52
- return Vibes.registerDevice();
51
+ return NativeVibes.registerDevice();
53
52
  }
54
53
  /**
55
54
  * Unregister this device with the Vibes platform
@@ -57,7 +56,7 @@ export function registerDevice(): Promise<DeviceResponse> {
57
56
  * @return {Promise<void>}
58
57
  */
59
58
  export function unregisterDevice(): Promise<void> {
60
- return Vibes.unregisterDevice();
59
+ return NativeVibes.unregisterDevice();
61
60
  }
62
61
 
63
62
  /**
@@ -66,16 +65,16 @@ export function unregisterDevice(): Promise<void> {
66
65
  * @return {Promise<void>}
67
66
  */
68
67
  export function registerPush(): Promise<void> {
69
- return Vibes.registerPush();
68
+ return NativeVibes.registerPush();
70
69
  }
71
70
 
72
71
  /**
73
- * Unregister the device from receiving push notifications
74
- *
75
- * @return {Promise<void>}
76
- */
72
+ * Unregister the device from receiving push notifications
73
+ *
74
+ * @return {Promise<void>}
75
+ */
77
76
  export function unregisterPush(): Promise<void> {
78
- return Vibes.registerPush();
77
+ return NativeVibes.unregisterPush();
79
78
  }
80
79
 
81
80
  /**
@@ -84,7 +83,7 @@ export function unregisterPush(): Promise<void> {
84
83
  * @return {Promise<DeviceInfoResponse>}
85
84
  */
86
85
  export function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {
87
- return Vibes.getVibesDeviceInfo();
86
+ return NativeVibes.getVibesDeviceInfo();
88
87
  }
89
88
 
90
89
  /**
@@ -100,17 +99,19 @@ export function updateDevice(
100
99
  latitude: number,
101
100
  longitude: number
102
101
  ): Promise<void> {
103
- return Vibes.updateDevice(updateCredential, latitude, longitude);
102
+ return NativeVibes.updateDevice(updateCredential, latitude, longitude);
104
103
  }
105
104
 
106
105
  /**
107
106
  * Associate an external ID with the current person.
108
107
  *
109
108
  * @param {string} externalPersonId
110
- * @return {Promise<void>}
109
+ * @return {Promise<AssociatePersonResponse>}
111
110
  */
112
- export function associatePerson(externalPersonId: string): Promise<void> {
113
- return Vibes.associatePerson(externalPersonId);
111
+ export function associatePerson(
112
+ externalPersonId: string
113
+ ): Promise<AssociatePersonResponse> {
114
+ return NativeVibes.associatePerson(externalPersonId);
114
115
  }
115
116
 
116
117
  /**
@@ -119,7 +120,7 @@ export function associatePerson(externalPersonId: string): Promise<void> {
119
120
  * @return {Promise<PersonResponse>}
120
121
  */
121
122
  export function getPerson(): Promise<PersonResponse> {
122
- return Vibes.getPerson();
123
+ return NativeVibes.getPerson();
123
124
  }
124
125
  /**
125
126
  * Fetches an array of inbox messages for the person associated with this device.
@@ -127,7 +128,7 @@ export function getPerson(): Promise<PersonResponse> {
127
128
  * @return {Promise<InboxMessage[]>}
128
129
  */
129
130
  export function fetchInboxMessages(): Promise<InboxMessage[]> {
130
- return Vibes.fetchInboxMessages();
131
+ return NativeVibes.fetchInboxMessages();
131
132
  }
132
133
 
133
134
  /**
@@ -137,7 +138,7 @@ export function fetchInboxMessages(): Promise<InboxMessage[]> {
137
138
  * @return {Promise<InboxMessage>}
138
139
  */
139
140
  export function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {
140
- return Vibes.fetchInboxMessage(message_uid);
141
+ return NativeVibes.fetchInboxMessage(message_uid);
141
142
  }
142
143
 
143
144
  /**
@@ -146,8 +147,10 @@ export function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {
146
147
  * @param {string} message_uid
147
148
  * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
148
149
  */
149
- export function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {
150
- return Vibes.markInboxMessageAsRead(message_uid);
150
+ export function markInboxMessageAsRead(
151
+ message_uid: string
152
+ ): Promise<InboxMessage> {
153
+ return NativeVibes.markInboxMessageAsRead(message_uid);
151
154
  }
152
155
 
153
156
  /**
@@ -157,17 +160,17 @@ export function markInboxMessageAsRead(message_uid: string): Promise<InboxMessag
157
160
  * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
158
161
  */
159
162
  export function expireInboxMessage(message_uid: string): Promise<InboxMessage> {
160
- return Vibes.expireInboxMessage(message_uid);
163
+ return NativeVibes.expireInboxMessage(message_uid);
161
164
  }
162
165
 
163
166
  /**
164
167
  * Records an event for when the user opens an inbox message.
165
168
  *
166
- * @param inboxMap json map of the InboxMessage
169
+ * @param inboxMessage - json map of the InboxMessage
167
170
  * @return {Promise<void>}
168
171
  */
169
- export function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {
170
- return Vibes.onInboxMessageOpen(inboxMap);
172
+ export function onInboxMessageOpen(inboxMessage: InboxMessage): Promise<void> {
173
+ return NativeVibes.onInboxMessageOpen(inboxMessage);
171
174
  }
172
175
 
173
176
  /**
@@ -176,7 +179,47 @@ export function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {
176
179
  * @return {Promise<void>}
177
180
  */
178
181
  export function onInboxMessagesFetched(): Promise<void> {
179
- return Vibes.onInboxMessagesFetched();
182
+ return NativeVibes.onInboxMessagesFetched();
183
+ }
184
+
185
+ /**
186
+ * Requests notification permissions from the OS.
187
+ *
188
+ * - iOS: prompts via UNUserNotificationCenter and registers for remote notifications
189
+ * - Android 13+: requests POST_NOTIFICATIONS via PermissionsAndroid
190
+ * - Android 12 and below: no-op (permission not required)
191
+ *
192
+ * @return {Promise<void>}
193
+ */
194
+ export async function requestNotificationPermissions(): Promise<void> {
195
+ if (Platform.OS === 'android') {
196
+ const apiLevel =
197
+ typeof Platform.Version === 'number'
198
+ ? Platform.Version
199
+ : parseInt(String(Platform.Version), 10);
200
+ // POST_NOTIFICATIONS is only required on Android 13+ (API 33)
201
+ if (!Number.isNaN(apiLevel) && apiLevel < 33) {
202
+ return;
203
+ }
204
+ const result = await PermissionsAndroid.request(
205
+ PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
206
+ );
207
+ if (result !== PermissionsAndroid.RESULTS.GRANTED) {
208
+ throw new Error('Notification permissions denied');
209
+ }
210
+ return;
211
+ }
212
+ return NativeVibes.requestNotificationPermissions();
180
213
  }
181
214
 
215
+ const Vibes = new Proxy(NativeVibes, {
216
+ get(target, prop, receiver) {
217
+ if (prop === 'requestNotificationPermissions') {
218
+ return requestNotificationPermissions;
219
+ }
220
+ const value = Reflect.get(target, prop, receiver);
221
+ return typeof value === 'function' ? value.bind(target) : value;
222
+ },
223
+ });
224
+
182
225
  export default Vibes;
package/src/types.ts ADDED
@@ -0,0 +1,31 @@
1
+ export interface DeviceResponse {
2
+ device_id?: string;
3
+ }
4
+
5
+ export interface DeviceInfoResponse extends DeviceResponse {
6
+ push_token?: string;
7
+ }
8
+
9
+ export interface PersonResponse {
10
+ person_key?: string;
11
+ external_person_id?: string;
12
+ }
13
+
14
+ export interface AssociatePersonResponse {
15
+ externalPersonId: string;
16
+ status: string;
17
+ }
18
+
19
+ export interface InboxMessage {
20
+ content?: string;
21
+ created_at?: string;
22
+ expires_at?: string;
23
+ message_uid?: string;
24
+ read?: boolean;
25
+ subject?: string;
26
+ detail?: string;
27
+ collapse_key?: string;
28
+ apprefdata?: any;
29
+ images?: any;
30
+ inbox_custom_data: any;
31
+ }
@@ -10,11 +10,11 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => "10.0" }
13
+ s.platforms = { :ios => "15.6" }
14
14
  s.source = { :git => "https://github.com/vibes/vibes-react-native.git", :tag => "#{s.version}" }
15
15
 
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
18
  s.dependency "React-Core"
19
- s.dependency "VibesPush", "4.7.0"
19
+ s.dependency "VibesPush", "5.0.0"
20
20
  end
File without changes
File without changes
@@ -1 +0,0 @@
1
- 61C79B06CD533399D1E28DE57C95268CA2764F2F1B5E0EFE56779638FB58E6F5
File without changes
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Vibes.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>