@zelloptt/react-native-zello-sdk 0.3.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/android/build.gradle +5 -3
- package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +117 -7
- package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +76 -8
- package/ios/Extensions/ZelloConsoleSettings+Extension.swift +14 -0
- package/ios/Extensions/ZelloContact+Extension.swift +56 -2
- package/ios/Extensions/ZelloDispatchCall+Extension.swift +13 -0
- package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +81 -8
- package/ios/ZelloIOSSdkModule.swift +61 -5
- package/ios/ZelloIOSSdkModuleBridge.m +14 -1
- package/lib/commonjs/docs/assets/highlight.css +18 -4
- package/lib/commonjs/docs/assets/navigation.js +1 -1
- package/lib/commonjs/docs/assets/navigation.js.map +1 -1
- package/lib/commonjs/docs/assets/search.js +1 -1
- package/lib/commonjs/docs/assets/search.js.map +1 -1
- package/lib/commonjs/docs/classes/sdk.Zello.html +75 -43
- package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloChannel.html +8 -8
- package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +5 -4
- package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +7 -0
- package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +19 -0
- package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +24 -0
- package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
- package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
- package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
- package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
- package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +8 -8
- package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
- package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +10 -10
- package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
- package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +7 -7
- package/lib/commonjs/docs/classes/types.ZelloUser.html +10 -8
- package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
- package/lib/commonjs/docs/enums/events.ZelloEvent.html +108 -67
- package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +3 -3
- package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
- package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloContactType.html +4 -2
- package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +6 -0
- package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +2 -2
- package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +5 -5
- package/lib/commonjs/docs/index.html +16 -8
- package/lib/commonjs/docs/modules/events.html +1 -1
- package/lib/commonjs/docs/modules/index.html +9 -3
- package/lib/commonjs/docs/modules/sdk.html +1 -1
- package/lib/commonjs/docs/modules/types.html +7 -1
- package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +4 -4
- package/lib/commonjs/docs/types/types.ZelloConfig.html +4 -3
- package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +8 -0
- package/lib/commonjs/docs/types/types.ZelloContact.html +1 -1
- package/lib/commonjs/docs/types/types.ZelloCredentials.html +2 -2
- package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +1 -1
- package/lib/commonjs/docs/types/types.ZelloMessage.html +1 -1
- package/lib/commonjs/events/index.js +11 -0
- package/lib/commonjs/events/index.js.map +1 -1
- package/lib/commonjs/sdk/index.js +237 -16
- package/lib/commonjs/sdk/index.js.map +1 -1
- package/lib/commonjs/types/index.js +110 -4
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/utils/index.js +73 -9
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/docs/assets/highlight.css +18 -4
- package/lib/module/docs/assets/navigation.js +1 -1
- package/lib/module/docs/assets/navigation.js.map +1 -1
- package/lib/module/docs/assets/search.js +1 -1
- package/lib/module/docs/assets/search.js.map +1 -1
- package/lib/module/docs/classes/sdk.Zello.html +75 -43
- package/lib/module/docs/classes/types.ZelloAlertMessage.html +7 -7
- package/lib/module/docs/classes/types.ZelloChannel.html +8 -8
- package/lib/module/docs/classes/types.ZelloChannelUser.html +5 -4
- package/lib/module/docs/classes/types.ZelloDispatchCall.html +7 -0
- package/lib/module/docs/classes/types.ZelloDispatchChannel.html +19 -0
- package/lib/module/docs/classes/types.ZelloGroupConversation.html +24 -0
- package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
- package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
- package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
- package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
- package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
- package/lib/module/docs/classes/types.ZelloImageMessage.html +8 -8
- package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +7 -7
- package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
- package/lib/module/docs/classes/types.ZelloLocationMessage.html +10 -10
- package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
- package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
- package/lib/module/docs/classes/types.ZelloRecentEntry.html +7 -7
- package/lib/module/docs/classes/types.ZelloTextMessage.html +7 -7
- package/lib/module/docs/classes/types.ZelloUser.html +10 -8
- package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
- package/lib/module/docs/enums/events.ZelloEvent.html +108 -67
- package/lib/module/docs/enums/types.ZelloAccountStatus.html +3 -3
- package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
- package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
- package/lib/module/docs/enums/types.ZelloConnectionError.html +2 -2
- package/lib/module/docs/enums/types.ZelloConnectionState.html +2 -2
- package/lib/module/docs/enums/types.ZelloContactType.html +4 -2
- package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +6 -0
- package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
- package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
- package/lib/module/docs/enums/types.ZelloRecentEntryType.html +2 -2
- package/lib/module/docs/enums/types.ZelloUserStatus.html +5 -5
- package/lib/module/docs/index.html +16 -8
- package/lib/module/docs/modules/events.html +1 -1
- package/lib/module/docs/modules/index.html +9 -3
- package/lib/module/docs/modules/sdk.html +1 -1
- package/lib/module/docs/modules/types.html +7 -1
- package/lib/module/docs/types/types.ZelloChannelOptions.html +4 -4
- package/lib/module/docs/types/types.ZelloConfig.html +4 -3
- package/lib/module/docs/types/types.ZelloConsoleSettings.html +8 -0
- package/lib/module/docs/types/types.ZelloContact.html +1 -1
- package/lib/module/docs/types/types.ZelloCredentials.html +2 -2
- package/lib/module/docs/types/types.ZelloHistoryMessage.html +1 -1
- package/lib/module/docs/types/types.ZelloMessage.html +1 -1
- package/lib/module/events/index.js +11 -0
- package/lib/module/events/index.js.map +1 -1
- package/lib/module/sdk/index.js +240 -17
- package/lib/module/sdk/index.js.map +1 -1
- package/lib/module/types/index.js +115 -3
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/utils/index.js +71 -10
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/commonjs/src/events/index.d.ts +65 -2
- package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sdk/index.d.ts +53 -4
- package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/index.d.ts +109 -6
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts +4 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/events/index.d.ts +65 -2
- package/lib/typescript/module/src/events/index.d.ts.map +1 -1
- package/lib/typescript/module/src/sdk/index.d.ts +53 -4
- package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types/index.d.ts +109 -6
- package/lib/typescript/module/src/types/index.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/index.d.ts +4 -1
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/package.json +1 -2
- package/react-native-zello-sdk.podspec +1 -1
- package/src/events/index.ts +64 -1
- package/src/sdk/index.ts +286 -19
- package/src/types/index.ts +152 -5
- package/src/utils/index.ts +124 -29
package/src/sdk/index.ts
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
EmitterSubscription,
|
|
3
5
|
NativeEventEmitter,
|
|
4
6
|
NativeModules,
|
|
5
7
|
} from 'react-native';
|
|
6
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
bridgeCallToSdkCall,
|
|
10
|
+
bridgeChannelUserToSdkChannelUser,
|
|
11
|
+
bridgeConsoleSettingsToSdkConsoleSettings,
|
|
12
|
+
isAndroid,
|
|
13
|
+
} from '../utils';
|
|
7
14
|
import {
|
|
8
15
|
ZelloAccountStatus,
|
|
9
16
|
ZelloAlertMessage,
|
|
10
17
|
ZelloChannel,
|
|
11
18
|
ZelloChannelAlertLevel,
|
|
12
|
-
ZelloChannelUser,
|
|
13
19
|
ZelloConfig,
|
|
14
20
|
ZelloConnectionError,
|
|
15
21
|
ZelloConnectionState,
|
|
22
|
+
ZelloConsoleSettings,
|
|
16
23
|
ZelloContact,
|
|
17
24
|
ZelloContactType,
|
|
18
25
|
ZelloCredentials,
|
|
26
|
+
ZelloDispatchChannel,
|
|
27
|
+
ZelloGroupConversation,
|
|
19
28
|
ZelloHistoryImageMessage,
|
|
20
29
|
ZelloHistoryMessage,
|
|
21
30
|
ZelloHistoryVoiceMessage,
|
|
@@ -74,6 +83,10 @@ export class Zello extends EventEmitter {
|
|
|
74
83
|
* The list of {@link ZelloChannel} in the contact list. Sorted by name, ascending.
|
|
75
84
|
*/
|
|
76
85
|
public channels: ZelloChannel[] = [];
|
|
86
|
+
/**
|
|
87
|
+
* The list of {@link ZelloGroupConversation} in the contact list. Sorted by name, ascending.
|
|
88
|
+
*/
|
|
89
|
+
public groupConversations: ZelloGroupConversation[] = [];
|
|
77
90
|
|
|
78
91
|
/**
|
|
79
92
|
* The current account status. undefined when {@link state} is not {@link ZelloConnectionState.Connected}.
|
|
@@ -113,6 +126,12 @@ export class Zello extends EventEmitter {
|
|
|
113
126
|
*/
|
|
114
127
|
public historyVoiceMessage: ZelloHistoryVoiceMessage | undefined;
|
|
115
128
|
|
|
129
|
+
/**
|
|
130
|
+
* The console settings for the network.
|
|
131
|
+
* This is only expected to be valid when {@link state} is {@link ZelloConnectionState.Connected}.
|
|
132
|
+
*/
|
|
133
|
+
public consoleSettings: ZelloConsoleSettings | undefined;
|
|
134
|
+
|
|
116
135
|
private eventListener: EmitterSubscription | undefined;
|
|
117
136
|
|
|
118
137
|
private constructor() {
|
|
@@ -131,9 +150,6 @@ export class Zello extends EventEmitter {
|
|
|
131
150
|
|
|
132
151
|
/**
|
|
133
152
|
* Sets configuration variables for the SDK.
|
|
134
|
-
*
|
|
135
|
-
* At the moment, this is only functional on Android.
|
|
136
|
-
*
|
|
137
153
|
* @param config The configuration to set.
|
|
138
154
|
*/
|
|
139
155
|
public configure(config: ZelloConfig) {
|
|
@@ -143,7 +159,7 @@ export class Zello extends EventEmitter {
|
|
|
143
159
|
config.android.enableForegroundService
|
|
144
160
|
);
|
|
145
161
|
} else {
|
|
146
|
-
ZelloIOSSdkModule.configure(config.ios.isDebugBuild);
|
|
162
|
+
ZelloIOSSdkModule.configure(config.ios.isDebugBuild, config.ios.appGroup);
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
165
|
|
|
@@ -208,6 +224,17 @@ export class Zello extends EventEmitter {
|
|
|
208
224
|
return sortedArrayFind(this.channels, name, compareNameAscending);
|
|
209
225
|
}
|
|
210
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Returns the group conversation with the given name. Case-insensitive.
|
|
229
|
+
* @param name The name of the group conversation to search for.
|
|
230
|
+
* @return The group conversation with the given name, or null if no group conversation with that name exists.
|
|
231
|
+
*/
|
|
232
|
+
public getGroupConversation(
|
|
233
|
+
name: string
|
|
234
|
+
): ZelloGroupConversation | undefined {
|
|
235
|
+
return sortedArrayFind(this.groupConversations, name, compareNameAscending);
|
|
236
|
+
}
|
|
237
|
+
|
|
211
238
|
/**
|
|
212
239
|
* Sets the selected contact.
|
|
213
240
|
* While optional, this is typically used for tracking the contact that the user is currently interacting with.
|
|
@@ -246,7 +273,11 @@ export class Zello extends EventEmitter {
|
|
|
246
273
|
if (isAndroid) {
|
|
247
274
|
ZelloAndroidSdkModule.connectChannel(channel.name);
|
|
248
275
|
} else {
|
|
249
|
-
|
|
276
|
+
if (channel.type === ZelloContactType.GroupConversation) {
|
|
277
|
+
ZelloIOSSdkModule.connectGroupConversation(channel.name);
|
|
278
|
+
} else {
|
|
279
|
+
ZelloIOSSdkModule.connectChannel(channel.name);
|
|
280
|
+
}
|
|
250
281
|
}
|
|
251
282
|
}
|
|
252
283
|
|
|
@@ -260,7 +291,11 @@ export class Zello extends EventEmitter {
|
|
|
260
291
|
if (isAndroid) {
|
|
261
292
|
ZelloAndroidSdkModule.disconnectChannel(channel.name);
|
|
262
293
|
} else {
|
|
263
|
-
|
|
294
|
+
if (channel.type === ZelloContactType.GroupConversation) {
|
|
295
|
+
ZelloIOSSdkModule.disconnectGroupConversation(channel.name);
|
|
296
|
+
} else {
|
|
297
|
+
ZelloIOSSdkModule.disconnectChannel(channel.name);
|
|
298
|
+
}
|
|
264
299
|
}
|
|
265
300
|
}
|
|
266
301
|
|
|
@@ -523,6 +558,110 @@ export class Zello extends EventEmitter {
|
|
|
523
558
|
});
|
|
524
559
|
}
|
|
525
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Ends the dispatch call for the given dispatch channel.
|
|
563
|
+
* This will trigger the {@link ZelloEvent.DISPATCH_CALL_ENDED} event.
|
|
564
|
+
*
|
|
565
|
+
* If {@link consoleSettings | ZelloConsoleSettings.allowNonDispatchersToEndCalls} is false, this method will do nothing.
|
|
566
|
+
*
|
|
567
|
+
* @param channel The dispatch channel to end the call for.
|
|
568
|
+
*/
|
|
569
|
+
public endDispatchCall(channel: ZelloDispatchChannel) {
|
|
570
|
+
if (isAndroid) {
|
|
571
|
+
ZelloAndroidSdkModule.endDispatchCall(channel.name);
|
|
572
|
+
} else {
|
|
573
|
+
ZelloIOSSdkModule.endDispatchCall(channel.name);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Creates a new group conversation with the given users.
|
|
579
|
+
* This will trigger the {@link ZelloEvent.GROUP_CONVERSATION_CREATED} and {@link ZelloEvent.CONTACT_LIST_UPDATED} events.
|
|
580
|
+
* @param users The users to create the group conversation with.
|
|
581
|
+
* @param displayName Optional; The display name of the group conversation. The conversation can be renamed later by using {@link renameGroupConversation}.
|
|
582
|
+
*/
|
|
583
|
+
public createGroupConversation(users: ZelloUser[], displayName?: string) {
|
|
584
|
+
if (!this.consoleSettings?.allowGroupConversations) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (isAndroid) {
|
|
588
|
+
ZelloAndroidSdkModule.createGroupConversation(
|
|
589
|
+
users.map((user) => user.name),
|
|
590
|
+
displayName
|
|
591
|
+
);
|
|
592
|
+
} else {
|
|
593
|
+
ZelloIOSSdkModule.createGroupConversation(
|
|
594
|
+
users.map((user) => user.name),
|
|
595
|
+
displayName
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Adds users to the given group conversation.
|
|
602
|
+
* This will trigger the {@link ZelloEvent.GROUP_CONVERSATION_USERS_ADDED} and {@link ZelloEvent.CONTACT_LIST_UPDATED} events.
|
|
603
|
+
* @param groupConversation The group conversation to add users to.
|
|
604
|
+
* @param users The users to add to the group conversation.
|
|
605
|
+
*/
|
|
606
|
+
public addUsersToGroupConversation(
|
|
607
|
+
groupConversation: ZelloGroupConversation,
|
|
608
|
+
users: ZelloUser[]
|
|
609
|
+
) {
|
|
610
|
+
if (!this.consoleSettings?.allowGroupConversations) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (isAndroid) {
|
|
614
|
+
ZelloAndroidSdkModule.addUsersToGroupConversation(
|
|
615
|
+
groupConversation.name,
|
|
616
|
+
users.map((user) => user.name)
|
|
617
|
+
);
|
|
618
|
+
} else {
|
|
619
|
+
ZelloIOSSdkModule.addUsersToGroupConversation(
|
|
620
|
+
groupConversation.name,
|
|
621
|
+
users.map((user) => user.name)
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Removes the user from the group conversation.
|
|
628
|
+
* This will trigger the {@link ZelloEvent.GROUP_CONVERSATION_LEFT} and {@link ZelloEvent.CONTACT_LIST_UPDATED} events.
|
|
629
|
+
* @param groupConversation The group conversation to leave.
|
|
630
|
+
*/
|
|
631
|
+
public leaveGroupConversation(groupConversation: ZelloGroupConversation) {
|
|
632
|
+
if (!this.consoleSettings?.allowGroupConversations) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (isAndroid) {
|
|
636
|
+
ZelloAndroidSdkModule.leaveGroupConversation(groupConversation.name);
|
|
637
|
+
} else {
|
|
638
|
+
ZelloIOSSdkModule.leaveGroupConversation(groupConversation.name);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Renames the group conversation.
|
|
644
|
+
* This will trigger the {@link ZelloEvent.GROUP_CONVERSATION_RENAMED} and {@link ZelloEvent.CONTACT_LIST_UPDATED} events.
|
|
645
|
+
* @param groupConversation The group conversation to rename.
|
|
646
|
+
* @param name The new name for the group conversation.
|
|
647
|
+
*/
|
|
648
|
+
public renameGroupConversation(
|
|
649
|
+
groupConversation: ZelloGroupConversation,
|
|
650
|
+
name: string
|
|
651
|
+
) {
|
|
652
|
+
if (!this.consoleSettings?.allowGroupConversations) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (isAndroid) {
|
|
656
|
+
ZelloAndroidSdkModule.renameGroupConversation(
|
|
657
|
+
groupConversation.name,
|
|
658
|
+
name
|
|
659
|
+
);
|
|
660
|
+
} else {
|
|
661
|
+
ZelloIOSSdkModule.renameGroupConversation(groupConversation.name, name);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
526
665
|
private setupEventListener(eventEmitter: NativeEventEmitter) {
|
|
527
666
|
this.eventListener = eventEmitter.addListener('zellosdk', (event) => {
|
|
528
667
|
const eventName = event.eventName;
|
|
@@ -568,13 +707,24 @@ export class Zello extends EventEmitter {
|
|
|
568
707
|
);
|
|
569
708
|
this.channels.sort(compareNameAscending);
|
|
570
709
|
|
|
710
|
+
this.groupConversations = event.groupConversations.map(
|
|
711
|
+
(groupConversation: any) =>
|
|
712
|
+
bridgeContactToSdkContact(groupConversation)
|
|
713
|
+
);
|
|
714
|
+
this.groupConversations.sort(compareNameAscending);
|
|
715
|
+
|
|
571
716
|
if (event.emergencyChannel) {
|
|
572
717
|
this.emergencyChannel = bridgeContactToSdkContact(
|
|
573
718
|
event.emergencyChannel
|
|
574
719
|
) as ZelloChannel;
|
|
575
720
|
}
|
|
576
721
|
|
|
577
|
-
this.emit(
|
|
722
|
+
this.emit(
|
|
723
|
+
ZelloEvent.CONTACT_LIST_UPDATED,
|
|
724
|
+
this.users,
|
|
725
|
+
this.channels,
|
|
726
|
+
this.groupConversations
|
|
727
|
+
);
|
|
578
728
|
break;
|
|
579
729
|
}
|
|
580
730
|
case 'onSelectedContactChanged': {
|
|
@@ -602,7 +752,7 @@ export class Zello extends EventEmitter {
|
|
|
602
752
|
}
|
|
603
753
|
this.incomingVoiceMessage = new ZelloIncomingVoiceMessage(
|
|
604
754
|
contact,
|
|
605
|
-
|
|
755
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
606
756
|
parseInt(event.timestamp, 10)
|
|
607
757
|
);
|
|
608
758
|
this.emit(
|
|
@@ -621,7 +771,7 @@ export class Zello extends EventEmitter {
|
|
|
621
771
|
ZelloEvent.INCOMING_VOICE_MESSAGE_STOPPED,
|
|
622
772
|
new ZelloIncomingVoiceMessage(
|
|
623
773
|
contact,
|
|
624
|
-
|
|
774
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
625
775
|
parseInt(event.timestamp, 10)
|
|
626
776
|
)
|
|
627
777
|
);
|
|
@@ -694,7 +844,7 @@ export class Zello extends EventEmitter {
|
|
|
694
844
|
ZelloEvent.INCOMING_IMAGE_MESSAGE_RECEIVED,
|
|
695
845
|
new ZelloImageMessage(
|
|
696
846
|
contact,
|
|
697
|
-
|
|
847
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
698
848
|
true,
|
|
699
849
|
parseInt(event.timestamp, 10),
|
|
700
850
|
event.thumbnail,
|
|
@@ -748,7 +898,7 @@ export class Zello extends EventEmitter {
|
|
|
748
898
|
ZelloEvent.INCOMING_ALERT_MESSAGE_RECEIVED,
|
|
749
899
|
new ZelloAlertMessage(
|
|
750
900
|
contact,
|
|
751
|
-
|
|
901
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
752
902
|
true,
|
|
753
903
|
parseInt(event.timestamp, 10),
|
|
754
904
|
event.text
|
|
@@ -799,7 +949,7 @@ export class Zello extends EventEmitter {
|
|
|
799
949
|
ZelloEvent.INCOMING_TEXT_MESSAGE_RECEIVED,
|
|
800
950
|
new ZelloTextMessage(
|
|
801
951
|
contact,
|
|
802
|
-
|
|
952
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
803
953
|
true,
|
|
804
954
|
parseInt(event.timestamp, 10),
|
|
805
955
|
event.text
|
|
@@ -850,7 +1000,7 @@ export class Zello extends EventEmitter {
|
|
|
850
1000
|
ZelloEvent.INCOMING_LOCATION_MESSAGE_RECEIVED,
|
|
851
1001
|
new ZelloLocationMessage(
|
|
852
1002
|
contact,
|
|
853
|
-
|
|
1003
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
854
1004
|
true,
|
|
855
1005
|
parseInt(event.timestamp, 10),
|
|
856
1006
|
event.latitude,
|
|
@@ -979,12 +1129,9 @@ export class Zello extends EventEmitter {
|
|
|
979
1129
|
if (!contact) {
|
|
980
1130
|
return undefined;
|
|
981
1131
|
}
|
|
982
|
-
const channelUser = recent.channelUser
|
|
983
|
-
? new ZelloChannelUser(recent.channelUser)
|
|
984
|
-
: undefined;
|
|
985
1132
|
return new ZelloRecentEntry(
|
|
986
1133
|
contact,
|
|
987
|
-
channelUser,
|
|
1134
|
+
bridgeChannelUserToSdkChannelUser(event.channelUser),
|
|
988
1135
|
parseInt(recent.timestamp, 10),
|
|
989
1136
|
recent.type.toLowerCase(),
|
|
990
1137
|
recent.incoming
|
|
@@ -1018,15 +1165,135 @@ export class Zello extends EventEmitter {
|
|
|
1018
1165
|
);
|
|
1019
1166
|
break;
|
|
1020
1167
|
}
|
|
1168
|
+
case 'onConsoleSettingsChanged': {
|
|
1169
|
+
this.consoleSettings =
|
|
1170
|
+
bridgeConsoleSettingsToSdkConsoleSettings(event);
|
|
1171
|
+
this.emit(ZelloEvent.CONSOLE_SETTINGS_CHANGED, this.consoleSettings);
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
case 'onDispatchCallTransferred':
|
|
1175
|
+
case 'onDispatchCallEnded':
|
|
1176
|
+
case 'onDispatchCallActive':
|
|
1177
|
+
case 'onDispatchCallPending': {
|
|
1178
|
+
this.processDispatchCallEvent(event);
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
case 'onGroupConversationLeft': {
|
|
1182
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1183
|
+
event.conversation
|
|
1184
|
+
) as ZelloGroupConversation;
|
|
1185
|
+
if (!groupConversation) {
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
this.emit(ZelloEvent.GROUP_CONVERSATION_LEFT, groupConversation);
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
case 'onGroupConversationInvite': {
|
|
1192
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1193
|
+
event.conversation
|
|
1194
|
+
) as ZelloGroupConversation;
|
|
1195
|
+
if (!groupConversation) {
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1198
|
+
this.emit(ZelloEvent.GROUP_CONVERSATION_INVITE, groupConversation);
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
case 'onGroupConversationCreated': {
|
|
1202
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1203
|
+
event.conversation
|
|
1204
|
+
) as ZelloGroupConversation;
|
|
1205
|
+
if (!groupConversation) {
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
this.emit(ZelloEvent.GROUP_CONVERSATION_CREATED, groupConversation);
|
|
1209
|
+
break;
|
|
1210
|
+
}
|
|
1211
|
+
case 'onGroupConversationRenamed': {
|
|
1212
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1213
|
+
event.conversation
|
|
1214
|
+
) as ZelloGroupConversation;
|
|
1215
|
+
if (!groupConversation) {
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
this.emit(ZelloEvent.GROUP_CONVERSATION_RENAMED, groupConversation);
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
1221
|
+
case 'onGroupConversationUsersAdded': {
|
|
1222
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1223
|
+
event.conversation
|
|
1224
|
+
) as ZelloGroupConversation;
|
|
1225
|
+
if (!groupConversation) {
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
const users = event.users.map((user: any) =>
|
|
1229
|
+
bridgeChannelUserToSdkChannelUser(user)
|
|
1230
|
+
);
|
|
1231
|
+
if (!users || users.length === 0) {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
this.emit(
|
|
1235
|
+
ZelloEvent.GROUP_CONVERSATION_USERS_ADDED,
|
|
1236
|
+
groupConversation,
|
|
1237
|
+
users
|
|
1238
|
+
);
|
|
1239
|
+
break;
|
|
1240
|
+
}
|
|
1241
|
+
case 'onGroupConversationUsersLeft': {
|
|
1242
|
+
const groupConversation = bridgeContactToSdkContact(
|
|
1243
|
+
event.conversation
|
|
1244
|
+
) as ZelloGroupConversation;
|
|
1245
|
+
if (!groupConversation) {
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
const users = event.users.map((user: any) =>
|
|
1249
|
+
bridgeChannelUserToSdkChannelUser(user)
|
|
1250
|
+
);
|
|
1251
|
+
if (!users || users.length === 0) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
this.emit(
|
|
1255
|
+
ZelloEvent.GROUP_CONVERSATION_USERS_LEFT,
|
|
1256
|
+
groupConversation,
|
|
1257
|
+
users
|
|
1258
|
+
);
|
|
1259
|
+
break;
|
|
1260
|
+
}
|
|
1021
1261
|
default:
|
|
1022
1262
|
break;
|
|
1023
1263
|
}
|
|
1024
1264
|
});
|
|
1025
1265
|
}
|
|
1026
1266
|
|
|
1267
|
+
private processDispatchCallEvent(event: any) {
|
|
1268
|
+
const channel = bridgeContactToSdkContact(
|
|
1269
|
+
event.channel
|
|
1270
|
+
) as ZelloDispatchChannel;
|
|
1271
|
+
const call = bridgeCallToSdkCall(event.call);
|
|
1272
|
+
if (!channel || !call) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
switch (event.name) {
|
|
1276
|
+
case 'onDispatchCallTransferred':
|
|
1277
|
+
this.emit(ZelloEvent.DISPATCH_CALL_TRANSFERRED, channel, call);
|
|
1278
|
+
break;
|
|
1279
|
+
case 'onDispatchCallEnded':
|
|
1280
|
+
this.emit(ZelloEvent.DISPATCH_CALL_ENDED, channel, call);
|
|
1281
|
+
break;
|
|
1282
|
+
case 'onDispatchCallActive':
|
|
1283
|
+
this.emit(ZelloEvent.DISPATCH_CALL_ACTIVE, channel, call);
|
|
1284
|
+
break;
|
|
1285
|
+
case 'onDispatchCallPending':
|
|
1286
|
+
this.emit(ZelloEvent.DISPATCH_CALL_PENDING, channel, call);
|
|
1287
|
+
break;
|
|
1288
|
+
default:
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1027
1293
|
private clearContactList() {
|
|
1028
1294
|
this.users = [];
|
|
1029
1295
|
this.channels = [];
|
|
1296
|
+
this.groupConversations = [];
|
|
1030
1297
|
}
|
|
1031
1298
|
|
|
1032
1299
|
private static getSdk() {
|
package/src/types/index.ts
CHANGED
|
@@ -26,6 +26,8 @@ export type ZelloContact = {
|
|
|
26
26
|
export enum ZelloContactType {
|
|
27
27
|
User = 'user',
|
|
28
28
|
Channel = 'channel',
|
|
29
|
+
DispatchChannel = 'dispatchChannel',
|
|
30
|
+
GroupConversation = 'groupConversation',
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -73,6 +75,10 @@ export class ZelloUser implements ZelloContact {
|
|
|
73
75
|
* This can be used for displaying a smaller version of the profile picture (such as in a list).
|
|
74
76
|
*/
|
|
75
77
|
public profilePictureThumbnailUrl: string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The supported features of the user.
|
|
80
|
+
*/
|
|
81
|
+
public supportedFeatures: ZelloUserSupportedFeatures;
|
|
76
82
|
|
|
77
83
|
constructor(
|
|
78
84
|
name: string,
|
|
@@ -80,7 +86,8 @@ export class ZelloUser implements ZelloContact {
|
|
|
80
86
|
isMuted: boolean,
|
|
81
87
|
status: ZelloUserStatus,
|
|
82
88
|
profilePictureUrl: string | undefined,
|
|
83
|
-
profilePictureThumbnailUrl: string | undefined
|
|
89
|
+
profilePictureThumbnailUrl: string | undefined,
|
|
90
|
+
supportedFeatures: ZelloUserSupportedFeatures
|
|
84
91
|
) {
|
|
85
92
|
this.name = name;
|
|
86
93
|
this.type = ZelloContactType.User;
|
|
@@ -89,6 +96,21 @@ export class ZelloUser implements ZelloContact {
|
|
|
89
96
|
this.status = status;
|
|
90
97
|
this.profilePictureUrl = profilePictureUrl;
|
|
91
98
|
this.profilePictureThumbnailUrl = profilePictureThumbnailUrl;
|
|
99
|
+
this.supportedFeatures = supportedFeatures;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The supported features of a {@link ZelloUser}.
|
|
105
|
+
*/
|
|
106
|
+
export class ZelloUserSupportedFeatures {
|
|
107
|
+
/**
|
|
108
|
+
* Whether the user supports group conversations.
|
|
109
|
+
*/
|
|
110
|
+
public readonly groupConversations: boolean;
|
|
111
|
+
|
|
112
|
+
constructor(groupConversations: boolean) {
|
|
113
|
+
this.groupConversations = groupConversations;
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
116
|
|
|
@@ -128,6 +150,95 @@ export class ZelloChannel implements ZelloContact {
|
|
|
128
150
|
}
|
|
129
151
|
}
|
|
130
152
|
|
|
153
|
+
/**
|
|
154
|
+
* A Zello dispatch channel. A dispatch channel is a special type of channel that has calls between a user and a dispatcher.
|
|
155
|
+
*/
|
|
156
|
+
export class ZelloDispatchChannel extends ZelloChannel {
|
|
157
|
+
/**
|
|
158
|
+
* The current call on the dispatch channel, if any.
|
|
159
|
+
*/
|
|
160
|
+
public readonly currentCall: ZelloDispatchCall | undefined;
|
|
161
|
+
|
|
162
|
+
constructor(
|
|
163
|
+
name: string,
|
|
164
|
+
isMuted: boolean,
|
|
165
|
+
connectionStatus: ZelloChannelConnectionStatus,
|
|
166
|
+
usersOnline: number,
|
|
167
|
+
options: ZelloChannelOptions,
|
|
168
|
+
currentCall: ZelloDispatchCall | undefined
|
|
169
|
+
) {
|
|
170
|
+
super(name, isMuted, connectionStatus, usersOnline, options);
|
|
171
|
+
this.type = ZelloContactType.DispatchChannel;
|
|
172
|
+
this.currentCall = currentCall;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A Zello dispatch call. A dispatch call is a call between a user and a dispatcher.
|
|
178
|
+
*/
|
|
179
|
+
export class ZelloDispatchCall {
|
|
180
|
+
/**
|
|
181
|
+
* The status of the call.
|
|
182
|
+
*/
|
|
183
|
+
public readonly status: ZelloDispatchCallStatus;
|
|
184
|
+
/**
|
|
185
|
+
* The name of the dispatcher who accepted the call. Null if the call is in the {@link ZelloDispatchCallStatus.Pending} state.
|
|
186
|
+
*/
|
|
187
|
+
public readonly dispatcher: string | undefined;
|
|
188
|
+
|
|
189
|
+
constructor(status: ZelloDispatchCallStatus, dispatcher: string | undefined) {
|
|
190
|
+
this.status = status;
|
|
191
|
+
this.dispatcher = dispatcher;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The status of a {@link ZelloDispatchCall}.
|
|
197
|
+
*/
|
|
198
|
+
export enum ZelloDispatchCallStatus {
|
|
199
|
+
Pending = 'pending',
|
|
200
|
+
Active = 'active',
|
|
201
|
+
Ended = 'ended',
|
|
202
|
+
Disconnected = 'disconnected',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A ad-hoc group conversation in Zello. A {@link ZelloGroupConversation} is a type of {@link ZelloChannel}, but the provisioning is done by the end user instead of through the Zello Work Administrative Console.
|
|
207
|
+
*
|
|
208
|
+
* {@link ZelloGroupConversation}s are only possible when {@link ZelloConsoleSettings.allowGroupConversations} is true.
|
|
209
|
+
*/
|
|
210
|
+
export class ZelloGroupConversation extends ZelloChannel {
|
|
211
|
+
/**
|
|
212
|
+
* The display name of the group conversation. This should be used in the UI instead of {@link ZelloChannel#name}, as the {@link ZelloChannel#name} will be a uniquely hashed value starting with c##.
|
|
213
|
+
*/
|
|
214
|
+
public readonly displayName: string;
|
|
215
|
+
/**
|
|
216
|
+
* The users in the group conversation.
|
|
217
|
+
*/
|
|
218
|
+
public readonly users: ZelloChannelUser[];
|
|
219
|
+
/**
|
|
220
|
+
* The users in the group conversation that are currently online.
|
|
221
|
+
*/
|
|
222
|
+
public readonly onlineUsers: ZelloChannelUser[];
|
|
223
|
+
|
|
224
|
+
constructor(
|
|
225
|
+
name: string,
|
|
226
|
+
isMuted: boolean,
|
|
227
|
+
connectionStatus: ZelloChannelConnectionStatus,
|
|
228
|
+
usersOnline: number,
|
|
229
|
+
options: ZelloChannelOptions,
|
|
230
|
+
displayName: string,
|
|
231
|
+
users: ZelloChannelUser[],
|
|
232
|
+
onlineUsers: ZelloChannelUser[]
|
|
233
|
+
) {
|
|
234
|
+
super(name, isMuted, connectionStatus, usersOnline, options);
|
|
235
|
+
this.type = ZelloContactType.GroupConversation;
|
|
236
|
+
this.displayName = displayName;
|
|
237
|
+
this.users = users;
|
|
238
|
+
this.onlineUsers = onlineUsers;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
131
242
|
/**
|
|
132
243
|
* The connection status of a {@link ZelloChannel}.
|
|
133
244
|
*/
|
|
@@ -160,7 +271,7 @@ export type ZelloChannelOptions = {
|
|
|
160
271
|
* Whether the user is allowed to send alert messages to the channel.
|
|
161
272
|
* When this is true, you should not show any UI to allow the user to send alert messages to the channel.
|
|
162
273
|
*/
|
|
163
|
-
|
|
274
|
+
allowAlertMessages: boolean;
|
|
164
275
|
/**
|
|
165
276
|
* Whether the user is allowed to send text messages to the channel.
|
|
166
277
|
* When this is true, you should not show any UI to allow the user to send text messages to the channel.
|
|
@@ -170,17 +281,19 @@ export type ZelloChannelOptions = {
|
|
|
170
281
|
* Whether the user is allowed to send location messages to the channel.
|
|
171
282
|
* When this is true, you should not show any UI to allow the user to send location messages to the channel.
|
|
172
283
|
*/
|
|
173
|
-
|
|
284
|
+
allowLocationMessages: boolean;
|
|
174
285
|
};
|
|
175
286
|
|
|
176
287
|
/**
|
|
177
|
-
* A user in a {@link ZelloChannel}. A {@link ZelloChannelUser} may or may not
|
|
288
|
+
* A user in a {@link ZelloChannel}. A {@link ZelloChannelUser} may or may not be part of your contact list.
|
|
178
289
|
*/
|
|
179
290
|
export class ZelloChannelUser {
|
|
180
291
|
public name: string;
|
|
292
|
+
public displayName: string;
|
|
181
293
|
|
|
182
|
-
constructor(name: string) {
|
|
294
|
+
constructor(name: string, displayName: string) {
|
|
183
295
|
this.name = name;
|
|
296
|
+
this.displayName = displayName;
|
|
184
297
|
}
|
|
185
298
|
}
|
|
186
299
|
|
|
@@ -814,5 +927,39 @@ export type ZelloConfig = {
|
|
|
814
927
|
* Whether your application is being run in a debug or release build.
|
|
815
928
|
*/
|
|
816
929
|
isDebugBuild: boolean;
|
|
930
|
+
/**
|
|
931
|
+
* The app group for shared data. This is required for the Notification Service Extension to work properly.
|
|
932
|
+
*/
|
|
933
|
+
appGroup: string;
|
|
817
934
|
};
|
|
818
935
|
};
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Settings for the network. These are configured via the Zello Work Administrative Console.
|
|
939
|
+
*/
|
|
940
|
+
export type ZelloConsoleSettings = {
|
|
941
|
+
/**
|
|
942
|
+
* Allow non-dispatchers to end calls. When this is false, you should not show any UI to allow non-dispatchers to end calls.
|
|
943
|
+
*/
|
|
944
|
+
allowNonDispatchersToEndCalls: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Allow image messages. When this is false, you should not show any UI to allow users to send image messages.
|
|
947
|
+
*/
|
|
948
|
+
allowImageMessages: boolean;
|
|
949
|
+
/**
|
|
950
|
+
* Allow alert messages. When this is false, you should not show any UI to allow users to send alert messages.
|
|
951
|
+
*/
|
|
952
|
+
allowAlertMessages: boolean;
|
|
953
|
+
/**
|
|
954
|
+
* Allow location messages. When this is false, you should not show any UI to allow users to send location messages.
|
|
955
|
+
*/
|
|
956
|
+
allowLocationMessages: boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Allow text messages. When this is false, you should not show any UI to allow users to send text messages.
|
|
959
|
+
*/
|
|
960
|
+
allowTextMessages: boolean;
|
|
961
|
+
/**
|
|
962
|
+
* Allow group conversations. When this is false, you should not show any UI to allow users to create group conversations.
|
|
963
|
+
*/
|
|
964
|
+
allowGroupConversations: boolean;
|
|
965
|
+
};
|