vibes-react-native 1.1.8 → 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.
- package/android/build.gradle +16 -8
- package/android/libs/maven/com/vibes/vibes-android-push-sdk/5.0.0/vibes-android-push-sdk-5.0.0.aar +0 -0
- package/android/libs/maven/com/vibes/vibes-android-push-sdk/5.0.0/vibes-android-push-sdk-5.0.0.pom +32 -0
- package/android/src/main/java/com/vibes/push/rn/plugin/VibesModule.java +38 -55
- package/android/src/main/java/com/vibes/push/rn/plugin/notifications/VibesPushReceiver.java +30 -0
- package/ios/Vibes.m +6 -2
- package/ios/Vibes.swift +67 -14
- package/lib/commonjs/index.js +64 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/index.js +63 -19
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/index.d.ts +23 -28
- package/lib/typescript/types.d.ts +27 -0
- package/package.json +31 -6
- package/src/index.tsx +85 -44
- package/src/types.ts +31 -0
- package/vibes-react-native.podspec +2 -2
- package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.8/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/nb-cache/trust/0FE3017D1D91C06BBB23B2D967E1CF942770CADF1DE28563D6C5A7D96E872CFD +0 -1
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/ios/Vibes.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Vibes.xcodeproj/project.xcworkspace/xcuserdata/ed.lafoy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- 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,7 +22,7 @@ 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
|
|
25
|
+
const NativeVibes = NativeModules.Vibes
|
|
10
26
|
? NativeModules.Vibes
|
|
11
27
|
: new Proxy(
|
|
12
28
|
{},
|
|
@@ -17,30 +33,13 @@ const Vibes = NativeModules.Vibes
|
|
|
17
33
|
}
|
|
18
34
|
);
|
|
19
35
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export interface PersonResponse {
|
|
28
|
-
person_key?: string;
|
|
29
|
-
external_person_id?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
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
|
|
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
|
|
59
|
+
return NativeVibes.unregisterDevice();
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
/**
|
|
@@ -66,7 +65,7 @@ export function unregisterDevice(): Promise<void> {
|
|
|
66
65
|
* @return {Promise<void>}
|
|
67
66
|
*/
|
|
68
67
|
export function registerPush(): Promise<void> {
|
|
69
|
-
return
|
|
68
|
+
return NativeVibes.registerPush();
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
/**
|
|
@@ -75,7 +74,7 @@ export function registerPush(): Promise<void> {
|
|
|
75
74
|
* @return {Promise<void>}
|
|
76
75
|
*/
|
|
77
76
|
export function unregisterPush(): Promise<void> {
|
|
78
|
-
return
|
|
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
|
|
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
|
|
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<
|
|
109
|
+
* @return {Promise<AssociatePersonResponse>}
|
|
111
110
|
*/
|
|
112
|
-
export function associatePerson(
|
|
113
|
-
|
|
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
|
|
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
|
|
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
|
|
141
|
+
return NativeVibes.fetchInboxMessage(message_uid);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -149,7 +150,7 @@ export function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {
|
|
|
149
150
|
export function markInboxMessageAsRead(
|
|
150
151
|
message_uid: string
|
|
151
152
|
): Promise<InboxMessage> {
|
|
152
|
-
return
|
|
153
|
+
return NativeVibes.markInboxMessageAsRead(message_uid);
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
/**
|
|
@@ -159,17 +160,17 @@ export function markInboxMessageAsRead(
|
|
|
159
160
|
* @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
|
|
160
161
|
*/
|
|
161
162
|
export function expireInboxMessage(message_uid: string): Promise<InboxMessage> {
|
|
162
|
-
return
|
|
163
|
+
return NativeVibes.expireInboxMessage(message_uid);
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
/**
|
|
166
167
|
* Records an event for when the user opens an inbox message.
|
|
167
168
|
*
|
|
168
|
-
* @param
|
|
169
|
+
* @param inboxMessage - json map of the InboxMessage
|
|
169
170
|
* @return {Promise<void>}
|
|
170
171
|
*/
|
|
171
|
-
export function onInboxMessageOpen(
|
|
172
|
-
return
|
|
172
|
+
export function onInboxMessageOpen(inboxMessage: InboxMessage): Promise<void> {
|
|
173
|
+
return NativeVibes.onInboxMessageOpen(inboxMessage);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
/**
|
|
@@ -178,7 +179,47 @@ export function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {
|
|
|
178
179
|
* @return {Promise<void>}
|
|
179
180
|
*/
|
|
180
181
|
export function onInboxMessagesFetched(): Promise<void> {
|
|
181
|
-
return
|
|
182
|
+
return NativeVibes.onInboxMessagesFetched();
|
|
182
183
|
}
|
|
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();
|
|
213
|
+
}
|
|
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
|
+
|
|
184
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 => "
|
|
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
|
-
|
|
19
|
+
s.dependency "VibesPush", "5.0.0"
|
|
20
20
|
end
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
61C79B06CD533399D1E28DE57C95268CA2764F2F1B5E0EFE56779638FB58E6F5
|
|
File without changes
|
|
Binary file
|
package/ios/Vibes.xcodeproj/xcuserdata/ed.lafoy.xcuserdatad/xcschemes/xcschememanagement.plist
DELETED
|
@@ -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>
|