react-native-altibbi 0.1.0 → 0.1.2

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 (95) hide show
  1. package/README.md +220 -60
  2. package/package.json +2 -3
  3. package/src/connection.ts +160 -64
  4. package/src/data.ts +7 -1
  5. package/src/index.tsx +27 -6
  6. package/src/service.ts +7 -8
  7. package/src/types.ts +178 -15
  8. package/lib/commonjs/connection.js +0 -200
  9. package/lib/commonjs/connection.js.map +0 -1
  10. package/lib/commonjs/data.js +0 -12
  11. package/lib/commonjs/data.js.map +0 -1
  12. package/lib/commonjs/index.js +0 -275
  13. package/lib/commonjs/index.js.map +0 -1
  14. package/lib/commonjs/scoket.js +0 -245
  15. package/lib/commonjs/scoket.js.map +0 -1
  16. package/lib/commonjs/service.js +0 -21
  17. package/lib/commonjs/service.js.map +0 -1
  18. package/lib/commonjs/types.js +0 -2
  19. package/lib/commonjs/types.js.map +0 -1
  20. package/lib/commonjs/video/OT.js +0 -57
  21. package/lib/commonjs/video/OT.js.map +0 -1
  22. package/lib/commonjs/video/OTError.js +0 -17
  23. package/lib/commonjs/video/OTError.js.map +0 -1
  24. package/lib/commonjs/video/OTPublisher.js +0 -171
  25. package/lib/commonjs/video/OTPublisher.js.map +0 -1
  26. package/lib/commonjs/video/OTSession.js +0 -205
  27. package/lib/commonjs/video/OTSession.js.map +0 -1
  28. package/lib/commonjs/video/OTSubscriber.js +0 -185
  29. package/lib/commonjs/video/OTSubscriber.js.map +0 -1
  30. package/lib/commonjs/video/contexts/OTContext.js +0 -11
  31. package/lib/commonjs/video/contexts/OTContext.js.map +0 -1
  32. package/lib/commonjs/video/helpers/OTHelper.js +0 -92
  33. package/lib/commonjs/video/helpers/OTHelper.js.map +0 -1
  34. package/lib/commonjs/video/helpers/OTPublisherHelper.js +0 -117
  35. package/lib/commonjs/video/helpers/OTPublisherHelper.js.map +0 -1
  36. package/lib/commonjs/video/helpers/OTSessionHelper.js +0 -206
  37. package/lib/commonjs/video/helpers/OTSessionHelper.js.map +0 -1
  38. package/lib/commonjs/video/helpers/OTSubscriberHelper.js +0 -121
  39. package/lib/commonjs/video/helpers/OTSubscriberHelper.js.map +0 -1
  40. package/lib/commonjs/video/index.js +0 -42
  41. package/lib/commonjs/video/index.js.map +0 -1
  42. package/lib/commonjs/video/views/OTPublisherView.js +0 -26
  43. package/lib/commonjs/video/views/OTPublisherView.js.map +0 -1
  44. package/lib/commonjs/video/views/OTSubscriberView.js +0 -25
  45. package/lib/commonjs/video/views/OTSubscriberView.js.map +0 -1
  46. package/lib/module/connection.js +0 -180
  47. package/lib/module/connection.js.map +0 -1
  48. package/lib/module/data.js +0 -6
  49. package/lib/module/data.js.map +0 -1
  50. package/lib/module/index.js +0 -12
  51. package/lib/module/index.js.map +0 -1
  52. package/lib/module/scoket.js +0 -235
  53. package/lib/module/scoket.js.map +0 -1
  54. package/lib/module/service.js +0 -14
  55. package/lib/module/service.js.map +0 -1
  56. package/lib/module/types.js +0 -2
  57. package/lib/module/types.js.map +0 -1
  58. package/lib/module/video/OT.js +0 -49
  59. package/lib/module/video/OT.js.map +0 -1
  60. package/lib/module/video/OTError.js +0 -10
  61. package/lib/module/video/OTError.js.map +0 -1
  62. package/lib/module/video/OTPublisher.js +0 -162
  63. package/lib/module/video/OTPublisher.js.map +0 -1
  64. package/lib/module/video/OTSession.js +0 -195
  65. package/lib/module/video/OTSession.js.map +0 -1
  66. package/lib/module/video/OTSubscriber.js +0 -175
  67. package/lib/module/video/OTSubscriber.js.map +0 -1
  68. package/lib/module/video/contexts/OTContext.js +0 -4
  69. package/lib/module/video/contexts/OTContext.js.map +0 -1
  70. package/lib/module/video/helpers/OTHelper.js +0 -82
  71. package/lib/module/video/helpers/OTHelper.js.map +0 -1
  72. package/lib/module/video/helpers/OTPublisherHelper.js +0 -110
  73. package/lib/module/video/helpers/OTPublisherHelper.js.map +0 -1
  74. package/lib/module/video/helpers/OTSessionHelper.js +0 -195
  75. package/lib/module/video/helpers/OTSessionHelper.js.map +0 -1
  76. package/lib/module/video/helpers/OTSubscriberHelper.js +0 -112
  77. package/lib/module/video/helpers/OTSubscriberHelper.js.map +0 -1
  78. package/lib/module/video/index.js +0 -7
  79. package/lib/module/video/index.js.map +0 -1
  80. package/lib/module/video/views/OTPublisherView.js +0 -18
  81. package/lib/module/video/views/OTPublisherView.js.map +0 -1
  82. package/lib/module/video/views/OTSubscriberView.js +0 -17
  83. package/lib/module/video/views/OTSubscriberView.js.map +0 -1
  84. package/lib/typescript/src/connection.d.ts +0 -40
  85. package/lib/typescript/src/connection.d.ts.map +0 -1
  86. package/lib/typescript/src/data.d.ts +0 -7
  87. package/lib/typescript/src/data.d.ts.map +0 -1
  88. package/lib/typescript/src/index.d.ts +0 -12
  89. package/lib/typescript/src/index.d.ts.map +0 -1
  90. package/lib/typescript/src/scoket.d.ts +0 -100
  91. package/lib/typescript/src/scoket.d.ts.map +0 -1
  92. package/lib/typescript/src/service.d.ts +0 -9
  93. package/lib/typescript/src/service.d.ts.map +0 -1
  94. package/lib/typescript/src/types.d.ts +0 -22
  95. package/lib/typescript/src/types.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,36 +1,52 @@
1
- This Flutter SDK provides integration for the Altibbi services, including video consultation, text consultation, push
2
- notification, and many other features. This guide will walk you through the steps to integrate it into your Flutter
1
+ This React native SDK provides integration for the Altibbi services, including video consultation, text consultation, push
2
+ Welcome to the React Native SDK for Altibbi services, your comprehensive solution for integrating health consultation services into your React Native applications. This SDK enables video and text consultations, push notifications, and many other features to provide a seamless healthcare experience.
3
3
  project.
4
4
 
5
+
6
+ ## Features
7
+ - **Video and VOIP Consultation:** Facilitate live video and VOIP sessions between patients and healthcare professionals.
8
+ - **GSM Consultation:** Facilitate GSM(Phone calls) sessions between patients and healthcare professionals.
9
+ - **Text Consultation:** Offer real-time text messaging for healthcare inquiries.
10
+ - **User Management:** Easily manage user information with our comprehensive API.
11
+ - **Real-time Notifications:** Keep users updated with push notifications and server to server real time callbacks.
12
+
13
+ ## Prerequisites
14
+ - React Native 0.60 or higher
15
+ - Node.js 16 or higher
16
+
5
17
  ## Installation
18
+ Install the SDK with npm:
6
19
 
7
20
  ```sh
8
21
  npm install react-native-altibbi
9
22
  ```
23
+ Or with yarn:
10
24
 
11
25
  ```sh
12
26
  yarn add react-native-altibbi
13
27
  ```
14
28
 
15
- ## Usage
16
29
 
17
- ### initlizetion
30
+ ## Initialization
31
+ Initialize the Altibbi SDK with the following parameters:
32
+ - **PARTNER_ENDPOINT:** Your partner endpoint (will be shared with you upon request).
33
+ - **token:** Authentication token from your backend.
34
+ - **language:** Preferred language for responses either Arabic (default) or English.
18
35
 
19
- Initialize the Altibbi service with the user token and partner endpoint as follows:
20
- Note: Be sure to replace placeholders "USER_TOKEN" and "PARTNER_ENDPOINT" with your actual values.
21
- language refer for the response language
22
-
23
- #### import init function to initialize Altibbi service
24
36
 
25
37
  ```js
26
38
  import { init } from 'react-native-altibbi';
27
- ```
28
39
 
29
- ```js
30
- init('PARTNER_ENDPOINT', 'LANGUAGE', 'USER_TOKEN');
40
+ init('TOKEN', 'PARTNER_ENDPOINT', 'LANGUAGE');
31
41
  ```
32
42
 
33
- note that the USER_TOKEN should be retrieved from your backend
43
+
44
+ ## Detailed Usage
45
+
46
+
47
+ ### User API
48
+ Manage users with functions like `createUser`, `updateUser`,`getUser`, `getUsers`, and `deleteUser`. Below are examples of how to use these functions:
49
+
34
50
 
35
51
  ### USER API
36
52
 
@@ -42,63 +58,60 @@ note that the USER_TOKEN should be retrieved from your backend
42
58
  | updateUser | userId |
43
59
  | deleteUser | userId |
44
60
 
45
- #### getUser
46
61
 
47
- ```js
48
- import { getUser } from 'react-native-altibbi';
49
- ```
62
+ #### createUser Example
50
63
 
51
64
  ```js
52
- const response = await getUser(user_id)
53
- ```
54
-
55
- #### getUsers
65
+ import { createUser } from 'react-native-altibbi';
56
66
 
57
- ```js
58
- import { getUsers } from 'react-native-altibbi';
67
+ const params = {
68
+ name: "Altibbi",
69
+ }
70
+ const response = await createUser(params)
59
71
  ```
60
72
 
61
- ```js
62
- const response = await getUsers(page, per_page)
63
- ```
64
73
 
65
- #### createUser
74
+ #### updateUser Example
66
75
 
67
76
  ```js
68
- import { createUser } from 'react-native-altibbi';
69
- ```
77
+ import { updateUser } from 'react-native-altibbi';
70
78
 
71
- ```js
72
79
  const params = {
73
80
  name: "Altibbi",
74
81
  }
75
- const response = await createUser(params)
82
+ const response = await updateUser(params)
76
83
  ```
77
84
 
78
- #### updateUser
79
85
 
86
+ #### getUser Example
80
87
  ```js
81
- import { updateUser } from 'react-native-altibbi';
88
+ import { getUser } from 'react-native-altibbi';
89
+
90
+ const response = await getUser(user_id)
82
91
  ```
83
92
 
93
+
94
+ #### getUsers Example
95
+
84
96
  ```js
85
- const params = {
86
- name: "Altibbi",
87
- }
88
- const response = await updateUser(params)
97
+ import { getUsers } from 'react-native-altibbi';
98
+ const response = await getUsers(page, per_page)
89
99
  ```
90
100
 
91
101
  #### deleteUser
92
102
 
93
103
  ```js
94
104
  import { deleteUser } from 'react-native-altibbi';
95
- ```
96
105
 
97
- ```js
98
106
  const response = await updateUser(user_id)
99
107
  ```
100
108
 
109
+
110
+
111
+
101
112
  ### Consultation API
113
+ Create and manage consultations using our suite of functions:
114
+
102
115
 
103
116
  | APi | params |
104
117
  |---------------------|--------------------------------------------------------------------------------------|
@@ -113,9 +126,7 @@ const response = await updateUser(user_id)
113
126
 
114
127
  ```js
115
128
  import { createConsultation } from 'react-native-altibbi';
116
- ```
117
129
 
118
- ```js
119
130
  const params = {
120
131
  question,
121
132
  medium,
@@ -128,63 +139,212 @@ const response = await createConsultation(params)
128
139
 
129
140
  ```js
130
141
  import { getConsultationInfo } from 'react-native-altibbi';
142
+
143
+ const response = await getConsultationInfo(consultation_id)
131
144
  ```
132
145
 
146
+ #### getConsultationList
147
+
133
148
  ```js
134
- const response = await getConsultationInfo(consultation_id)
149
+ import { getConsultationList } from 'react-native-altibbi';
150
+
151
+ const response = await getConsultationList(user_id, page, per_page)
135
152
  ```
136
153
 
137
- #### deleteUser
154
+ #### deleteConsultation
138
155
 
139
156
  ```js
140
- import { getLastConsultation } from 'react-native-altibbi';
157
+ import { deleteConsultation } from 'react-native-altibbi';
158
+
159
+ const response = await deleteConsultation(consultation_id)
141
160
  ```
142
161
 
162
+ #### cancelConsultation
163
+
143
164
  ```js
144
- const response = await getLastConsultation()
165
+ import { cancelConsultation } from 'react-native-altibbi';
166
+
167
+ const response = await cancelConsultation(consultation_id)
145
168
  ```
146
169
 
147
- #### getConsultationList
170
+ ### TBISocket :
171
+
172
+ #### After creating the consultation you can use TBISocket to listen to consultation status events
173
+
148
174
 
149
175
  ```js
150
- import { getConsultationList } from 'react-native-altibbi';
176
+ import { TBISocket } from 'react-native-altibbi';
151
177
  ```
152
178
 
153
179
  ```js
154
- const response = await getConsultationList(user_id, page, per_page)
180
+ const instance = TBISocket.getInstance();
155
181
  ```
156
182
 
157
- #### deleteConsultation
183
+ #### connect && subscribe to listen to event
158
184
 
159
185
  ```js
160
- import { deleteConsultation } from 'react-native-altibbi';
186
+ await instance.init({...socketParams,// socketParams retrived from consultation Object in SDK
187
+ ...{
188
+ onConnectionStateChange,
189
+ onError,
190
+ onEvent,
191
+ onSubscriptionSucceeded,
192
+ onSubscriptionError,
193
+ onDecryptionFailure,
194
+ onMemberAdded,
195
+ onMemberRemoved,
196
+ onSubscriptionCount,
197
+ }});
198
+ await instance.subscribe({ channelName: CHANNEL_NAME });
199
+ await instance.connect();
161
200
  ```
162
201
 
202
+ ### Video Consultation
203
+
204
+ #### import video components
205
+
163
206
  ```js
164
- const response = await deleteConsultation(consultation_id)
207
+ import {
208
+ TBIPublisher,
209
+ TBISession,
210
+ TBISubscriber,
211
+ TBISubscriberView,
212
+ } from 'react-native-altibbi';
165
213
  ```
166
214
 
167
- #### cancelConsultation
215
+ ```js
216
+ <TBISession
217
+ options={{
218
+ androidZOrder: 'onTop',
219
+ androidOnTop: 'publisher',
220
+ }}
221
+ ref={(ref) => (sessionRef.current = ref)}
222
+ apiKey={API_KEY} //retrived from consultation Object in SDK
223
+ sessionId={CALL_ID}//retrived from consultation Object in SDK
224
+ token={TOKEN}//retrived from consultation Object in SDK
225
+ eventHandlers={{
226
+ streamDestroyed: (event) => {
227
+ },
228
+ error: (event) => {
229
+ },
230
+ otrnError: (event) => {
231
+ },
232
+ }}
233
+ >
234
+ <TBISubscriber
235
+ eventHandlers={{
236
+ error: (event) => {
237
+ },
238
+ otrnError: (event) => {
239
+ },
240
+ }}
241
+ >
242
+ {renderSubscribers}
243
+ </TBISubscriber>
244
+ <TBIPublisher
245
+ properties={{
246
+ cameraPosition: 'front',
247
+ publishVideo: true, // set to false in voip consultation
248
+ publishAudio: true,
249
+ enableDtx: true,
250
+ }}
251
+ eventHandlers={{
252
+ streamDestroyed: (event) => {
253
+ },
254
+ error: (event) => {
255
+ },
256
+ otrnError: (event) => {
257
+ },
258
+ }}
259
+ />
260
+ </TBISession>
261
+ ```
262
+
263
+ ### Chat Consultation
264
+
265
+ #### import the components
168
266
 
169
267
  ```js
170
- import { cancelConsultation } from 'react-native-altibbi';
268
+ import {
269
+ AltibbiChat,
270
+ } from 'react-native-altibbi';
171
271
  ```
172
272
 
173
273
  ```js
174
- const response = await cancelConsultation(consultation_id)
274
+ const ref = useRef(null);
275
+
276
+ const init = () => {
277
+ AltibbiChat.init({
278
+ appId: APP_ID,
279
+ modules: [new GroupChannelModule()],
280
+ });
281
+ };
282
+
283
+ const connect = async () => {
284
+ await ref?.current?.connect(data.chat_user_id, data.chat_user_token);
285
+ };
286
+
287
+ const addHandler = () => {
288
+ let groupChannelHandler = new GroupChannelHandler({
289
+ onUserJoined,
290
+ onUserLeft,
291
+ onTypingStatusUpdated,
292
+ onMessageReceived,
293
+ });
294
+
295
+ let connectionHandler = new ConnectionHandler({
296
+ onConnected,
297
+ onReconnectStarted,
298
+ onReconnectSucceeded,
299
+ onReconnectFailed,
300
+ onDisconnected,
301
+ });
302
+ ref?.current?.groupChannel?.addGroupChannelHandler(
303
+ 'CHA_HAN',
304
+ groupChannelHandler
305
+ );
306
+ ref?.current?.addConnectionHandler('CHA_CONN', connectionHandler);
307
+ };
308
+
309
+ const loadAllMessage = async (channelURL) => {
310
+ const channel = await getChannel(channelURL);
311
+ const previousMessageList = await channel.createPreviousMessageListQuery();
312
+ let allMessages = [];
313
+
314
+ while (previousMessageList.hasNext) {
315
+ let newMsgArr = await previousMessageList.load();
316
+ allMessages = [...allMessages, ...newMsgArr];
317
+ }
318
+ return allMessages;
319
+ };
320
+
175
321
  ```
176
322
 
177
- ## Support
323
+ ```js
324
+ useEffect(() => {
325
+ const chatStart = async () => {
326
+ init();
327
+ addHandler();
328
+ connect().then(() => {
329
+ loadAllMessage(`channel_${data.group_id}`).then((res) => {
330
+ setMessageList(res);
331
+ setLoading(false);
332
+ });
333
+ });
334
+ };
335
+ chatStart();
336
+ }, []);
337
+ ```
178
338
 
179
- If you need support you can contact: [mobile@altibbi.com](mobile@altibbi.com). Please
180
- ensure that you are referencing the latest version of our SDK to access all available features and improvements.
181
339
 
182
- ## Contributing
340
+ ## Support
341
+
342
+ For support, contact: [mobile@altibbi.com](mobile@altibbi.com). Please
343
+ ensure that you are referencing the latest version of the SDK to access all available features and improvements.
183
344
 
184
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
185
345
 
186
346
  ## License
187
347
 
188
- MIT
348
+ This project is licensed under the MIT License.
189
349
 
190
350
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-altibbi",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Altibbi Sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -31,7 +31,6 @@
31
31
  "typecheck": "tsc --noEmit",
32
32
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
33
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib"
34
-
35
34
  },
36
35
  "keywords": [
37
36
  "react-native",
@@ -155,7 +154,7 @@
155
154
  "dependencies": {
156
155
  "@sendbird/chat": "4.10.3",
157
156
  "axios": "1.6.2",
158
- "deprecated-react-native-prop-types": "5.0.0",
157
+ "deprecated-react-native-prop-types": "2.3.0",
159
158
  "flow-bin": "0.223.3",
160
159
  "prop-types": "15.8.1",
161
160
  "underscore": "1.13.6",