-
- All Implemented Interfaces:
-
com.glia.androidsdk.Engagement
public class CommonEngagement implements Engagement
Contains common Engagement functionality that is shared between OmniCore and OmniBrowse Engagements.
-
-
Constructor Summary
Constructors Constructor Description CommonEngagement(InternalEngagement engagement, GliaEnvironment env, ApiDeps apiDeps)
-
Method Summary
Modifier and Type Method Description OperatorgetOperator()voidonActivityResult(int requestCode, int resultCode, Intent intent)Accepts activity results. ChatgetChat()MediagetMedia()StringgetId()Engagement.VisitorStategetVisitorStatus()voiduploadFile(File file, RequestCallback<EngagementFile> callback)Uploads a file to the engagement. voiduploadFile(Uri fileUri, RequestCallback<EngagementFile> callback)See uploadFile voidfetchFile(String fileId, RequestCallback<InputStream> callback)voidend(Consumer<GliaException> onResult)Ends the Engagement. voidgetSurvey(@NonNull() RequestCallback<Survey> callback)Fetch the survey for the engagement. <T> voidon(@NonNull() Engagement.EngagementEvent<T> event, @NonNull() Consumer<T> listener)Registers event listeners for . voidon(@NonNull() Engagement.EngagementEvent<out Object> event, @NonNull() Runnable listener)Registers event listeners for . <T> voidoff(@NonNull() Engagement.EngagementEvent<T> event, @NonNull() Consumer<T> listener)Removes event listeners from the . voidoff(@NonNull() Engagement.EngagementEvent<out Object> event, @NonNull() Runnable listener)Removes event listeners from the . -
-
Constructor Detail
-
CommonEngagement
CommonEngagement(InternalEngagement engagement, GliaEnvironment env, ApiDeps apiDeps)
-
-
Method Detail
-
getOperator
Operator getOperator()
-
onActivityResult
void onActivityResult(int requestCode, int resultCode, Intent intent)
Accepts activity results.
Some functionality, for example , requires to triggerpermission prompts via *Activity#startActivityForResult(Intent, int).The results of this prompt is passed to your activity's *Activity#onActivityResult(int, int, Intent),which in turn must call this method to pass the results to Glia SDK.
This method is no-op for other non-Glia triggered results.
-
getVisitorStatus
Engagement.VisitorState getVisitorStatus()
-
uploadFile
void uploadFile(File file, RequestCallback<EngagementFile> callback)
Uploads a file to the engagement. The uploaded file can be later sent as part of a chat message attachments. Additional security scan might be required in some cases before file can be sent as part of a chat message.Please see isSecurityScanRequired ()} for more informationThe error inside the completion may have one of the following causes:
- Parameters:
file- File which should be uploaded to the engagementcallback- called with EngagementFile when request succeedsor with GliaException.
-
uploadFile
void uploadFile(Uri fileUri, RequestCallback<EngagementFile> callback)
See uploadFile
- Parameters:
fileUri- Uri that points to the file which content should be uploaded to the engagementcallback- called with EngagementFile when request succeedsor with GliaException.
-
fetchFile
@Deprecated() void fetchFile(String fileId, RequestCallback<InputStream> callback)
-
end
void end(Consumer<GliaException> onResult)
Ends the Engagement.
All event listeners added to the and other engagement child modules,for example , are automatically removed.
-
getSurvey
void getSurvey(@NonNull() RequestCallback<Survey> callback)
Fetch the survey for the engagement.
Usage example:
engagement.on(Engagement.Events.END, () -> { engagement.getSurvey((survey, exception) -> { if (survey != null) { // show survey } }); });- Parameters:
callback- Called with Survey if the engagement has a survey,or with with{@code null}if the engagement doesn't have the survey.
-
on
<T> void on(@NonNull() Engagement.EngagementEvent<T> event, @NonNull() Consumer<T> listener)
Registers event listeners for .
If a listener is added while the is processing an event,it is not triggered with the current event.
If multiple identical listeners are registered on the same event typethe duplicate instances are discarded. They do not cause the listenerto be called twice and do not need to be removed with the #offmethod.
-
on
void on(@NonNull() Engagement.EngagementEvent<out Object> event, @NonNull() Runnable listener)
Registers event listeners for .
If a listener is added while the is processing an event,it is not triggered with the current event.
If multiple identical listeners are registered on the same event typethe duplicate instances are discarded. They do not cause the listenerto be called twice and do not need to be removed with the #offmethod.
Compared to #on(EngagementEvent, Consumer) this methoddoes not require the listener to consumer the payload.This is useful when payload is of type Void.
-
off
<T> void off(@NonNull() Engagement.EngagementEvent<T> event, @NonNull() Consumer<T> listener)
Removes event listeners from the .
If an event listener is removed while the is processing an event,it is not triggered with the current event.
Calling off} with arguments which do not identify any currently registeredlistener has no effect.
-
off
void off(@NonNull() Engagement.EngagementEvent<out Object> event, @NonNull() Runnable listener)
Removes event listeners from the .
If an event listener is removed while the is processing an event,it is not triggered with the current event.
Calling off} with arguments which do not identify any currently registeredlistener has no effect.
-
-
-
-