vibes-react-native 1.0.0 → 1.1.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.
@@ -1,8 +1,117 @@
1
1
  declare const Vibes: any;
2
- export declare function registerDevice(): Promise<any>;
3
- export declare function unregisterDevice(): Promise<any>;
4
- export declare function registerPush(): Promise<any>;
5
- export declare function getVibesDeviceInfo(): Promise<any>;
6
- export declare function updateDevice(updateCredential: boolean, latitude: number, longitude: number): Promise<any>;
7
- export declare function associatePerson(externalPersonId: string): Promise<any>;
2
+ export interface DeviceResponse {
3
+ device_id?: string;
4
+ }
5
+ export interface DeviceInfoResponse extends DeviceResponse {
6
+ push_token?: string;
7
+ }
8
+ export interface PersonResponse {
9
+ person_key?: string;
10
+ external_person_id?: string;
11
+ }
12
+ export interface InboxMessage {
13
+ content?: string;
14
+ created_at?: string;
15
+ expires_at?: string;
16
+ message_uid?: string;
17
+ read?: boolean;
18
+ subject?: string;
19
+ detail?: string;
20
+ collapse_key?: string;
21
+ apprefdata?: any;
22
+ images?: any;
23
+ inbox_custom_data: any;
24
+ }
25
+ /**
26
+ * Register this device with the Vibes platform
27
+ *
28
+ * @return {Promise<DeviceResponse>}
29
+ */
30
+ export declare function registerDevice(): Promise<DeviceResponse>;
31
+ /**
32
+ * Unregister this device with the Vibes platform
33
+ *
34
+ * @return {Promise<void>}
35
+ */
36
+ export declare function unregisterDevice(): Promise<void>;
37
+ /**
38
+ * Register this device to receive push notifications
39
+ *
40
+ * @return {Promise<void>}
41
+ */
42
+ export declare function registerPush(): Promise<void>;
43
+ /**
44
+ * Unregister the device from receiving push notifications
45
+ *
46
+ * @return {Promise<void>}
47
+ */
48
+ export declare function unregisterPush(): Promise<void>;
49
+ /**
50
+ * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
51
+ *
52
+ * @return {Promise<DeviceInfoResponse>}
53
+ */
54
+ export declare function getVibesDeviceInfo(): Promise<DeviceInfoResponse>;
55
+ /**
56
+ * Updates the Vibes platform with changes to the device since the last time device information was submitted.
57
+ *
58
+ * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.
59
+ * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
60
+ * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
61
+ * @returns {Promise<void>}
62
+ */
63
+ export declare function updateDevice(updateCredential: boolean, latitude: number, longitude: number): Promise<void>;
64
+ /**
65
+ * Associate an external ID with the current person.
66
+ *
67
+ * @param {string} externalPersonId
68
+ * @return {Promise<void>}
69
+ */
70
+ export declare function associatePerson(externalPersonId: string): Promise<void>;
71
+ /**
72
+ * Fetches the PersonResponse associated with this device currently
73
+ *
74
+ * @return {Promise<PersonResponse>}
75
+ */
76
+ export declare function getPerson(): Promise<PersonResponse>;
77
+ /**
78
+ * Fetches an array of inbox messages for the person associated with this device.
79
+ *
80
+ * @return {Promise<InboxMessage[]>}
81
+ */
82
+ export declare function fetchInboxMessages(): Promise<InboxMessage[]>;
83
+ /**
84
+ * Fetches a single inbox message by it's id.
85
+ *
86
+ * @param {string} message_uid
87
+ * @return {Promise<InboxMessage>}
88
+ */
89
+ export declare function fetchInboxMessage(message_uid: string): Promise<InboxMessage>;
90
+ /**
91
+ * Marks an inbox message as read.
92
+ *
93
+ * @param {string} message_uid
94
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
95
+ */
96
+ export declare function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage>;
97
+ /**
98
+ * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date
99
+ *
100
+ * @param {string} message_uid
101
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
102
+ */
103
+ export declare function expireInboxMessage(message_uid: string): Promise<InboxMessage>;
104
+ /**
105
+ * Records an event for when the user opens an inbox message.
106
+ *
107
+ * @param inboxMap json map of the InboxMessage
108
+ * @return {Promise<void>}
109
+ */
110
+ export declare function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void>;
111
+ /**
112
+ * Records an event for when the user fetches a list of inbox messages.
113
+ *
114
+ * @return {Promise<void>}
115
+ */
116
+ export declare function onInboxMessagesFetched(): Promise<void>;
8
117
  export default Vibes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibes-react-native",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "The React Native plugin for the Vibes Mobile SDKs",
5
5
  "author": "Vibes",
6
6
  "main": "lib/commonjs/index",
package/src/index.tsx CHANGED
@@ -9,40 +9,174 @@ const LINKING_ERROR =
9
9
  const Vibes = NativeModules.Vibes
10
10
  ? NativeModules.Vibes
11
11
  : new Proxy(
12
- {},
13
- {
14
- get() {
15
- throw new Error(LINKING_ERROR);
16
- },
17
- }
18
- );
19
-
20
- export function registerDevice(): Promise<any> {
21
- return Vibes.registerDevice();
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
+ }
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;
22
44
  }
23
45
 
24
- export function unregisterDevice(): Promise<any> {
46
+ /**
47
+ * Register this device with the Vibes platform
48
+ *
49
+ * @return {Promise<DeviceResponse>}
50
+ */
51
+ export function registerDevice(): Promise<DeviceResponse> {
52
+ return Vibes.registerDevice();
53
+ }
54
+ /**
55
+ * Unregister this device with the Vibes platform
56
+ *
57
+ * @return {Promise<void>}
58
+ */
59
+ export function unregisterDevice(): Promise<void> {
25
60
  return Vibes.unregisterDevice();
26
61
  }
27
62
 
28
- export function registerPush(): Promise<any> {
63
+ /**
64
+ * Register this device to receive push notifications
65
+ *
66
+ * @return {Promise<void>}
67
+ */
68
+ export function registerPush(): Promise<void> {
69
+ return Vibes.registerPush();
70
+ }
71
+
72
+ /**
73
+ * Unregister the device from receiving push notifications
74
+ *
75
+ * @return {Promise<void>}
76
+ */
77
+ export function unregisterPush(): Promise<void> {
29
78
  return Vibes.registerPush();
30
79
  }
31
80
 
32
- export function getVibesDeviceInfo(): Promise<any> {
81
+ /**
82
+ * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
83
+ *
84
+ * @return {Promise<DeviceInfoResponse>}
85
+ */
86
+ export function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {
33
87
  return Vibes.getVibesDeviceInfo();
34
88
  }
35
89
 
90
+ /**
91
+ * Updates the Vibes platform with changes to the device since the last time device information was submitted.
92
+ *
93
+ * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.
94
+ * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
95
+ * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
96
+ * @returns {Promise<void>}
97
+ */
36
98
  export function updateDevice(
37
99
  updateCredential: boolean,
38
100
  latitude: number,
39
101
  longitude: number
40
- ): Promise<any> {
102
+ ): Promise<void> {
41
103
  return Vibes.updateDevice(updateCredential, latitude, longitude);
42
104
  }
43
105
 
44
- export function associatePerson(externalPersonId: string): Promise<any> {
106
+ /**
107
+ * Associate an external ID with the current person.
108
+ *
109
+ * @param {string} externalPersonId
110
+ * @return {Promise<void>}
111
+ */
112
+ export function associatePerson(externalPersonId: string): Promise<void> {
45
113
  return Vibes.associatePerson(externalPersonId);
46
114
  }
47
115
 
116
+ /**
117
+ * Fetches the PersonResponse associated with this device currently
118
+ *
119
+ * @return {Promise<PersonResponse>}
120
+ */
121
+ export function getPerson(): Promise<PersonResponse> {
122
+ return Vibes.getPerson();
123
+ }
124
+ /**
125
+ * Fetches an array of inbox messages for the person associated with this device.
126
+ *
127
+ * @return {Promise<InboxMessage[]>}
128
+ */
129
+ export function fetchInboxMessages(): Promise<InboxMessage[]> {
130
+ return Vibes.fetchInboxMessages();
131
+ }
132
+
133
+ /**
134
+ * Fetches a single inbox message by it's id.
135
+ *
136
+ * @param {string} message_uid
137
+ * @return {Promise<InboxMessage>}
138
+ */
139
+ export function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {
140
+ return Vibes.fetchInboxMessage(message_uid);
141
+ }
142
+
143
+ /**
144
+ * Marks an inbox message as read.
145
+ *
146
+ * @param {string} message_uid
147
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
148
+ */
149
+ export function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {
150
+ return Vibes.markInboxMessageAsRead(message_uid);
151
+ }
152
+
153
+ /**
154
+ * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date
155
+ *
156
+ * @param {string} message_uid
157
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
158
+ */
159
+ export function expireInboxMessage(message_uid: string): Promise<InboxMessage> {
160
+ return Vibes.expireInboxMessage(message_uid);
161
+ }
162
+
163
+ /**
164
+ * Records an event for when the user opens an inbox message.
165
+ *
166
+ * @param inboxMap json map of the InboxMessage
167
+ * @return {Promise<void>}
168
+ */
169
+ export function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {
170
+ return Vibes.onInboxMessageOpen(inboxMap);
171
+ }
172
+
173
+ /**
174
+ * Records an event for when the user fetches a list of inbox messages.
175
+ *
176
+ * @return {Promise<void>}
177
+ */
178
+ export function onInboxMessagesFetched(): Promise<void> {
179
+ return Vibes.onInboxMessagesFetched();
180
+ }
181
+
48
182
  export default Vibes;
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
18
  s.dependency "React-Core"
19
- s.dependency "VibesPush", "4.5.0"
19
+ s.dependency "VibesPush", "4.7.0"
20
20
  end