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.
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 +64 -18
  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 +63 -19
  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 +23 -28
  17. package/lib/typescript/types.d.ts +27 -0
  18. package/package.json +31 -6
  19. package/src/index.tsx +85 -44
  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
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","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","_default","exports"],"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(\n message_uid: string\n): 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,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,6EAA6E,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,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA4BL;AACA;AACA;AACA;AACA;AACO,SAASU,cAAcA,CAAA,EAA4B;EACxD,OAAOL,KAAK,CAACK,cAAc,CAAC,CAAC;AAC/B;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAAkB;EAChD,OAAON,KAAK,CAACM,gBAAgB,CAAC,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAA,EAAkB;EAC5C,OAAOP,KAAK,CAACO,YAAY,CAAC,CAA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C,QAAsB,EAAiB;EACxE,OAAOvB,KAAK,CAACsB,kBAAkB,CAACC,QAAQ,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAAA,EAAkB;EACtD,OAAOxB,KAAK,CAACwB,sBAAsB,CAAC,CAAC;AACvC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3B,OAAA,GAEcC,KAAK","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","NativeVibes","NativeModules","Vibes","Proxy","get","Error","getSDKVersion","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMessage","onInboxMessagesFetched","requestNotificationPermissions","OS","apiLevel","Version","parseInt","String","Number","isNaN","result","PermissionsAndroid","request","PERMISSIONS","POST_NOTIFICATIONS","RESULTS","GRANTED","target","prop","receiver","value","Reflect","bind","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, PermissionsAndroid, Platform } from 'react-native';\n\nimport type {\n AssociatePersonResponse,\n DeviceInfoResponse,\n DeviceResponse,\n InboxMessage,\n PersonResponse,\n} from './types';\n\nexport type {\n AssociatePersonResponse,\n DeviceInfoResponse,\n DeviceResponse,\n InboxMessage,\n PersonResponse,\n} from './types';\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 NativeVibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Returns the wrapper SDK version string.\n *\n * @return {Promise<string>}\n */\nexport function getSDKVersion(): Promise<string> {\n return NativeVibes.getSDKVersion();\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return NativeVibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return NativeVibes.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 NativeVibes.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 NativeVibes.unregisterPush();\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 NativeVibes.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 NativeVibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<AssociatePersonResponse>}\n */\nexport function associatePerson(\n externalPersonId: string\n): Promise<AssociatePersonResponse> {\n return NativeVibes.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 NativeVibes.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 NativeVibes.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 NativeVibes.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(\n message_uid: string\n): Promise<InboxMessage> {\n return NativeVibes.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 NativeVibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMessage - json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMessage: InboxMessage): Promise<void> {\n return NativeVibes.onInboxMessageOpen(inboxMessage);\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 NativeVibes.onInboxMessagesFetched();\n}\n\n/**\n * Requests notification permissions from the OS.\n *\n * - iOS: prompts via UNUserNotificationCenter and registers for remote notifications\n * - Android 13+: requests POST_NOTIFICATIONS via PermissionsAndroid\n * - Android 12 and below: no-op (permission not required)\n *\n * @return {Promise<void>}\n */\nexport async function requestNotificationPermissions(): Promise<void> {\n if (Platform.OS === 'android') {\n const apiLevel =\n typeof Platform.Version === 'number'\n ? Platform.Version\n : parseInt(String(Platform.Version), 10);\n // POST_NOTIFICATIONS is only required on Android 13+ (API 33)\n if (!Number.isNaN(apiLevel) && apiLevel < 33) {\n return;\n }\n const result = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS\n );\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new Error('Notification permissions denied');\n }\n return;\n }\n return NativeVibes.requestNotificationPermissions();\n}\n\nconst Vibes = new Proxy(NativeVibes, {\n get(target, prop, receiver) {\n if (prop === 'requestNotificationPermissions') {\n return requestNotificationPermissions;\n }\n const value = Reflect.get(target, prop, receiver);\n return typeof value === 'function' ? value.bind(target) : value;\n },\n});\n\nexport default Vibes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAkBA,MAAMC,aAAa,GACjB,6EAA6E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,WAAW,GAAGC,0BAAa,CAACC,KAAK,GACnCD,0BAAa,CAACC,KAAK,GACnB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA;AACO,SAASW,aAAaA,CAAA,EAAoB;EAC/C,OAAON,WAAW,CAACM,aAAa,CAAC,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAA4B;EACxD,OAAOP,WAAW,CAACO,cAAc,CAAC,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAAkB;EAChD,OAAOR,WAAW,CAACQ,gBAAgB,CAAC,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAA,EAAkB;EAC5C,OAAOT,WAAW,CAACS,YAAY,CAAC,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAkB;EAC9C,OAAOV,WAAW,CAACU,cAAc,CAAC,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAAgC;EAChE,OAAOX,WAAW,CAACW,kBAAkB,CAAC,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAC1BC,gBAAyB,EACzBC,QAAgB,EAChBC,SAAiB,EACF;EACf,OAAOf,WAAW,CAACY,YAAY,CAACC,gBAAgB,EAAEC,QAAQ,EAAEC,SAAS,CAAC;AACxE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,gBAAwB,EACU;EAClC,OAAOjB,WAAW,CAACgB,eAAe,CAACC,gBAAgB,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAA,EAA4B;EACnD,OAAOlB,WAAW,CAACkB,SAAS,CAAC,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAA4B;EAC5D,OAAOnB,WAAW,CAACmB,kBAAkB,CAAC,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,WAAmB,EAAyB;EAC5E,OAAOrB,WAAW,CAACoB,iBAAiB,CAACC,WAAW,CAAC;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACpCD,WAAmB,EACI;EACvB,OAAOrB,WAAW,CAACsB,sBAAsB,CAACD,WAAW,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkBA,CAACF,WAAmB,EAAyB;EAC7E,OAAOrB,WAAW,CAACuB,kBAAkB,CAACF,WAAW,CAAC;AACpD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAACC,YAA0B,EAAiB;EAC5E,OAAOzB,WAAW,CAACwB,kBAAkB,CAACC,YAAY,CAAC;AACr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QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAEYG,KAAK","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface DeviceResponse {\n device_id?: string;\n}\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 AssociatePersonResponse {\n externalPersonId: string;\n status: 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"],"mappings":"","ignoreList":[]}
@@ -1,20 +1,30 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import { NativeModules, PermissionsAndroid, Platform } from 'react-native';
2
2
  const LINKING_ERROR = `The package 'vibes-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
3
  ios: "- You have run 'pod install'\n",
4
4
  default: ''
5
5
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
- const Vibes = NativeModules.Vibes ? NativeModules.Vibes : new Proxy({}, {
6
+ const NativeVibes = NativeModules.Vibes ? NativeModules.Vibes : new Proxy({}, {
7
7
  get() {
8
8
  throw new Error(LINKING_ERROR);
9
9
  }
10
10
  });
11
+
12
+ /**
13
+ * Returns the wrapper SDK version string.
14
+ *
15
+ * @return {Promise<string>}
16
+ */
17
+ export function getSDKVersion() {
18
+ return NativeVibes.getSDKVersion();
19
+ }
20
+
11
21
  /**
12
22
  * Register this device with the Vibes platform
13
23
  *
14
24
  * @return {Promise<DeviceResponse>}
15
25
  */
16
26
  export function registerDevice() {
17
- return Vibes.registerDevice();
27
+ return NativeVibes.registerDevice();
18
28
  }
19
29
  /**
20
30
  * Unregister this device with the Vibes platform
@@ -22,7 +32,7 @@ export function registerDevice() {
22
32
  * @return {Promise<void>}
23
33
  */
24
34
  export function unregisterDevice() {
25
- return Vibes.unregisterDevice();
35
+ return NativeVibes.unregisterDevice();
26
36
  }
27
37
 
28
38
  /**
@@ -31,7 +41,7 @@ export function unregisterDevice() {
31
41
  * @return {Promise<void>}
32
42
  */
33
43
  export function registerPush() {
34
- return Vibes.registerPush();
44
+ return NativeVibes.registerPush();
35
45
  }
36
46
 
37
47
  /**
@@ -40,7 +50,7 @@ export function registerPush() {
40
50
  * @return {Promise<void>}
41
51
  */
42
52
  export function unregisterPush() {
43
- return Vibes.registerPush();
53
+ return NativeVibes.unregisterPush();
44
54
  }
45
55
 
46
56
  /**
@@ -49,7 +59,7 @@ export function unregisterPush() {
49
59
  * @return {Promise<DeviceInfoResponse>}
50
60
  */
51
61
  export function getVibesDeviceInfo() {
52
- return Vibes.getVibesDeviceInfo();
62
+ return NativeVibes.getVibesDeviceInfo();
53
63
  }
54
64
 
55
65
  /**
@@ -61,17 +71,17 @@ export function getVibesDeviceInfo() {
61
71
  * @returns {Promise<void>}
62
72
  */
63
73
  export function updateDevice(updateCredential, latitude, longitude) {
64
- return Vibes.updateDevice(updateCredential, latitude, longitude);
74
+ return NativeVibes.updateDevice(updateCredential, latitude, longitude);
65
75
  }
66
76
 
67
77
  /**
68
78
  * Associate an external ID with the current person.
69
79
  *
70
80
  * @param {string} externalPersonId
71
- * @return {Promise<void>}
81
+ * @return {Promise<AssociatePersonResponse>}
72
82
  */
73
83
  export function associatePerson(externalPersonId) {
74
- return Vibes.associatePerson(externalPersonId);
84
+ return NativeVibes.associatePerson(externalPersonId);
75
85
  }
76
86
 
77
87
  /**
@@ -80,7 +90,7 @@ export function associatePerson(externalPersonId) {
80
90
  * @return {Promise<PersonResponse>}
81
91
  */
82
92
  export function getPerson() {
83
- return Vibes.getPerson();
93
+ return NativeVibes.getPerson();
84
94
  }
85
95
  /**
86
96
  * Fetches an array of inbox messages for the person associated with this device.
@@ -88,7 +98,7 @@ export function getPerson() {
88
98
  * @return {Promise<InboxMessage[]>}
89
99
  */
90
100
  export function fetchInboxMessages() {
91
- return Vibes.fetchInboxMessages();
101
+ return NativeVibes.fetchInboxMessages();
92
102
  }
93
103
 
94
104
  /**
@@ -98,7 +108,7 @@ export function fetchInboxMessages() {
98
108
  * @return {Promise<InboxMessage>}
99
109
  */
100
110
  export function fetchInboxMessage(message_uid) {
101
- return Vibes.fetchInboxMessage(message_uid);
111
+ return NativeVibes.fetchInboxMessage(message_uid);
102
112
  }
103
113
 
104
114
  /**
@@ -108,7 +118,7 @@ export function fetchInboxMessage(message_uid) {
108
118
  * @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
109
119
  */
110
120
  export function markInboxMessageAsRead(message_uid) {
111
- return Vibes.markInboxMessageAsRead(message_uid);
121
+ return NativeVibes.markInboxMessageAsRead(message_uid);
112
122
  }
113
123
 
114
124
  /**
@@ -118,17 +128,17 @@ export function markInboxMessageAsRead(message_uid) {
118
128
  * @return {Promise<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
119
129
  */
120
130
  export function expireInboxMessage(message_uid) {
121
- return Vibes.expireInboxMessage(message_uid);
131
+ return NativeVibes.expireInboxMessage(message_uid);
122
132
  }
123
133
 
124
134
  /**
125
135
  * Records an event for when the user opens an inbox message.
126
136
  *
127
- * @param inboxMap json map of the InboxMessage
137
+ * @param inboxMessage - json map of the InboxMessage
128
138
  * @return {Promise<void>}
129
139
  */
130
- export function onInboxMessageOpen(inboxMap) {
131
- return Vibes.onInboxMessageOpen(inboxMap);
140
+ export function onInboxMessageOpen(inboxMessage) {
141
+ return NativeVibes.onInboxMessageOpen(inboxMessage);
132
142
  }
133
143
 
134
144
  /**
@@ -137,7 +147,41 @@ export function onInboxMessageOpen(inboxMap) {
137
147
  * @return {Promise<void>}
138
148
  */
139
149
  export function onInboxMessagesFetched() {
140
- return Vibes.onInboxMessagesFetched();
150
+ return NativeVibes.onInboxMessagesFetched();
141
151
  }
152
+
153
+ /**
154
+ * Requests notification permissions from the OS.
155
+ *
156
+ * - iOS: prompts via UNUserNotificationCenter and registers for remote notifications
157
+ * - Android 13+: requests POST_NOTIFICATIONS via PermissionsAndroid
158
+ * - Android 12 and below: no-op (permission not required)
159
+ *
160
+ * @return {Promise<void>}
161
+ */
162
+ export async function requestNotificationPermissions() {
163
+ if (Platform.OS === 'android') {
164
+ const apiLevel = typeof Platform.Version === 'number' ? Platform.Version : parseInt(String(Platform.Version), 10);
165
+ // POST_NOTIFICATIONS is only required on Android 13+ (API 33)
166
+ if (!Number.isNaN(apiLevel) && apiLevel < 33) {
167
+ return;
168
+ }
169
+ const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
170
+ if (result !== PermissionsAndroid.RESULTS.GRANTED) {
171
+ throw new Error('Notification permissions denied');
172
+ }
173
+ return;
174
+ }
175
+ return NativeVibes.requestNotificationPermissions();
176
+ }
177
+ const Vibes = new Proxy(NativeVibes, {
178
+ get(target, prop, receiver) {
179
+ if (prop === 'requestNotificationPermissions') {
180
+ return requestNotificationPermissions;
181
+ }
182
+ const value = Reflect.get(target, prop, receiver);
183
+ return typeof value === 'function' ? value.bind(target) : value;
184
+ }
185
+ });
142
186
  export default Vibes;
143
187
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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(\n message_uid: string\n): 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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OAAOd,KAAK,CAACa,eAAe,CAACC,gBAAgB,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAA4B;EACnD,OAAOf,KAAK,CAACe,SAAS,CAAC,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAA4B;EAC5D,OAAOhB,KAAK,CAACgB,kBAAkB,CAAC,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,WAAmB,EAAyB;EAC5E,OAAOlB,KAAK,CAACiB,iBAAiB,CAACC,WAAW,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCD,WAAmB,EACI;EACvB,OAAOlB,KAAK,CAACmB,sBAAsB,CAACD,WAAW,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAACF,WAAmB,EAAyB;EAC7E,OAAOlB,KAAK,CAACoB,kBAAkB,CAACF,WAAW,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,kBAAkBA,CAACC,QAAsB,EAAiB;EACxE,OAAOtB,KAAK,CAACqB,kBAAkB,CAACC,QAAQ,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAA,EAAkB;EACtD,OAAOvB,KAAK,CAACuB,sBAAsB,CAAC,CAAC;AACvC;AAEA,eAAevB,KAAK","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","PermissionsAndroid","Platform","LINKING_ERROR","select","ios","default","NativeVibes","Vibes","Proxy","get","Error","getSDKVersion","registerDevice","unregisterDevice","registerPush","unregisterPush","getVibesDeviceInfo","updateDevice","updateCredential","latitude","longitude","associatePerson","externalPersonId","getPerson","fetchInboxMessages","fetchInboxMessage","message_uid","markInboxMessageAsRead","expireInboxMessage","onInboxMessageOpen","inboxMessage","onInboxMessagesFetched","requestNotificationPermissions","OS","apiLevel","Version","parseInt","String","Number","isNaN","result","request","PERMISSIONS","POST_NOTIFICATIONS","RESULTS","GRANTED","target","prop","receiver","value","Reflect","bind"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, PermissionsAndroid, Platform } from 'react-native';\n\nimport type {\n AssociatePersonResponse,\n DeviceInfoResponse,\n DeviceResponse,\n InboxMessage,\n PersonResponse,\n} from './types';\n\nexport type {\n AssociatePersonResponse,\n DeviceInfoResponse,\n DeviceResponse,\n InboxMessage,\n PersonResponse,\n} from './types';\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 NativeVibes = NativeModules.Vibes\n ? NativeModules.Vibes\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Returns the wrapper SDK version string.\n *\n * @return {Promise<string>}\n */\nexport function getSDKVersion(): Promise<string> {\n return NativeVibes.getSDKVersion();\n}\n\n/**\n * Register this device with the Vibes platform\n *\n * @return {Promise<DeviceResponse>}\n */\nexport function registerDevice(): Promise<DeviceResponse> {\n return NativeVibes.registerDevice();\n}\n/**\n * Unregister this device with the Vibes platform\n *\n * @return {Promise<void>}\n */\nexport function unregisterDevice(): Promise<void> {\n return NativeVibes.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 NativeVibes.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 NativeVibes.unregisterPush();\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 NativeVibes.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 NativeVibes.updateDevice(updateCredential, latitude, longitude);\n}\n\n/**\n * Associate an external ID with the current person.\n *\n * @param {string} externalPersonId\n * @return {Promise<AssociatePersonResponse>}\n */\nexport function associatePerson(\n externalPersonId: string\n): Promise<AssociatePersonResponse> {\n return NativeVibes.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 NativeVibes.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 NativeVibes.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 NativeVibes.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(\n message_uid: string\n): Promise<InboxMessage> {\n return NativeVibes.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 NativeVibes.expireInboxMessage(message_uid);\n}\n\n/**\n * Records an event for when the user opens an inbox message.\n *\n * @param inboxMessage - json map of the InboxMessage\n * @return {Promise<void>}\n */\nexport function onInboxMessageOpen(inboxMessage: InboxMessage): Promise<void> {\n return NativeVibes.onInboxMessageOpen(inboxMessage);\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 NativeVibes.onInboxMessagesFetched();\n}\n\n/**\n * Requests notification permissions from the OS.\n *\n * - iOS: prompts via UNUserNotificationCenter and registers for remote notifications\n * - Android 13+: requests POST_NOTIFICATIONS via PermissionsAndroid\n * - Android 12 and below: no-op (permission not required)\n *\n * @return {Promise<void>}\n */\nexport async function requestNotificationPermissions(): Promise<void> {\n if (Platform.OS === 'android') {\n const apiLevel =\n typeof Platform.Version === 'number'\n ? Platform.Version\n : parseInt(String(Platform.Version), 10);\n // POST_NOTIFICATIONS is only required on Android 13+ (API 33)\n if (!Number.isNaN(apiLevel) && apiLevel < 33) {\n return;\n }\n const result = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS\n );\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new Error('Notification permissions denied');\n }\n return;\n }\n return NativeVibes.requestNotificationPermissions();\n}\n\nconst Vibes = new Proxy(NativeVibes, {\n get(target, prop, receiver) {\n if (prop === 'requestNotificationPermissions') {\n return requestNotificationPermissions;\n }\n const value = Reflect.get(target, prop, receiver);\n return typeof value === 'function' ? value.bind(target) : value;\n },\n});\n\nexport default Vibes;\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAkB1E,MAAMC,aAAa,GACjB,6EAA6E,GAC7ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,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CAAC;IAC5C;IACA,IAAI,CAACG,MAAM,CAACC,KAAK,CAACL,QAAQ,CAAC,IAAIA,QAAQ,GAAG,EAAE,EAAE;MAC5C;IACF;IACA,MAAMM,MAAM,GAAG,MAAMxC,kBAAkB,CAACyC,OAAO,CAC7CzC,kBAAkB,CAAC0C,WAAW,CAACC,kBACjC,CAAC;IACD,IAAIH,MAAM,KAAKxC,kBAAkB,CAAC4C,OAAO,CAACC,OAAO,EAAE;MACjD,MAAM,IAAInC,KAAK,CAAC,iCAAiC,CAAC;IACpD;IACA;EACF;EACA,OAAOJ,WAAW,CAAC0B,8BAA8B,CAAC,CAAC;AACrD;AAEA,MAAMzB,KAAK,GAAG,IAAIC,KAAK,CAACF,WAAW,EAAE;EACnCG,GAAGA,CAACqC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAE;IAC1B,IAAID,IAAI,KAAK,gCAAgC,EAAE;MAC7C,OAAOf,8BAA8B;IACvC;IACA,MAAMiB,KAAK,GAAGC,OAAO,CAACzC,GAAG,CAACqC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;IACjD,OAAO,OAAOC,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACE,IAAI,CAACL,MAAM,CAAC,GAAGG,KAAK;EACjE;AACF,CAAC,CAAC;AAEF,eAAe1C,KAAK","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface DeviceResponse {\n device_id?: string;\n}\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 AssociatePersonResponse {\n externalPersonId: string;\n status: 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"],"mappings":"","ignoreList":[]}
@@ -1,27 +1,11 @@
1
- declare const Vibes: 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
- }
1
+ import type { AssociatePersonResponse, DeviceInfoResponse, DeviceResponse, InboxMessage, PersonResponse } from './types';
2
+ export type { AssociatePersonResponse, DeviceInfoResponse, DeviceResponse, InboxMessage, PersonResponse, } from './types';
3
+ /**
4
+ * Returns the wrapper SDK version string.
5
+ *
6
+ * @return {Promise<string>}
7
+ */
8
+ export declare function getSDKVersion(): Promise<string>;
25
9
  /**
26
10
  * Register this device with the Vibes platform
27
11
  *
@@ -65,9 +49,9 @@ export declare function updateDevice(updateCredential: boolean, latitude: number
65
49
  * Associate an external ID with the current person.
66
50
  *
67
51
  * @param {string} externalPersonId
68
- * @return {Promise<void>}
52
+ * @return {Promise<AssociatePersonResponse>}
69
53
  */
70
- export declare function associatePerson(externalPersonId: string): Promise<void>;
54
+ export declare function associatePerson(externalPersonId: string): Promise<AssociatePersonResponse>;
71
55
  /**
72
56
  * Fetches the PersonResponse associated with this device currently
73
57
  *
@@ -104,14 +88,25 @@ export declare function expireInboxMessage(message_uid: string): Promise<InboxMe
104
88
  /**
105
89
  * Records an event for when the user opens an inbox message.
106
90
  *
107
- * @param inboxMap json map of the InboxMessage
91
+ * @param inboxMessage - json map of the InboxMessage
108
92
  * @return {Promise<void>}
109
93
  */
110
- export declare function onInboxMessageOpen(inboxMap: InboxMessage): Promise<void>;
94
+ export declare function onInboxMessageOpen(inboxMessage: InboxMessage): Promise<void>;
111
95
  /**
112
96
  * Records an event for when the user fetches a list of inbox messages.
113
97
  *
114
98
  * @return {Promise<void>}
115
99
  */
116
100
  export declare function onInboxMessagesFetched(): Promise<void>;
101
+ /**
102
+ * Requests notification permissions from the OS.
103
+ *
104
+ * - iOS: prompts via UNUserNotificationCenter and registers for remote notifications
105
+ * - Android 13+: requests POST_NOTIFICATIONS via PermissionsAndroid
106
+ * - Android 12 and below: no-op (permission not required)
107
+ *
108
+ * @return {Promise<void>}
109
+ */
110
+ export declare function requestNotificationPermissions(): Promise<void>;
111
+ declare const Vibes: any;
117
112
  export default Vibes;
@@ -0,0 +1,27 @@
1
+ export interface DeviceResponse {
2
+ device_id?: string;
3
+ }
4
+ export interface DeviceInfoResponse extends DeviceResponse {
5
+ push_token?: string;
6
+ }
7
+ export interface PersonResponse {
8
+ person_key?: string;
9
+ external_person_id?: string;
10
+ }
11
+ export interface AssociatePersonResponse {
12
+ externalPersonId: string;
13
+ status: string;
14
+ }
15
+ export interface InboxMessage {
16
+ content?: string;
17
+ created_at?: string;
18
+ expires_at?: string;
19
+ message_uid?: string;
20
+ read?: boolean;
21
+ subject?: string;
22
+ detail?: string;
23
+ collapse_key?: string;
24
+ apprefdata?: any;
25
+ images?: any;
26
+ inbox_custom_data: any;
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibes-react-native",
3
- "version": "1.1.8",
3
+ "version": "5.0.0",
4
4
  "description": "The React Native plugin for the Vibes Mobile SDKs",
5
5
  "author": "Vibes",
6
6
  "main": "lib/commonjs/index",
@@ -15,7 +15,7 @@
15
15
  "ios",
16
16
  "cpp",
17
17
  "vibes-react-native.podspec",
18
- "!lib/typescript/sample-app",
18
+ "!lib/typescript/examples",
19
19
  "!android/build",
20
20
  "!ios/build",
21
21
  "!**/__tests__",
@@ -26,8 +26,7 @@
26
26
  "test": "jest",
27
27
  "typescript": "tsc --noEmit",
28
28
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
29
- "prepare": "bob build",
30
- "release:public": "node scripts/release-to-public.js"
29
+ "prepare": "bob build"
31
30
  },
32
31
  "keywords": [
33
32
  "react-native",
@@ -44,21 +43,35 @@
44
43
  "registry": "https://registry.npmjs.org/"
45
44
  },
46
45
  "devDependencies": {
46
+ "@babel/core": "^7.25.2",
47
+ "@babel/eslint-parser": "^7.25.1",
48
+ "@babel/runtime": "^7.25.0",
49
+ "@react-native/babel-preset": "0.77.3",
47
50
  "@react-native/eslint-config": "0.77.3",
51
+ "@react-native/eslint-plugin": "0.77.3",
48
52
  "@types/jest": "^26.0.0",
49
53
  "@types/react": "^18.2.6",
54
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
55
+ "@typescript-eslint/parser": "^7.1.1",
50
56
  "eslint": "^8.57.0",
51
57
  "eslint-config-prettier": "^8.5.0",
58
+ "eslint-plugin-eslint-comments": "^3.2.0",
59
+ "eslint-plugin-ft-flow": "^2.0.1",
60
+ "eslint-plugin-jest": "^27.9.0",
52
61
  "eslint-plugin-prettier": "^5.2.1",
62
+ "eslint-plugin-react": "^7.30.1",
63
+ "eslint-plugin-react-hooks": "^4.6.0",
64
+ "eslint-plugin-react-native": "^4.0.0",
53
65
  "husky": "^6.0.0",
54
66
  "jest": "^29.7.0",
55
67
  "pod-install": "^1.0.14",
56
68
  "prettier": "^3.5.3",
57
69
  "react": "18.3.1",
58
70
  "react-native": "0.77.3",
59
- "react-native-push-notification": "^3.1.9",
60
71
  "react-native-builder-bob": "^0.18.0",
61
- "typescript": "^4.1.3"
72
+ "react-native-push-notification": "^3.1.9",
73
+ "tiny-invariant": "^1.3.3",
74
+ "typescript": "^5.3.3"
62
75
  },
63
76
  "peerDependencies": {
64
77
  "react": "*",
@@ -67,9 +80,21 @@
67
80
  },
68
81
  "jest": {
69
82
  "preset": "react-native",
83
+ "setupFiles": [
84
+ "<rootDir>/jest.setup.js"
85
+ ],
86
+ "testPathIgnorePatterns": [
87
+ "/node_modules/",
88
+ "/examples/",
89
+ "/lib/",
90
+ "/src/__tests__/mocks/"
91
+ ],
70
92
  "modulePathIgnorePatterns": [
71
93
  "<rootDir>/sample-app/node_modules",
72
94
  "<rootDir>/lib/"
95
+ ],
96
+ "transformIgnorePatterns": [
97
+ "node_modules/(?!((\\.bun/)?(react-native|@react-native|@react-navigation)(/|$)|\\.bun/react-native@|\\.bun/@react-native\\+))"
73
98
  ]
74
99
  },
75
100
  "eslintConfig": {