@zelloptt/react-native-zello-sdk 2.0.1 → 4.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 (201) hide show
  1. package/README.md +100 -15
  2. package/android/build.gradle +29 -10
  3. package/android/gradle.properties +4 -4
  4. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +93 -68
  5. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +25 -0
  6. package/app.plugin.js +97 -0
  7. package/ios/Extensions/ZelloContact+Extension.swift +26 -3
  8. package/ios/Extensions/ZelloHistoryVoiceMessage+Extension.swift +3 -0
  9. package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +8 -2
  10. package/ios/Extensions/ZelloIncomingEmergency+Extension.swift +1 -0
  11. package/ios/Extensions/ZelloTranscription+Extension.swift +18 -0
  12. package/ios/ZelloIOSSdkModule.swift +24 -7
  13. package/ios/ZelloIOSSdkModuleBridge.m +1 -0
  14. package/ios/ZelloSdkModule.h +8 -0
  15. package/ios/ZelloSdkModule.mm +189 -0
  16. package/ios/ZelloSdkModuleImpl.swift +280 -0
  17. package/lib/commonjs/docs/assets/highlight.css +17 -10
  18. package/lib/commonjs/docs/assets/icons.js +1 -1
  19. package/lib/commonjs/docs/assets/icons.js.map +1 -1
  20. package/lib/commonjs/docs/assets/icons.svg +1 -1
  21. package/lib/commonjs/docs/assets/main.js +220 -288
  22. package/lib/commonjs/docs/assets/main.js.map +1 -1
  23. package/lib/commonjs/docs/assets/navigation.js +1 -1
  24. package/lib/commonjs/docs/assets/navigation.js.map +1 -1
  25. package/lib/commonjs/docs/assets/search.js +1 -1
  26. package/lib/commonjs/docs/assets/search.js.map +1 -1
  27. package/lib/commonjs/docs/assets/style.css +21 -6
  28. package/lib/commonjs/docs/classes/sdk.Zello.html +793 -97
  29. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +122 -9
  30. package/lib/commonjs/docs/classes/types.ZelloChannel.html +155 -10
  31. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +86 -4
  32. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +90 -6
  33. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +163 -11
  34. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +178 -13
  35. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  36. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  37. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  38. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  39. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  40. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +130 -10
  41. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  42. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  43. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +146 -12
  44. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  45. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  46. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +114 -9
  47. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +122 -9
  48. package/lib/commonjs/docs/classes/types.ZelloTranscription.html +122 -0
  49. package/lib/commonjs/docs/classes/types.ZelloTranslation.html +91 -0
  50. package/lib/commonjs/docs/classes/types.ZelloUser.html +142 -11
  51. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  52. package/lib/commonjs/docs/enums/events.ZelloEvent.html +563 -95
  53. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +67 -5
  54. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  55. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  56. package/lib/commonjs/docs/enums/types.ZelloChannelType.html +84 -0
  57. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +68 -3
  58. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +73 -3
  59. package/lib/commonjs/docs/enums/types.ZelloContactType.html +73 -3
  60. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  61. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  62. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  63. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +78 -3
  64. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +81 -7
  65. package/lib/commonjs/docs/hierarchy.html +29 -1
  66. package/lib/commonjs/docs/index.html +155 -26
  67. package/lib/commonjs/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  68. package/lib/commonjs/docs/modules/events.html +37 -1
  69. package/lib/commonjs/docs/modules/index.html +37 -1
  70. package/lib/commonjs/docs/modules/sdk.html +37 -1
  71. package/lib/commonjs/docs/modules/specs_NativeZelloSdk.html +41 -0
  72. package/lib/commonjs/docs/modules/types.html +45 -1
  73. package/lib/commonjs/docs/modules.html +36 -1
  74. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +114 -9
  75. package/lib/commonjs/docs/types/types.ZelloConfig.html +86 -7
  76. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +96 -9
  77. package/lib/commonjs/docs/types/types.ZelloContact.html +80 -6
  78. package/lib/commonjs/docs/types/types.ZelloCredentials.html +75 -6
  79. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +97 -8
  80. package/lib/commonjs/docs/types/types.ZelloMessage.html +91 -7
  81. package/lib/commonjs/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  82. package/lib/commonjs/events/index.js +217 -0
  83. package/lib/commonjs/events/index.js.map +1 -1
  84. package/lib/commonjs/sdk/index.js +731 -911
  85. package/lib/commonjs/sdk/index.js.map +1 -1
  86. package/lib/commonjs/specs/NativeZelloSdk.js +27 -0
  87. package/lib/commonjs/specs/NativeZelloSdk.js.map +1 -0
  88. package/lib/commonjs/types/index.js +423 -302
  89. package/lib/commonjs/types/index.js.map +1 -1
  90. package/lib/commonjs/utils/index.js +27 -4
  91. package/lib/commonjs/utils/index.js.map +1 -1
  92. package/lib/module/docs/assets/highlight.css +17 -10
  93. package/lib/module/docs/assets/icons.js +1 -1
  94. package/lib/module/docs/assets/icons.js.map +1 -1
  95. package/lib/module/docs/assets/icons.svg +1 -1
  96. package/lib/module/docs/assets/main.js +220 -288
  97. package/lib/module/docs/assets/main.js.map +1 -1
  98. package/lib/module/docs/assets/navigation.js +1 -1
  99. package/lib/module/docs/assets/navigation.js.map +1 -1
  100. package/lib/module/docs/assets/search.js +1 -1
  101. package/lib/module/docs/assets/search.js.map +1 -1
  102. package/lib/module/docs/assets/style.css +21 -6
  103. package/lib/module/docs/classes/sdk.Zello.html +793 -97
  104. package/lib/module/docs/classes/types.ZelloAlertMessage.html +122 -9
  105. package/lib/module/docs/classes/types.ZelloChannel.html +155 -10
  106. package/lib/module/docs/classes/types.ZelloChannelUser.html +86 -4
  107. package/lib/module/docs/classes/types.ZelloDispatchCall.html +90 -6
  108. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +163 -11
  109. package/lib/module/docs/classes/types.ZelloGroupConversation.html +178 -13
  110. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  111. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  112. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  113. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  114. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  115. package/lib/module/docs/classes/types.ZelloImageMessage.html +130 -10
  116. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  117. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  118. package/lib/module/docs/classes/types.ZelloLocationMessage.html +146 -12
  119. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  120. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  121. package/lib/module/docs/classes/types.ZelloRecentEntry.html +114 -9
  122. package/lib/module/docs/classes/types.ZelloTextMessage.html +122 -9
  123. package/lib/module/docs/classes/types.ZelloTranscription.html +122 -0
  124. package/lib/module/docs/classes/types.ZelloTranslation.html +91 -0
  125. package/lib/module/docs/classes/types.ZelloUser.html +142 -11
  126. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  127. package/lib/module/docs/enums/events.ZelloEvent.html +563 -95
  128. package/lib/module/docs/enums/types.ZelloAccountStatus.html +67 -5
  129. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  130. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  131. package/lib/module/docs/enums/types.ZelloChannelType.html +84 -0
  132. package/lib/module/docs/enums/types.ZelloConnectionError.html +68 -3
  133. package/lib/module/docs/enums/types.ZelloConnectionState.html +73 -3
  134. package/lib/module/docs/enums/types.ZelloContactType.html +73 -3
  135. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  136. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  137. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  138. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +78 -3
  139. package/lib/module/docs/enums/types.ZelloUserStatus.html +81 -7
  140. package/lib/module/docs/hierarchy.html +29 -1
  141. package/lib/module/docs/index.html +155 -26
  142. package/lib/module/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  143. package/lib/module/docs/modules/events.html +37 -1
  144. package/lib/module/docs/modules/index.html +37 -1
  145. package/lib/module/docs/modules/sdk.html +37 -1
  146. package/lib/module/docs/modules/specs_NativeZelloSdk.html +41 -0
  147. package/lib/module/docs/modules/types.html +45 -1
  148. package/lib/module/docs/modules.html +36 -1
  149. package/lib/module/docs/types/types.ZelloChannelOptions.html +114 -9
  150. package/lib/module/docs/types/types.ZelloConfig.html +86 -7
  151. package/lib/module/docs/types/types.ZelloConsoleSettings.html +96 -9
  152. package/lib/module/docs/types/types.ZelloContact.html +80 -6
  153. package/lib/module/docs/types/types.ZelloCredentials.html +75 -6
  154. package/lib/module/docs/types/types.ZelloHistoryMessage.html +97 -8
  155. package/lib/module/docs/types/types.ZelloMessage.html +91 -7
  156. package/lib/module/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  157. package/lib/module/events/index.js +217 -0
  158. package/lib/module/events/index.js.map +1 -1
  159. package/lib/module/sdk/index.js +730 -912
  160. package/lib/module/sdk/index.js.map +1 -1
  161. package/lib/module/specs/NativeZelloSdk.js +25 -0
  162. package/lib/module/specs/NativeZelloSdk.js.map +1 -0
  163. package/lib/module/types/index.js +378 -301
  164. package/lib/module/types/index.js.map +1 -1
  165. package/lib/module/utils/index.js +27 -5
  166. package/lib/module/utils/index.js.map +1 -1
  167. package/lib/typescript/commonjs/src/events/index.d.ts +9 -0
  168. package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/src/sdk/index.d.ts +10 -0
  170. package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
  171. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts +55 -0
  172. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/src/types/index.d.ts +106 -4
  174. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
  176. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  177. package/lib/typescript/module/src/events/index.d.ts +9 -0
  178. package/lib/typescript/module/src/events/index.d.ts.map +1 -1
  179. package/lib/typescript/module/src/index.d.ts +4 -4
  180. package/lib/typescript/module/src/index.d.ts.map +1 -1
  181. package/lib/typescript/module/src/sdk/index.d.ts +11 -1
  182. package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
  183. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts +55 -0
  184. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts.map +1 -0
  185. package/lib/typescript/module/src/types/index.d.ts +106 -4
  186. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  187. package/lib/typescript/module/src/utils/algorithms/index.d.ts +1 -1
  188. package/lib/typescript/module/src/utils/algorithms/index.d.ts.map +1 -1
  189. package/lib/typescript/module/src/utils/index.d.ts +2 -1
  190. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  191. package/package.json +53 -16
  192. package/react-native-zello-sdk.podspec +23 -24
  193. package/scripts/podfile-transform.js +416 -0
  194. package/scripts/setup-ios.js +248 -0
  195. package/scripts/zello_pods.rb +128 -0
  196. package/scripts/zello_sdk_requirement.rb +12 -0
  197. package/src/events/index.ts +9 -0
  198. package/src/sdk/index.ts +105 -225
  199. package/src/specs/NativeZelloSdk.ts +89 -0
  200. package/src/types/index.ts +153 -6
  201. package/src/utils/index.ts +50 -3
package/app.plugin.js ADDED
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Expo config plugin: migrates the generated Podfile to the SwiftPM-based native ZelloSDK and
5
+ * makes sure extension targets meet the iOS 17.0 deployment target.
6
+ *
7
+ * "plugins": [["@zelloptt/react-native-zello-sdk", { "extensionTargets": ["NotificationServiceExtension"] }]]
8
+ *
9
+ * The app's deployment target itself comes from `expo-build-properties`
10
+ * (`ios.deploymentTarget: "17.0"`). Expo runs mods in reverse plugin order, so list this plugin
11
+ * before any plugin that creates the extension target.
12
+ */
13
+
14
+ const {
15
+ createRunOncePlugin,
16
+ withPodfile,
17
+ withXcodeProject,
18
+ } = require('expo/config-plugins');
19
+ const {
20
+ MIN_IOS,
21
+ compareVersions,
22
+ transformPodfile,
23
+ } = require('./scripts/podfile-transform');
24
+ const pkg = require('./package.json');
25
+
26
+ const unquote = (s) => String(s).replace(/^"(.*)"$/, '$1');
27
+
28
+ /** Raises IPHONEOS_DEPLOYMENT_TARGET to MIN_IOS on the named native targets (xcode project object). */
29
+ function setExtensionDeploymentTarget(project, extensionTargets) {
30
+ const lists = project.pbxXCConfigurationList();
31
+ const configs = project.pbxXCBuildConfigurationSection();
32
+ const sections = project.pbxNativeTargetSection();
33
+ const targets = Object.keys(sections)
34
+ .map((key) => sections[key])
35
+ .filter((target) => typeof target === 'object');
36
+ const missing = extensionTargets.filter(
37
+ (name) => !targets.some((target) => unquote(target.name) === name)
38
+ );
39
+ if (missing.length) {
40
+ throw new Error(
41
+ `[react-native-zello-sdk] Extension target(s) ${missing.join(', ')} not found in the Xcode project. ` +
42
+ 'List @zelloptt/react-native-zello-sdk before the plugin that creates them (Expo runs mods in reverse order).'
43
+ );
44
+ }
45
+ targets.forEach((target) => {
46
+ if (!extensionTargets.includes(unquote(target.name))) {
47
+ return;
48
+ }
49
+ const list = lists[target.buildConfigurationList];
50
+ (list ? list.buildConfigurations : []).forEach(({ value }) => {
51
+ const settings = configs[value].buildSettings;
52
+ const current = settings.IPHONEOS_DEPLOYMENT_TARGET;
53
+ if (!current || compareVersions(unquote(current), MIN_IOS) < 0) {
54
+ settings.IPHONEOS_DEPLOYMENT_TARGET = MIN_IOS;
55
+ }
56
+ });
57
+ });
58
+ return project;
59
+ }
60
+
61
+ function withZelloSdk(config, props = {}) {
62
+ const extensionTargets = (props && props.extensionTargets) || [];
63
+ if (
64
+ !Array.isArray(extensionTargets) ||
65
+ !extensionTargets.every((name) => typeof name === 'string' && name)
66
+ ) {
67
+ throw new Error(
68
+ '[react-native-zello-sdk] `extensionTargets` must be an array of target names (strings).'
69
+ );
70
+ }
71
+
72
+ config = withPodfile(config, (cfg) => {
73
+ const result = transformPodfile(cfg.modResults.contents, {
74
+ appTarget: cfg.modRequest.projectName,
75
+ extensionTargets,
76
+ });
77
+ if (result.manual.length) {
78
+ throw new Error(
79
+ `[react-native-zello-sdk] Could not migrate the Podfile:\n - ${result.manual.join('\n - ')}` +
80
+ (result.snippet ? `\n\n${result.snippet}` : '')
81
+ );
82
+ }
83
+ cfg.modResults.contents = result.content;
84
+ return cfg;
85
+ });
86
+
87
+ if (extensionTargets.length) {
88
+ config = withXcodeProject(config, (cfg) => {
89
+ setExtensionDeploymentTarget(cfg.modResults, extensionTargets);
90
+ return cfg;
91
+ });
92
+ }
93
+ return config;
94
+ }
95
+
96
+ module.exports = createRunOncePlugin(withZelloSdk, pkg.name, pkg.version);
97
+ module.exports.setExtensionDeploymentTarget = setExtensionDeploymentTarget;
@@ -22,15 +22,19 @@ extension ZelloChannel {
22
22
  "isConnected": status == .connected,
23
23
  "isConnecting": status == .connecting,
24
24
  "usersOnline": usersOnline,
25
+ "channelType": type.bridgeString,
26
+ "translationsEnabled": translationsEnabled,
25
27
  "options": [
26
28
  "noDisconnect": channelOptions.noDisconnect,
27
29
  "hidePowerButton": channelOptions.hidePowerButton,
28
30
  "listenOnly": channelOptions.listenOnly,
29
31
  "allowAlerts": channelOptions.allowAlerts,
30
32
  "allowTextMessages": channelOptions.allowTextMessages,
31
- "allowLocations": channelOptions.allowLocations
33
+ "allowLocations": channelOptions.allowLocations,
34
+ "allowEmergencyEndOwn": channelOptions.allowEmergencyEndOwn,
35
+ "allowEmergencyEndOthers": channelOptions.allowEmergencyEndOthers
32
36
  ],
33
- "isDispatchChannel": dispatchInfo != nil
37
+ "isDispatchChannel": type == .dispatch || dispatchInfo != nil
34
38
  ]
35
39
  if let currentCall = dispatchInfo?.currentCall {
36
40
  body["currentCall"] = currentCall.jsonDictionary
@@ -39,6 +43,21 @@ extension ZelloChannel {
39
43
  }
40
44
  }
41
45
 
46
+ extension ZelloChannel.ChannelType {
47
+ var bridgeString: String {
48
+ switch self {
49
+ case .dispatch:
50
+ return "DISPATCH"
51
+ case .team:
52
+ return "TEAM"
53
+ case .dynamic:
54
+ return "DYNAMIC"
55
+ @unknown default:
56
+ return "DYNAMIC"
57
+ }
58
+ }
59
+ }
60
+
42
61
  extension ZelloUser {
43
62
  var jsonDictionary: [AnyHashable: Any] {
44
63
  var body: [AnyHashable: Any] = [
@@ -70,13 +89,17 @@ extension ZelloGroupConversation {
70
89
  "isConnected": status == .connected,
71
90
  "isConnecting": status == .connecting,
72
91
  "usersOnline": onlineUsers.count,
92
+ "channelType": "GROUP_CONVERSATION",
93
+ "translationsEnabled": false,
73
94
  "options": [
74
95
  "noDisconnect": false,
75
96
  "hidePowerButton": false,
76
97
  "listenOnly": false,
77
98
  "allowAlerts": true,
78
99
  "allowTextMessages": true,
79
- "allowLocations": true
100
+ "allowLocations": true,
101
+ "allowEmergencyEndOwn": false,
102
+ "allowEmergencyEndOthers": false
80
103
  ],
81
104
  "isGroupConversation": true,
82
105
  "displayName": displayName,
@@ -13,6 +13,9 @@ extension ZelloHistoryVoiceMessage {
13
13
  if let channelUserName = channelUser?.name {
14
14
  body["channelUserName"] = channelUserName
15
15
  }
16
+ if let transcription {
17
+ body["transcription"] = transcription.jsonDictionary
18
+ }
16
19
  return body
17
20
  }
18
21
  }
@@ -85,7 +85,8 @@ extension ZelloIOSSdkModule: Zello.Delegate {
85
85
  func zello(_ zello: Zello, didStartReceiving incomingVoiceMessage: ZelloIncomingVoiceMessage) {
86
86
  var body: [AnyHashable: Any] = [
87
87
  "contact": incomingVoiceMessage.contact.jsonDictionary,
88
- "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
88
+ "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp,
89
+ "isTranslation": incomingVoiceMessage.isTranslation
89
90
  ]
90
91
  if let channelUser = incomingVoiceMessage.channelUser {
91
92
  body["channelUser"] = channelUser.jsonDictionary
@@ -96,7 +97,8 @@ extension ZelloIOSSdkModule: Zello.Delegate {
96
97
  func zello(_ zello: Zello, didFinishReceiving incomingVoiceMessage: ZelloIncomingVoiceMessage) {
97
98
  var body: [AnyHashable: Any] = [
98
99
  "contact": incomingVoiceMessage.contact.jsonDictionary,
99
- "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
100
+ "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp,
101
+ "isTranslation": incomingVoiceMessage.isTranslation
100
102
  ]
101
103
  if let channelUser = incomingVoiceMessage.channelUser {
102
104
  body["channelUser"] = channelUser.jsonDictionary
@@ -291,6 +293,10 @@ extension ZelloIOSSdkModule: Zello.Delegate {
291
293
  sendSdkEvent(withName: "onHistoryPlaybackStopped", body: message.jsonDictionary)
292
294
  }
293
295
 
296
+ func zello(_ zello: Zello, didReceiveTranscriptionFor message: ZelloHistoryVoiceMessage) {
297
+ sendSdkEvent(withName: "onHistoryVoiceMessageTranscriptionAvailable", body: message.jsonDictionary)
298
+ }
299
+
294
300
  func zello(_ zello: Zello, callDidBecomePending call: ZelloDispatchCall, on channel: ZelloChannel) {
295
301
  let body: [AnyHashable: Any] = [
296
302
  "call": call.jsonDictionary,
@@ -4,6 +4,7 @@ extension ZelloIncomingEmergency {
4
4
  var jsonDictionary: [AnyHashable: Any] {
5
5
  var body: [AnyHashable: Any] = [
6
6
  "channel": channel.jsonDictionary,
7
+ "channelUser": channelUser.jsonDictionary,
7
8
  "channelUserName": channelUser.name,
8
9
  "emergencyId": id,
9
10
  "startTimestamp": startTimestamp.bridgeTimestamp
@@ -0,0 +1,18 @@
1
+ import ZelloSDK
2
+
3
+ extension ZelloTranscription {
4
+ var jsonDictionary: [AnyHashable: Any] {
5
+ return [
6
+ "text": text,
7
+ "language": language,
8
+ "isTruncated": isTruncated,
9
+ "confidence": confidence,
10
+ "translations": translations.map { translation in
11
+ [
12
+ "text": translation.text,
13
+ "language": translation.language
14
+ ]
15
+ }
16
+ ]
17
+ }
18
+ }
@@ -1,10 +1,15 @@
1
1
  import ZelloSDK
2
2
 
3
- @objc(ZelloIOSSdkModule) class ZelloIOSSdkModule: RCTEventEmitter {
3
+ @objc(ZelloIOSSdkModule) class ZelloIOSSdkModule: NSObject {
4
4
 
5
5
  private let bridgeEventName = "zellosdk"
6
6
  private let eventName = "eventName"
7
7
 
8
+ // Injected by React Native. The bridgeless-safe way to call a JS module
9
+ // (here RCTDeviceEventEmitter) from native; RCTEventEmitter's sendEvent path
10
+ // is not callable under the bridgeless New Architecture.
11
+ @objc var callableJSModules: RCTCallableJSModules?
12
+
8
13
  let zello = Zello.shared
9
14
 
10
15
  override init() {
@@ -160,6 +165,18 @@ import ZelloSDK
160
165
  }
161
166
  }
162
167
 
168
+ @objc func stopIncomingEmergency(_ emergencyId: String) {
169
+ DispatchQueue.main.async { [weak self] in
170
+ guard
171
+ let self,
172
+ let incomingEmergency = self.zello.incomingEmergencies.first(where: { $0.id == emergencyId })
173
+ else {
174
+ return
175
+ }
176
+ self.zello.stopIncomingEmergency(incomingEmergency)
177
+ }
178
+ }
179
+
163
180
  @objc func getHistory(_ name: String, contactType: String, maxMessages: Int, callback: RCTResponseSenderBlock) {
164
181
  guard let contact = contactFromType(contactType, name: name) else {
165
182
  callback(nil)
@@ -271,14 +288,14 @@ extension ZelloIOSSdkModule {
271
288
  func sendSdkEvent(withName name: String, body: [AnyHashable: Any]?) {
272
289
  var eventBody = body ?? [:]
273
290
  eventBody[eventName] = name
274
- sendEvent(withName: bridgeEventName, body: eventBody)
275
- }
276
-
277
- override func supportedEvents() -> [String]! {
278
- return [bridgeEventName]
291
+ callableJSModules?.invokeModule(
292
+ "RCTDeviceEventEmitter",
293
+ method: "emit",
294
+ withArgs: [bridgeEventName, eventBody]
295
+ )
279
296
  }
280
297
 
281
- override class func requiresMainQueueSetup() -> Bool {
298
+ @objc static func requiresMainQueueSetup() -> Bool {
282
299
  return true
283
300
  }
284
301
  }
@@ -35,6 +35,7 @@ RCT_EXTERN_METHOD(unmuteContact:(NSString *)name contactType:(NSString *)contact
35
35
 
36
36
  RCT_EXTERN_METHOD(startEmergency)
37
37
  RCT_EXTERN_METHOD(stopEmergency)
38
+ RCT_EXTERN_METHOD(stopIncomingEmergency:(NSString *)emergencyId)
38
39
 
39
40
  RCT_EXTERN_METHOD(getHistory:(NSString *)name contactType:(NSString *)contactType maxMessages:(NSInteger)maxMessages callback:(RCTResponseSenderBlock)callback)
40
41
 
@@ -0,0 +1,8 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ // Keep this header free of the generated spec import: the spec header
4
+ // (RNZelloSdkSpec.h) is Objective-C++ only, and this header is pulled into the
5
+ // pod's Swift umbrella. The `<NativeZelloSdkSpec>` conformance and the C++
6
+ // TurboModule glue live in ZelloSdkModule.mm instead.
7
+ @interface ZelloSdkModule : NSObject <RCTBridgeModule>
8
+ @end
@@ -0,0 +1,189 @@
1
+ #import "ZelloSdkModule.h"
2
+
3
+ // Generated Swift interface header for this pod (module name derived from the
4
+ // podspec name `react-native-zello-sdk`). Use the framework-style import when
5
+ // built with use_frameworks!, falling back to the flat header otherwise.
6
+ #if __has_include(<react_native_zello_sdk/react_native_zello_sdk-Swift.h>)
7
+ #import <react_native_zello_sdk/react_native_zello_sdk-Swift.h>
8
+ #else
9
+ #import "react_native_zello_sdk-Swift.h"
10
+ #endif
11
+
12
+ #ifdef RCT_NEW_ARCH_ENABLED
13
+ // The generated spec header is Objective-C++ only, so it is imported here in
14
+ // the .mm rather than in the public .h. Conformance is declared via a class
15
+ // extension so the public interface stays Swift-umbrella safe.
16
+ #import "RNZelloSdkSpec.h"
17
+
18
+ @interface ZelloSdkModule () <NativeZelloSdkSpec>
19
+ @end
20
+ #endif
21
+
22
+ @implementation ZelloSdkModule {
23
+ ZelloSdkModuleImpl *_impl;
24
+ }
25
+
26
+ RCT_EXPORT_MODULE(NativeZelloSdk)
27
+
28
+ - (instancetype)init {
29
+ if (self = [super init]) {
30
+ _impl = [ZelloSdkModuleImpl new];
31
+ }
32
+ return self;
33
+ }
34
+
35
+ + (BOOL)requiresMainQueueSetup {
36
+ return YES;
37
+ }
38
+
39
+ #ifdef RCT_NEW_ARCH_ENABLED
40
+
41
+ - (void)configure:(NSDictionary *)config {
42
+ [_impl configure:config];
43
+ }
44
+
45
+ - (void)connect:(NSString *)network username:(NSString *)username password:(NSString *)password {
46
+ [_impl connect:network username:username password:password];
47
+ }
48
+
49
+ - (void)disconnect {
50
+ [_impl disconnect];
51
+ }
52
+
53
+ - (void)setAccountStatus:(NSString *)status {
54
+ [_impl setAccountStatus:status];
55
+ }
56
+
57
+ - (void)selectContact:(NSString *)name contactType:(NSString *)contactType {
58
+ [_impl selectContact:name contactType:contactType];
59
+ }
60
+
61
+ - (void)startVoiceMessage:(NSString *)name contactType:(NSString *)contactType {
62
+ [_impl startVoiceMessage:name contactType:contactType];
63
+ }
64
+
65
+ - (void)stopVoiceMessage {
66
+ [_impl stopVoiceMessage];
67
+ }
68
+
69
+ - (void)sendImage:(NSString *)name contactType:(NSString *)contactType data:(NSArray *)data {
70
+ [_impl sendImage:name contactType:contactType data:data];
71
+ }
72
+
73
+ - (void)sendLocation:(NSString *)name contactType:(NSString *)contactType {
74
+ [_impl sendLocation:name contactType:contactType];
75
+ }
76
+
77
+ - (void)sendText:(NSString *)name contactType:(NSString *)contactType text:(NSString *)text {
78
+ [_impl sendText:name contactType:contactType text:text];
79
+ }
80
+
81
+ - (void)sendAlert:(NSString *)name
82
+ contactType:(NSString *)contactType
83
+ text:(NSString *)text
84
+ level:(NSString *)level {
85
+ [_impl sendAlert:name contactType:contactType text:text level:level];
86
+ }
87
+
88
+ - (void)connectChannel:(NSString *)name {
89
+ [_impl connectChannel:name];
90
+ }
91
+
92
+ - (void)disconnectChannel:(NSString *)name {
93
+ [_impl disconnectChannel:name];
94
+ }
95
+
96
+ - (void)connectGroupConversation:(NSString *)name {
97
+ [_impl connectGroupConversation:name];
98
+ }
99
+
100
+ - (void)disconnectGroupConversation:(NSString *)name {
101
+ [_impl disconnectGroupConversation:name];
102
+ }
103
+
104
+ - (void)submitProblemReport {
105
+ [_impl submitProblemReport];
106
+ }
107
+
108
+ - (void)muteContact:(NSString *)name contactType:(NSString *)contactType {
109
+ [_impl muteContact:name contactType:contactType];
110
+ }
111
+
112
+ - (void)unmuteContact:(NSString *)name contactType:(NSString *)contactType {
113
+ [_impl unmuteContact:name contactType:contactType];
114
+ }
115
+
116
+ - (void)startEmergency {
117
+ [_impl startEmergency];
118
+ }
119
+
120
+ - (void)stopEmergency {
121
+ [_impl stopEmergency];
122
+ }
123
+
124
+ - (void)stopIncomingEmergency:(NSString *)emergencyId {
125
+ [_impl stopIncomingEmergency:emergencyId];
126
+ }
127
+
128
+ - (void)getHistory:(NSString *)name
129
+ contactType:(NSString *)contactType
130
+ maxMessages:(double)maxMessages
131
+ resolve:(RCTPromiseResolveBlock)resolve
132
+ reject:(RCTPromiseRejectBlock)reject {
133
+ [_impl getHistory:name
134
+ contactType:contactType
135
+ maxMessages:(NSInteger)maxMessages
136
+ resolve:resolve
137
+ reject:reject];
138
+ }
139
+
140
+ - (void)playHistoryMessage:(NSString *)historyId
141
+ contactName:(NSString *)contactName
142
+ contactType:(NSString *)contactType {
143
+ [_impl playHistoryMessage:historyId contactName:contactName contactType:contactType];
144
+ }
145
+
146
+ - (void)stopHistoryMessagePlayback {
147
+ [_impl stopHistoryMessagePlayback];
148
+ }
149
+
150
+ - (void)getHistoryImageData:(NSString *)historyId
151
+ contactName:(NSString *)contactName
152
+ contactType:(NSString *)contactType
153
+ resolve:(RCTPromiseResolveBlock)resolve
154
+ reject:(RCTPromiseRejectBlock)reject {
155
+ [_impl getHistoryImageData:historyId
156
+ contactName:contactName
157
+ contactType:contactType
158
+ resolve:resolve
159
+ reject:reject];
160
+ }
161
+
162
+ - (void)endDispatchCall:(NSString *)channelName {
163
+ [_impl endDispatchCall:channelName];
164
+ }
165
+
166
+ - (void)createGroupConversation:(NSArray *)usernames displayName:(NSString *)displayName {
167
+ [_impl createGroupConversation:usernames displayName:displayName];
168
+ }
169
+
170
+ - (void)addUsersToGroupConversation:(NSString *)conversationName usernames:(NSArray *)usernames {
171
+ [_impl addUsersToGroupConversation:conversationName usernames:usernames];
172
+ }
173
+
174
+ - (void)leaveGroupConversation:(NSString *)conversationName {
175
+ [_impl leaveGroupConversation:conversationName];
176
+ }
177
+
178
+ - (void)renameGroupConversation:(NSString *)conversationName newName:(NSString *)newName {
179
+ [_impl renameGroupConversation:conversationName newName:newName];
180
+ }
181
+
182
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
183
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
184
+ return std::make_shared<facebook::react::NativeZelloSdkSpecJSI>(params);
185
+ }
186
+
187
+ #endif
188
+
189
+ @end