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.
@@ -16,8 +16,8 @@ import com.vibes.vibes.VibesReceiver;
16
16
 
17
17
  import static com.vibes.push.rn.plugin.VibesModule.TAG;
18
18
 
19
- public class VibesPushReceiver extends VibesReceiver{
20
-
19
+ public class VibesPushReceiver extends VibesReceiver {
20
+
21
21
  @Override
22
22
  protected void onPushOpened(Context context, PushPayloadParser pushModel) {
23
23
  super.onPushOpened(context, pushModel);
@@ -25,16 +25,18 @@ public class VibesPushReceiver extends VibesReceiver{
25
25
  emitPayload(context, pushModel);
26
26
  }
27
27
 
28
- private void emitPayload(Context context, PushPayloadParser pushModel) {
29
- final VibesPushReceiver serviceRef = this;
30
- // We need to run this on the main thread, as the React code assumes that is true.
31
- // Namely, DevServerHelper constructs a Handler() without a Looper, which triggers:
28
+ public static void emitPayload(Context context, PushPayloadParser pushModel) {
29
+ // We need to run this on the main thread, as the React code assumes that is
30
+ // true.
31
+ // Namely, DevServerHelper constructs a Handler() without a Looper, which
32
+ // triggers:
32
33
  // "Can't create handler inside thread that has not called Looper.prepare()"
33
34
  Handler handler = new Handler(Looper.getMainLooper());
34
35
  handler.post(new Runnable() {
35
36
  public void run() {
36
37
  // Construct and load our normal React JS code bundle
37
- final ReactInstanceManager mReactInstanceManager = ((ReactApplication) context.getApplicationContext()).getReactNativeHost().getReactInstanceManager();
38
+ final ReactInstanceManager mReactInstanceManager = ((ReactApplication) context.getApplicationContext())
39
+ .getReactNativeHost().getReactInstanceManager();
38
40
  ReactContext context = mReactInstanceManager.getCurrentReactContext();
39
41
  // If it's constructed, send a notification
40
42
  if (context != null) {
package/ios/Vibes.m CHANGED
@@ -27,5 +27,30 @@ RCT_EXTERN_METHOD(updateDevice: (BOOL ) updateCredentials
27
27
  resolver:(RCTPromiseResolveBlock *)resolve
28
28
  rejecter:(RCTPromiseRejectBlock *)reject)
29
29
 
30
+ RCT_EXTERN_METHOD(getPerson: (RCTPromiseResolveBlock *)resolve
31
+ rejecter:(RCTPromiseRejectBlock *)reject)
32
+
33
+
34
+ RCT_EXTERN_METHOD(fetchInboxMessages: (RCTPromiseResolveBlock *)resolve
35
+ rejecter:(RCTPromiseRejectBlock *)reject)
36
+
37
+ RCT_EXTERN_METHOD(fetchInboxMessage: (NSString *) messageUID
38
+ resolve:(RCTPromiseResolveBlock *)resolve
39
+ reject:(RCTPromiseRejectBlock *)reject)
40
+
41
+ RCT_EXTERN_METHOD(markInboxMessageAsRead: (NSString *) messageUID
42
+ resolve:(RCTPromiseResolveBlock *)resolve
43
+ reject:(RCTPromiseRejectBlock *)reject)
44
+
45
+ RCT_EXTERN_METHOD(expireInboxMessage: (NSString *) messageUID
46
+ resolve:(RCTPromiseResolveBlock *)resolve
47
+ reject:(RCTPromiseRejectBlock *)reject)
48
+
49
+ RCT_EXTERN_METHOD(onInboxMessageOpen: (NSDictionary *) message
50
+ resolve:(RCTPromiseResolveBlock *)resolve
51
+ reject:(RCTPromiseRejectBlock *)reject)
52
+
53
+ RCT_EXTERN_METHOD(onInboxMessagesFetched: (RCTPromiseResolveBlock *)resolve
54
+ reject:(RCTPromiseRejectBlock *)reject)
30
55
  @end
31
56
 
package/ios/Vibes.swift CHANGED
@@ -7,6 +7,8 @@ class Vibes: NSObject, RCTBridgeModule, VibesPush.VibesAPIDelegate {
7
7
  static func moduleName() -> String! {
8
8
  return "Vibes"
9
9
  }
10
+
11
+ public typealias JSONDictionary = [String: Any]
10
12
 
11
13
  let userDefaults = UserDefaults.standard
12
14
 
@@ -136,7 +138,7 @@ class Vibes: NSObject, RCTBridgeModule, VibesPush.VibesAPIDelegate {
136
138
  @objc
137
139
  /// Get Vibes Device Info
138
140
  /// - Parameters:
139
- /// - resolve: promose resolver
141
+ /// - resolve: promise resolver
140
142
  /// - reject: promise rejector
141
143
  func getVibesDeviceInfo(_ resolve: @escaping RCTPromiseResolveBlock,
142
144
  rejecter reject: @escaping RCTPromiseRejectBlock) {
@@ -148,7 +150,147 @@ class Vibes: NSObject, RCTBridgeModule, VibesPush.VibesAPIDelegate {
148
150
  resolve(["device_id": deviceId])
149
151
  }
150
152
  }
153
+
154
+ @objc
155
+ /// Get Person Info
156
+ /// - Parameters:
157
+ /// - resolve: promise resolver
158
+ /// - reject: promise rejector
159
+ func getPerson(_ resolve: @escaping RCTPromiseResolveBlock,
160
+ rejecter reject: @escaping RCTPromiseRejectBlock ) -> Void {
161
+ vibes.getPerson { person, error in
162
+ if let error = error {
163
+ reject("GET_PERSON_ERROR", error.localizedDescription, error)
164
+ } else {
165
+ resolve(["external_person_id": person?.externalPersonId, "person_key": person?.personKey])
166
+ }
167
+ }
168
+ }
169
+
170
+ @objc
171
+ /// Fetch Inbox Messages
172
+ ///
173
+ /// - Parameters:
174
+ /// - resolve: promise resolver
175
+ /// - reject: promise rejector
176
+ func fetchInboxMessages(_ resolve: @escaping RCTPromiseResolveBlock,
177
+ rejecter reject: @escaping RCTPromiseRejectBlock ) -> Void {
178
+ vibes.fetchInboxMessages({ messages, error in
179
+ if let error = error {
180
+ reject("FETCH_INBOX_MESSAGES_ERROR", error.localizedDescription, error)
181
+ } else {
182
+ var msgs: [JSONDictionary] = []
183
+ for msg in messages {
184
+ msgs.append(msg.encodeJSON())
185
+ }
186
+ resolve(msgs)
187
+ }
188
+ })
189
+ }
151
190
 
191
+ @objc
192
+ /// Fetch single Inbox Message
193
+ ///
194
+ /// - Parameters:
195
+ /// - messageUid: The Message ID
196
+ /// - resolve: promise resolver
197
+ /// - reject: promise rejector
198
+ func fetchInboxMessage(_ messageUid: String,
199
+ resolve: @escaping RCTPromiseResolveBlock,
200
+ reject: @escaping RCTPromiseRejectBlock ) -> Void {
201
+ vibes.fetchInboxMessage(messageUID: messageUid) {message, error in
202
+
203
+ if let error = error {
204
+ reject("FETCH_INBOX_MESSAGE_ERROR", error.localizedDescription, error)
205
+ } else {
206
+ if let message = message {
207
+ resolve(message.encodeJSON())
208
+ } else {
209
+ reject("FETCH_INBOX_MESSAGE_ERROR", "message encoding faild", "message encoding faild" as? Error)
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ @objc
216
+ /// Mark Inbox Message as Read
217
+ ///
218
+ /// - Parameters:
219
+ /// - messageUid: The Message ID
220
+ /// - resolve: promise resolver
221
+ /// - reject: promise rejector
222
+ func markInboxMessageAsRead(_ messageUid: String,
223
+ resolve: @escaping RCTPromiseResolveBlock,
224
+ reject: @escaping RCTPromiseRejectBlock ) -> Void {
225
+ vibes.markInboxMessageAsRead(messageUID: messageUid) {message, error in
226
+
227
+ if let error = error {
228
+ reject("MARK_INBOX_MESSAGE_AS_READ_ERROR", error.localizedDescription, error)
229
+ } else {
230
+ if let message = message {
231
+ resolve(message.encodeJSON())
232
+ } else {
233
+ reject("MARK_INBOX_MESSAGE_AS_READ_ERROR", "message encoding faild", "message encoding faild" as? Error)
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ @objc
240
+ /// Expire Inbox Message
241
+ ///
242
+ /// - Parameters:
243
+ /// - messageUid: The Message ID
244
+ /// - resolve: promise resolver
245
+ /// - reject: promise rejector
246
+ func expireInboxMessage(_ messageUid: String,
247
+ resolve: @escaping RCTPromiseResolveBlock,
248
+ reject: @escaping RCTPromiseRejectBlock ) -> Void {
249
+ vibes.expireInboxMessage(messageUID: messageUid) {message, error in
250
+
251
+ if let error = error {
252
+ reject("EXPIRE_INBOX_MESSAGE_ERROR", error.localizedDescription, error)
253
+ } else {
254
+ if let message = message {
255
+ resolve(message.encodeJSON())
256
+ } else {
257
+ reject("EXPIRE_INBOX_MESSAGE_ERROR", "message encoding faild", "message encoding faild" as? Error)
258
+ }
259
+ }
260
+ }
261
+ }
262
+
263
+ @objc
264
+ /// Inbox Message Opened
265
+ ///
266
+ /// - Parameters:
267
+ /// - message: The Inbox Message
268
+ /// - resolve: promise resolver
269
+ /// - reject: promise rejector
270
+ func onInboxMessageOpen(_ message: VibesJSONDictionary,
271
+ resolve: @escaping RCTPromiseResolveBlock,
272
+ reject: @escaping RCTPromiseRejectBlock ) -> Void {
273
+ guard let inboxMessage = InboxMessage(attributes: message) else {
274
+ reject("INBOX_MESSAGE_OPEN_ERROR", "Could not create Inbox Message from payload", nil)
275
+ return
276
+ }
277
+ vibes.onInboxMessageOpen(inboxMessage: inboxMessage)
278
+ resolve("success")
279
+ }
280
+
281
+ @objc
282
+ /// Inbox Messages Fetched
283
+ ///
284
+ /// - Parameters:
285
+ /// - resolve: promise resolver
286
+ /// - reject: promise rejector
287
+ func onInboxMessagesFetched(_ resolve: @escaping RCTPromiseResolveBlock,
288
+ reject: @escaping RCTPromiseRejectBlock ) -> Void {
289
+
290
+ vibes.onInboxMessagesFetched()
291
+ resolve("Success recording an inbox_fetch event")
292
+ }
293
+
152
294
  func didRegisterDevice(deviceId: String?, error: Error?) {
153
295
  if let error = error {
154
296
  if let registerDeviceRejecter = registerDeviceRejecter {
@@ -5,14 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.associatePerson = associatePerson;
7
7
  exports.default = void 0;
8
+ exports.expireInboxMessage = expireInboxMessage;
9
+ exports.fetchInboxMessage = fetchInboxMessage;
10
+ exports.fetchInboxMessages = fetchInboxMessages;
11
+ exports.getPerson = getPerson;
8
12
  exports.getVibesDeviceInfo = getVibesDeviceInfo;
13
+ exports.markInboxMessageAsRead = markInboxMessageAsRead;
14
+ exports.onInboxMessageOpen = onInboxMessageOpen;
15
+ exports.onInboxMessagesFetched = onInboxMessagesFetched;
9
16
  exports.registerDevice = registerDevice;
10
17
  exports.registerPush = registerPush;
11
18
  exports.unregisterDevice = unregisterDevice;
19
+ exports.unregisterPush = unregisterPush;
12
20
  exports.updateDevice = updateDevice;
13
-
14
21
  var _reactNative = require("react-native");
15
-
16
22
  const LINKING_ERROR = `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
17
23
  ios: "- You have run 'pod install'\n",
18
24
  default: ''
@@ -21,33 +27,138 @@ const Vibes = _reactNative.NativeModules.Vibes ? _reactNative.NativeModules.Vibe
21
27
  get() {
22
28
  throw new Error(LINKING_ERROR);
23
29
  }
24
-
25
30
  });
26
-
31
+ /**
32
+ * Register this device with the Vibes platform
33
+ *
34
+ * @return {Promise<DeviceResponse>}
35
+ */
27
36
  function registerDevice() {
28
37
  return Vibes.registerDevice();
29
38
  }
30
-
39
+ /**
40
+ * Unregister this device with the Vibes platform
41
+ *
42
+ * @return {Promise<void>}
43
+ */
31
44
  function unregisterDevice() {
32
45
  return Vibes.unregisterDevice();
33
46
  }
34
47
 
48
+ /**
49
+ * Register this device to receive push notifications
50
+ *
51
+ * @return {Promise<void>}
52
+ */
35
53
  function registerPush() {
36
54
  return Vibes.registerPush();
37
55
  }
38
56
 
57
+ /**
58
+ * Unregister the device from receiving push notifications
59
+ *
60
+ * @return {Promise<void>}
61
+ */
62
+ function unregisterPush() {
63
+ return Vibes.registerPush();
64
+ }
65
+
66
+ /**
67
+ * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
68
+ *
69
+ * @return {Promise<DeviceInfoResponse>}
70
+ */
39
71
  function getVibesDeviceInfo() {
40
72
  return Vibes.getVibesDeviceInfo();
41
73
  }
42
74
 
75
+ /**
76
+ * Updates the Vibes platform with changes to the device since the last time device information was submitted.
77
+ *
78
+ * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.
79
+ * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
80
+ * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0
81
+ * @returns {Promise<void>}
82
+ */
43
83
  function updateDevice(updateCredential, latitude, longitude) {
44
84
  return Vibes.updateDevice(updateCredential, latitude, longitude);
45
85
  }
46
86
 
87
+ /**
88
+ * Associate an external ID with the current person.
89
+ *
90
+ * @param {string} externalPersonId
91
+ * @return {Promise<void>}
92
+ */
47
93
  function associatePerson(externalPersonId) {
48
94
  return Vibes.associatePerson(externalPersonId);
49
95
  }
50
96
 
97
+ /**
98
+ * Fetches the PersonResponse associated with this device currently
99
+ *
100
+ * @return {Promise<PersonResponse>}
101
+ */
102
+ function getPerson() {
103
+ return Vibes.getPerson();
104
+ }
105
+ /**
106
+ * Fetches an array of inbox messages for the person associated with this device.
107
+ *
108
+ * @return {Promise<InboxMessage[]>}
109
+ */
110
+ function fetchInboxMessages() {
111
+ return Vibes.fetchInboxMessages();
112
+ }
113
+
114
+ /**
115
+ * Fetches a single inbox message by it's id.
116
+ *
117
+ * @param {string} message_uid
118
+ * @return {Promise<InboxMessage>}
119
+ */
120
+ function fetchInboxMessage(message_uid) {
121
+ return Vibes.fetchInboxMessage(message_uid);
122
+ }
123
+
124
+ /**
125
+ * Marks an inbox message as read.
126
+ *
127
+ * @param {string} message_uid
128
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
129
+ */
130
+ function markInboxMessageAsRead(message_uid) {
131
+ return Vibes.markInboxMessageAsRead(message_uid);
132
+ }
133
+
134
+ /**
135
+ * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date
136
+ *
137
+ * @param {string} message_uid
138
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
139
+ */
140
+ function expireInboxMessage(message_uid) {
141
+ return Vibes.expireInboxMessage(message_uid);
142
+ }
143
+
144
+ /**
145
+ * Records an event for when the user opens an inbox message.
146
+ *
147
+ * @param inboxMap json map of the InboxMessage
148
+ * @return {Promise<void>}
149
+ */
150
+ function onInboxMessageOpen(inboxMap) {
151
+ return Vibes.onInboxMessageOpen(inboxMap);
152
+ }
153
+
154
+ /**
155
+ * Records an event for when the user fetches a list of inbox messages.
156
+ *
157
+ * @return {Promise<void>}
158
+ */
159
+ function onInboxMessagesFetched() {
160
+ return Vibes.onInboxMessagesFetched();
161
+ }
51
162
  var _default = Vibes;
52
163
  exports.default = _default;
53
164
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Vibes","NativeModules","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function registerDevice(): Promise<any> {\n return Vibes.registerDevice();\n}\n\nexport function unregisterDevice(): Promise<any> {\n return Vibes.unregisterDevice();\n}\n\nexport function registerPush(): Promise<any> {\n return Vibes.registerPush();\n}\n\nexport function getVibesDeviceInfo(): Promise<any> {\n return Vibes.getVibesDeviceInfo();\n}\n\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<any> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\nexport function associatePerson(externalPersonId: string): Promise<any> {\n return Vibes.associatePerson(externalPersonId);\n}\n\nexport default Vibes;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA,MAAMA,aAAa,GAChB,6EAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,KAAK,GAAGC,0BAAA,CAAcD,KAAd,GACVC,0BAAA,CAAcD,KADJ,GAEV,IAAIE,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;;AAWO,SAASU,cAAT,GAAwC;EAC7C,OAAOL,KAAK,CAACK,cAAN,EAAP;AACD;;AAEM,SAASC,gBAAT,GAA0C;EAC/C,OAAON,KAAK,CAACM,gBAAN,EAAP;AACD;;AAEM,SAASC,YAAT,GAAsC;EAC3C,OAAOP,KAAK,CAACO,YAAN,EAAP;AACD;;AAEM,SAASC,kBAAT,GAA4C;EACjD,OAAOR,KAAK,CAACQ,kBAAN,EAAP;AACD;;AAEM,SAASC,YAAT,CACLC,gBADK,EAELC,QAFK,EAGLC,SAHK,EAIS;EACd,OAAOZ,KAAK,CAACS,YAAN,CAAmBC,gBAAnB,EAAqCC,QAArC,EAA+CC,SAA/C,CAAP;AACD;;AAEM,SAASC,eAAT,CAAyBC,gBAAzB,EAAiE;EACtE,OAAOd,KAAK,CAACa,eAAN,CAAsBC,gBAAtB,CAAP;AACD;;eAEcd,K"}
1
+ {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Vibes","NativeModules","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAEA,MAAMA,aAAa,GAChB,6EAA4E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,KAAK,GAAGC,0BAAa,CAACD,KAAK,GAC7BC,0BAAa,CAACD,KAAK,GACnB,IAAIE,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AA4BH;AACA;AACA;AACA;AACA;AACO,SAASU,cAAc,GAA4B;EACxD,OAAOL,KAAK,CAACK,cAAc,EAAE;AAC/B;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgB,GAAkB;EAChD,OAAON,KAAK,CAACM,gBAAgB,EAAE;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAY,GAAkB;EAC5C,OAAOP,KAAK,CAACO,YAAY,EAAE;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAc,GAAkB;EAC9C,OAAOR,KAAK,CAACO,YAAY,EAAE;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkB,GAAgC;EAChE,OAAOT,KAAK,CAACS,kBAAkB,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAY,CAC1BC,gBAAyB,EACzBC,QAAgB,EAChBC,SAAiB,EACF;EACf,OAAOb,KAAK,CAACU,YAAY,CAACC,gBAAgB,EAAEC,QAAQ,EAAEC,SAAS,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAe,CAACC,gBAAwB,EAAiB;EACvE,OAAOf,KAAK,CAACc,eAAe,CAACC,gBAAgB,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,SAAS,GAA4B;EACnD,OAAOhB,KAAK,CAACgB,SAAS,EAAE;AAC1B;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkB,GAA4B;EAC5D,OAAOjB,KAAK,CAACiB,kBAAkB,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiB,CAACC,WAAmB,EAAyB;EAC5E,OAAOnB,KAAK,CAACkB,iBAAiB,CAACC,WAAW,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsB,CAACD,WAAmB,EAAyB;EACjF,OAAOnB,KAAK,CAACoB,sBAAsB,CAACD,WAAW,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkB,CAACF,WAAmB,EAAyB;EAC7E,OAAOnB,KAAK,CAACqB,kBAAkB,CAACF,WAAW,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkB,CAACC,QAAsB,EAAiB;EACxE,OAAOvB,KAAK,CAACsB,kBAAkB,CAACC,QAAQ,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsB,GAAkB;EACtD,OAAOxB,KAAK,CAACwB,sBAAsB,EAAE;AACvC;AAAC,eAEcxB,KAAK;AAAA"}
@@ -7,25 +7,137 @@ const Vibes = NativeModules.Vibes ? NativeModules.Vibes : new Proxy({}, {
7
7
  get() {
8
8
  throw new Error(LINKING_ERROR);
9
9
  }
10
-
11
10
  });
11
+ /**
12
+ * Register this device with the Vibes platform
13
+ *
14
+ * @return {Promise<DeviceResponse>}
15
+ */
12
16
  export function registerDevice() {
13
17
  return Vibes.registerDevice();
14
18
  }
19
+ /**
20
+ * Unregister this device with the Vibes platform
21
+ *
22
+ * @return {Promise<void>}
23
+ */
15
24
  export function unregisterDevice() {
16
25
  return Vibes.unregisterDevice();
17
26
  }
27
+
28
+ /**
29
+ * Register this device to receive push notifications
30
+ *
31
+ * @return {Promise<void>}
32
+ */
18
33
  export function registerPush() {
19
34
  return Vibes.registerPush();
20
35
  }
36
+
37
+ /**
38
+ * Unregister the device from receiving push notifications
39
+ *
40
+ * @return {Promise<void>}
41
+ */
42
+ export function unregisterPush() {
43
+ return Vibes.registerPush();
44
+ }
45
+
46
+ /**
47
+ * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
48
+ *
49
+ * @return {Promise<DeviceInfoResponse>}
50
+ */
21
51
  export function getVibesDeviceInfo() {
22
52
  return Vibes.getVibesDeviceInfo();
23
53
  }
54
+
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
+ */
24
63
  export function updateDevice(updateCredential, latitude, longitude) {
25
64
  return Vibes.updateDevice(updateCredential, latitude, longitude);
26
65
  }
66
+
67
+ /**
68
+ * Associate an external ID with the current person.
69
+ *
70
+ * @param {string} externalPersonId
71
+ * @return {Promise<void>}
72
+ */
27
73
  export function associatePerson(externalPersonId) {
28
74
  return Vibes.associatePerson(externalPersonId);
29
75
  }
76
+
77
+ /**
78
+ * Fetches the PersonResponse associated with this device currently
79
+ *
80
+ * @return {Promise<PersonResponse>}
81
+ */
82
+ export function getPerson() {
83
+ return Vibes.getPerson();
84
+ }
85
+ /**
86
+ * Fetches an array of inbox messages for the person associated with this device.
87
+ *
88
+ * @return {Promise<InboxMessage[]>}
89
+ */
90
+ export function fetchInboxMessages() {
91
+ return Vibes.fetchInboxMessages();
92
+ }
93
+
94
+ /**
95
+ * Fetches a single inbox message by it's id.
96
+ *
97
+ * @param {string} message_uid
98
+ * @return {Promise<InboxMessage>}
99
+ */
100
+ export function fetchInboxMessage(message_uid) {
101
+ return Vibes.fetchInboxMessage(message_uid);
102
+ }
103
+
104
+ /**
105
+ * Marks an inbox message as read.
106
+ *
107
+ * @param {string} message_uid
108
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
109
+ */
110
+ export function markInboxMessageAsRead(message_uid) {
111
+ return Vibes.markInboxMessageAsRead(message_uid);
112
+ }
113
+
114
+ /**
115
+ * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date
116
+ *
117
+ * @param {string} message_uid
118
+ * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
119
+ */
120
+ export function expireInboxMessage(message_uid) {
121
+ return Vibes.expireInboxMessage(message_uid);
122
+ }
123
+
124
+ /**
125
+ * Records an event for when the user opens an inbox message.
126
+ *
127
+ * @param inboxMap json map of the InboxMessage
128
+ * @return {Promise<void>}
129
+ */
130
+ export function onInboxMessageOpen(inboxMap) {
131
+ return Vibes.onInboxMessageOpen(inboxMap);
132
+ }
133
+
134
+ /**
135
+ * Records an event for when the user fetches a list of inbox messages.
136
+ *
137
+ * @return {Promise<void>}
138
+ */
139
+ export function onInboxMessagesFetched() {
140
+ return Vibes.onInboxMessagesFetched();
141
+ }
30
142
  export default Vibes;
31
143
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Vibes","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function registerDevice(): Promise<any> {\n return Vibes.registerDevice();\n}\n\nexport function unregisterDevice(): Promise<any> {\n return Vibes.unregisterDevice();\n}\n\nexport function registerPush(): Promise<any> {\n return Vibes.registerPush();\n}\n\nexport function getVibesDeviceInfo(): Promise<any> {\n return Vibes.getVibesDeviceInfo();\n}\n\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<any> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\nexport function associatePerson(externalPersonId: string): Promise<any> {\n return Vibes.associatePerson(externalPersonId);\n}\n\nexport default Vibes;\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAEA,MAAMC,aAAa,GAChB,6EAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,KAAK,GAAGN,aAAa,CAACM,KAAd,GACVN,aAAa,CAACM,KADJ,GAEV,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;AAWA,OAAO,SAASQ,cAAT,GAAwC;EAC7C,OAAOJ,KAAK,CAACI,cAAN,EAAP;AACD;AAED,OAAO,SAASC,gBAAT,GAA0C;EAC/C,OAAOL,KAAK,CAACK,gBAAN,EAAP;AACD;AAED,OAAO,SAASC,YAAT,GAAsC;EAC3C,OAAON,KAAK,CAACM,YAAN,EAAP;AACD;AAED,OAAO,SAASC,kBAAT,GAA4C;EACjD,OAAOP,KAAK,CAACO,kBAAN,EAAP;AACD;AAED,OAAO,SAASC,YAAT,CACLC,gBADK,EAELC,QAFK,EAGLC,SAHK,EAIS;EACd,OAAOX,KAAK,CAACQ,YAAN,CAAmBC,gBAAnB,EAAqCC,QAArC,EAA+CC,SAA/C,CAAP;AACD;AAED,OAAO,SAASC,eAAT,CAAyBC,gBAAzB,EAAiE;EACtE,OAAOb,KAAK,CAACY,eAAN,CAAsBC,gBAAtB,CAAP;AACD;AAED,eAAeb,KAAf"}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Vibes","Proxy","get","Error","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMap","onInboxMessagesFetched"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Vibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport interface DeviceResponse {\n device_id?: string;\n}\nexport interface DeviceInfoResponse extends DeviceResponse {\n push_token?: string;\n}\n\nexport interface PersonResponse {\n person_key?: string;\n external_person_id?: string;\n}\n\nexport interface InboxMessage {\n content?: string;\n created_at?: string;\n expires_at?: string;\n message_uid?: string;\n read?: boolean;\n subject?: string;\n detail?: string;\n collapse_key?: string;\n apprefdata?: any;\n images?: any;\n inbox_custom_data: any;\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return Vibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return Vibes.unregisterDevice();\n}\n\n/**\n * Register this device to receive push notifications\n *\n * @return {Promise<void>}\n */\nexport function registerPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n* Unregister the device from receiving push notifications\n*\n* @return {Promise<void>}\n*/\nexport function unregisterPush(): Promise<void> {\n return Vibes.registerPush();\n}\n\n/**\n * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token\n *\n * @return {Promise<DeviceInfoResponse>}\n */\nexport function getVibesDeviceInfo(): Promise<DeviceInfoResponse> {\n return Vibes.getVibesDeviceInfo();\n}\n\n/**\n * Updates the Vibes platform with changes to the device since the last time device information was submitted.\n *\n * @param updateCredential - if true, the authentication token will be refreshed. Unless required, pass false here.\n * @param latitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @param longitude - if you collect geolocation information, then pass the latitude here. Otherwise, pass 0\n * @returns {Promise<void>}\n */\nexport function updateDevice(\n updateCredential: boolean,\n latitude: number,\n longitude: number\n): Promise<void> {\n return Vibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<void>}\n */\nexport function associatePerson(externalPersonId: string): Promise<void> {\n return Vibes.associatePerson(externalPersonId);\n}\n\n/**\n * Fetches the PersonResponse associated with this device currently\n *\n * @return {Promise<PersonResponse>}\n */\nexport function getPerson(): Promise<PersonResponse> {\n return Vibes.getPerson();\n}\n/**\n * Fetches an array of inbox messages for the person associated with this device.\n *\n * @return {Promise<InboxMessage[]>}\n */\nexport function fetchInboxMessages(): Promise<InboxMessage[]> {\n return Vibes.fetchInboxMessages();\n}\n\n/**\n * Fetches a single inbox message by it's id.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>}\n */\nexport function fetchInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.fetchInboxMessage(message_uid);\n}\n\n/**\n * Marks an inbox message as read.\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated\n */\nexport function markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {\n return Vibes.markInboxMessageAsRead(message_uid);\n}\n\n/**\n * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date as expiry date\n *\n * @param {string} message_uid\n * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated\n */\nexport function expireInboxMessage(message_uid: string): Promise<InboxMessage> {\n return Vibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMap json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void> {\n return Vibes.onInboxMessageOpen(inboxMap);\n}\n\n/**\n * Records an event for when the user fetches a list of inbox messages.\n *\n * @return {Promise<void>}\n */\nexport function onInboxMessagesFetched(): Promise<void> {\n return Vibes.onInboxMessagesFetched();\n}\n\nexport default Vibes;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,6EAA4E,GAC7ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,KAAK,GAAGN,aAAa,CAACM,KAAK,GAC7BN,aAAa,CAACM,KAAK,GACnB,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AA4BH;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,cAAc,GAA4B;EACxD,OAAOJ,KAAK,CAACI,cAAc,EAAE;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgB,GAAkB;EAChD,OAAOL,KAAK,CAACK,gBAAgB,EAAE;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAY,GAAkB;EAC5C,OAAON,KAAK,CAACM,YAAY,EAAE;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAc,GAAkB;EAC9C,OAAOP,KAAK,CAACM,YAAY,EAAE;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkB,GAAgC;EAChE,OAAOR,KAAK,CAACQ,kBAAkB,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAY,CAC1BC,gBAAyB,EACzBC,QAAgB,EAChBC,SAAiB,EACF;EACf,OAAOZ,KAAK,CAACS,YAAY,CAACC,gBAAgB,EAAEC,QAAQ,EAAEC,SAAS,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAe,CAACC,gBAAwB,EAAiB;EACvE,OAAOd,KAAK,CAACa,eAAe,CAACC,gBAAgB,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAAS,GAA4B;EACnD,OAAOf,KAAK,CAACe,SAAS,EAAE;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkB,GAA4B;EAC5D,OAAOhB,KAAK,CAACgB,kBAAkB,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiB,CAACC,WAAmB,EAAyB;EAC5E,OAAOlB,KAAK,CAACiB,iBAAiB,CAACC,WAAW,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsB,CAACD,WAAmB,EAAyB;EACjF,OAAOlB,KAAK,CAACmB,sBAAsB,CAACD,WAAW,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkB,CAACF,WAAmB,EAAyB;EAC7E,OAAOlB,KAAK,CAACoB,kBAAkB,CAACF,WAAW,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,kBAAkB,CAACC,QAAsB,EAAiB;EACxE,OAAOtB,KAAK,CAACqB,kBAAkB,CAACC,QAAQ,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsB,GAAkB;EACtD,OAAOvB,KAAK,CAACuB,sBAAsB,EAAE;AACvC;AAEA,eAAevB,KAAK"}