Skip to content

Commit 11e67fe

Browse files
feat: add the ability to hide the Visitor Code alert
MOB-4818
1 parent 9a16ca0 commit 11e67fe

File tree

15 files changed

+86
-16
lines changed

15 files changed

+86
-16
lines changed

android/src/main/java/com/glia/widgets/ionic/GliaSdk.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,20 @@ public void presentEntryWidget(PluginCall call, Activity activity) {
133133
}
134134

135135
public void showEntryWidget(PluginCall call, Activity activity) {
136-
JSArray queueIds = call.getArray("queueIds", new JSArray());
137-
entryWidget = GliaWidgets.getEntryWidget(jsArrayToArrayList(queueIds));
138-
entryWidget.show(activity);
139-
call.resolve();
136+
try {
137+
JSArray queueIds = call.getArray("queueIds", new JSArray());
138+
entryWidget = GliaWidgets.getEntryWidget(jsArrayToArrayList(queueIds));
139+
entryWidget.show(activity);
140+
call.resolve();
141+
} catch (Exception e) {
142+
call.reject("Could not show entry widget. Error='" + e.getMessage() + "'");
143+
}
140144
}
141145

142146
public void hideEntryWidget(PluginCall call) {
143-
entryWidget.hide();
147+
if (entryWidget != null) {
148+
entryWidget.hide();
149+
}
144150
call.resolve();
145151
}
146152

@@ -297,8 +303,21 @@ public void getQueues(PluginCall call) {
297303
}
298304

299305
public void showVisitorCode(PluginCall call) {
300-
GliaWidgets.getCallVisualizer().showVisitorCodeDialog();
301-
call.resolve();
306+
try {
307+
GliaWidgets.getCallVisualizer().showVisitorCodeDialog();
308+
call.resolve();
309+
} catch (Exception e) {
310+
call.reject("Could not show visitor code. Error='" + e.getMessage() + "'");
311+
}
312+
}
313+
314+
public void hideVisitorCode(PluginCall call) {
315+
try {
316+
GliaWidgets.getCallVisualizer().hideVisitorCodeDialog();
317+
call.resolve();
318+
} catch (Exception e) {
319+
call.reject("Could not hide visitor code. Error='" + e.getMessage() + "'");
320+
}
302321
}
303322

304323
public void authenticate(PluginCall call) {

android/src/main/java/com/glia/widgets/ionic/GliaSdkPlugin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public void showVisitorCode(PluginCall call) {
9494
implementation.showVisitorCode(call);
9595
}
9696

97+
@PluginMethod
98+
public void hideVisitorCode(PluginCall call) {
99+
implementation.hideVisitorCode(call);
100+
}
101+
97102
@PluginMethod
98103
public void authenticate(PluginCall call) {
99104
implementation.authenticate(call);

dist/docs.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
"tags": [
217217
{
218218
"name": "deprecated",
219-
"text": "Use showVisitorCode() instead.\nPresents GliaWidgets UI with a visitor code for sharing with operator to start an engagement."
219+
"text": "Use showVisitorCode() instead.\nPresents a GliaWidgets alert with a visitor code to share with an operator to start an engagement."
220220
}
221221
],
222222
"docs": "",
@@ -229,10 +229,20 @@
229229
"parameters": [],
230230
"returns": "Promise<void>",
231231
"tags": [],
232-
"docs": "Presents GliaWidgets UI with a visitor code for sharing with operator to start an engagement.",
232+
"docs": "Presents a GliaWidgets alert with a visitor code to share with an operator to start an engagement.",
233233
"complexTypes": [],
234234
"slug": "showvisitorcode"
235235
},
236+
{
237+
"name": "hideVisitorCode",
238+
"signature": "() => Promise<void>",
239+
"parameters": [],
240+
"returns": "Promise<void>",
241+
"tags": [],
242+
"docs": "Closes a GliaWidgets alert with a visitor code if it is currently visible.",
243+
"complexTypes": [],
244+
"slug": "hidevisitorcode"
245+
},
236246
{
237247
"name": "authenticate",
238248
"signature": "(options: { behavior: AuthenticationBehavior; idToken: string; accessToken?: string; }) => Promise<void>",

dist/esm/definitions.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,17 @@ export interface GliaSdk {
408408
getQueues(): Promise<Queues>;
409409
/**
410410
* @deprecated Use showVisitorCode() instead.
411-
* Presents GliaWidgets UI with a visitor code for sharing with operator to start an engagement.
411+
* Presents a GliaWidgets alert with a visitor code to share with an operator to start an engagement.
412412
*/
413413
showVisitorCodeViewController(): Promise<void>;
414414
/**
415-
* Presents GliaWidgets UI with a visitor code for sharing with operator to start an engagement.
415+
* Presents a GliaWidgets alert with a visitor code to share with an operator to start an engagement.
416416
*/
417417
showVisitorCode(): Promise<void>;
418+
/**
419+
* Closes a GliaWidgets alert with a visitor code if it is currently visible.
420+
*/
421+
hideVisitorCode(): Promise<void>;
418422
/**
419423
* Authenticates the visitor.
420424
* @param options - Provides options for authentication such as behavior, idToken, and accessToken.

dist/esm/definitions.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.cjs.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example-app/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ <h3>Start Engagement (new methods)</h3>
7070
<p>
7171
<h3>Visitor Code</h3>
7272
<button onclick="showVisitorCodeViewController()">Show Visitor Code</button>
73+
<button onclick="hideVisitorCode()">Hide Visitor Code</button>
7374
</p>
7475
<p>
7576
<button onclick="endEngagement()">End Engagement</button>

0 commit comments

Comments
 (0)