Coder Social home page Coder Social logo

chat-window-android's Introduction

chat-window-android

Embedding mobile chat window in Android application for

LiveChat: https://developers.livechat.com/docs/getting-started/installing-livechat/android-widget/

Installation

[Release] (https://jitpack.io/#livechat/chat-window-android)

https://jitpack.io/#livechat/chat-window-android

To get a project into your build:

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

allprojects {
     repositories {
         ...
         maven { url 'https://jitpack.io' }
     }
 }

Step 2. Add the dependency

dependencies {
    implementation 'com.github.livechat:chat-window-android:v2.2.1'
}

Your application will need a permission to use the Internet. Add the following line to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

If you want to allow users to upload files from their external storage using chat window, a permission is also needed:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Usage

There are couple ways you can use this library. To be able to use all the features we recommend you add chat window as a view, either by using static method which adds view to your activity, or as an embedded view in your xml. As long as ChatWindowView is initilized, you will get events when new message comes in.

First, you need to configure your chat window

Configuration

Simply use ChatWindowConfiguration.java constructor. Note that licence number is mandatory.

configuration = new ChatWindowConfiguration(
    "your_licence_number",
    "group_id",
    "Visitor name",
    "[email protected]",
    customParamsMap);

You could also use new ChatWindowConfiguration.Builder().

Chat Window View

There are two recommended ways to use ChatWindow.

  • Full screen ChatWindow added to the root of your activity, and
  • XML embedded ChatWindow to controll placement and size

Full Screen Window

All you need to do is to create, attach and initialize chat window. Something in the lines of:

public void startFullScreenChat() {
    if (fullScreenChatWindow == null) {
        fullScreenChatWindow = ChatWindowUtils.createAndAttachChatWindowInstance(getActivity());
        fullScreenChatWindow.setConfiguration(configuration);
        fullScreenChatWindow.setEventsListener(this);
        fullScreenChatWindow.initialize();
    }
    fullScreenChatWindow.showChatWindow();
}

XML Embedded View

If you like to control the place and size of the ChatWindowView, you might want to add it to your app either by inlucidng a view in XML

<com.livechatinc.inappchat.ChatWindowViewImpl
    android:id="@+id/embedded_chat_window"
    android:layout_width="match_parent"
    android:layout_height="400dp"/>

or inflating the view directly

ChatWindowViewImpl chatWindowView = new ChatWindowViewImpl(MainActivity.this);

and then initializing ChatWindow like with full screen window approach:

public void startEmmbeddedChat(View view) {
    if (!emmbeddedChatWindow.isInitialized()) {
        emmbeddedChatWindow.setConfiguration(configuration);
        emmbeddedChatWindow.setEventsListener(this);
        emmbeddedChatWindow.initialize();
    }
    emmbeddedChatWindow.showChatWindow();
}

Navigation

Depending on your use case you might want to hide ChatWindow if user hits back button. You can use our onBackPressed() function which hides the view if its visible and returns true. In your activity/fragment add the following:

@Override
public boolean onBackPressed() {
    return fullScreenChatWindow != null && fullScreenChatWindow.onBackPressed();
}

ChatWindowEventsListener

This listener gives you opportunity to:

  • handle a case, when user wants to attach file in ChatWindow
  • get notified if new message arrived in chat. This gets handy if you want to show some kind of badge for a user to read new message.
  • react on visibility changes (user can hide the view on its own)
  • handle user selected links in a custom way
  • react and handle errors coming from chat window
  • allow users to use SnapCall integration

File sharing

To provide your users capability to send files, you need to set ChatWindowEventsListener on your ChatWindowView.

Your listener should override onStartFilePickerActivity method and start activity for result with provided intent and request code.

    @Override
    public void onStartFilePickerActivity(Intent intent, int requestCode) {
        startActivityForResult(intent, requestCode);
    }

and then give opportunity to the view to handle activity result, i.e.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (fullChatWindow != null) fullChatWindow.onActivityResult(requestCode, resultCode, data);
    super.onActivityResult(requestCode, resultCode, data);
}

Handling URL's

You can disable chat widget's default behavior when user selects link by implementing handleUri method from ChatWindowEventsListener.

@Override
public boolean handleUri(Uri uri) {
	// Handle uri here...
	return true; // Return true to disable default behavior.
}

Error handling

You might want to customize user experience when encountering errors, such as problems with internet connection. By returning true in onError callback method you're taking responsibility to handle errors coming from the chat window.

Please keep in mind that chat window, once it's loaded, can handle connection issues by sporadically trying to reconnect. This case can be detected by implementing following condition in onError callback method.

@Override
public boolean onError(ChatWindowErrorType errorType, int errorCode, String errorDescription) {
    if (errorType == ChatWindowErrorType.WebViewClient && errorCode == -2 && chatWindow.isChatLoaded()) {
        //Chat window can handle reconnection. You might want to delegate this to chat window
        return false;
    } else {
        reloadChatBtn.setVisibility(View.VISIBLE);
    }
    Toast.makeText(getActivity(), errorDescription, Toast.LENGTH_SHORT).show();
    return true;
}

Clear chat session

After your user signs out of the app, you might want to clear the chat session. You can do that by invoking static method on ChatWindowUtils.clearSession(Context) from anywhere in the app. In case your ChatWindowView is attached in course of the log out flow, you also going to need to reload it by calling chatWindow.reload(false) after clearSession code. See FullScreenWindowActivityExample.java

In case your ChatWindow isn't recreated when ChatWindowConfiguration changes (i.e. VisitorName), you might want to full reload chat window by invoking chatWindow.reload(true)

Alternative usage with limited capabilities

If you want you don't want users to be notified when user gets new message in hidden Chat, you might want to use provided activity or fragment

If you do not want the chat window to reload its content every time device orientation changes, add this line to your Activity in the manifest:

android:configChanges="orientation|screenSize"

The chat window will handle the orientation change by itself.

Example usage

There are two ways to open the chat window – using Activity or Fragment.

Using Activity

In order to open a chat window in new Activity, you need to declare ChatWindowActivity in your manifest. Add the following line to AndroidManifest.xml, between <application></application> tags:

<activity android:name="com.livechatinc.inappchat.ChatWindowActivity" android:configChanges="orientation|screenSize" />

Finally, add the following code to your application, in a place where you want to open the chat window (e.g. button listener). You need to provide a Context (your Activity or Application object), your LiveChat license number (taken from the your app: LiveChat and, optionally, an ID of a group:

Intent intent = new Intent(context, com.livechatinc.inappchat.ChatWindowActivity.class);
Bundle config = new ChatWindowConfiguration.Builder()
	.setLicenceNumber("<your_license_number>")
	.setGroupId("<your_group_id>")
	.build()
	.asBundle();

intent.putExtras(config);
startActivity(intent);

It’s also possibile to automatically login to chat window by providing visitor’s name and email. You need to disable pre-chat survey in the web application and add the following lines to the previous code:

intent.putExtra(com.livechatinc.inappchat.ChatWindowConfiguration.KEY_VISITOR_NAME, "your_name");
intent.putExtra(com.livechatinc.inappchat.ChatWindowConfiguration.KEY_VISITOR_EMAIL, "your_email");

Using Fragment

In order to open chat window in new Fragment, you need to add the following code to your application, in a place where you want to open the chat window (e.g. button listener). You also need to provide your LiveChat license number and group ID:

getFragmentManager()
   .beginTransaction()
   .replace(R.id.frame_layout, ChatWindowFragment.newInstance("your_license_number", "your_group_id"), "chat_fragment")
   .addToBackStack("chat_fragment")
   .commit();

Method ChatWindowFragment.newInstance() returns chat window Fragment.

It’s also possible to automatically login to chat window by providing visitor’s name and email. You need to disable pre-chat survey in web application and use different newInstance() method:

getFragmentManager()
   .beginTransaction()
   .replace(R.id.frame_layout, ChatWindowFragment.newInstance("your_license_number", "your_group_id", “visitor _name”, “visitor _email”), "chat_fragment")
   .addToBackStack("chat_fragment")
   .commit();

Localisation

You can change or localize error messages, by defining your own string resources with following id's

<string name="failed_to_load_chat">Couldn\'t load chat.</string>
<string name="cant_share_files">File sharing is not configured for this app</string>
<string name="reload_chat">Reload</string>

Migrating to version >= 2.2.0

  • ChatWindowView is now interface that can be casted to View
  • setUpWindow(configuration); is replaced by setConfiguration(configuration);
  • setUpListener(listener) is replaced by setEventsListener(listener)
  • ChatWindowView.clearSession(Context) is moved to ChatWindowUtils.clearSession(Context)
  • ChatWindowView.createAndAttachChatWindowInstance(Activity) is moved to `ChatWindowUtils.createAndAttachChatWindowInstance(getActivity())``

SnapCall integration

SnapCall integration requires AUDIO and VIDEO permissions. In order to allow your users to use SnapCall integration you need to:

  1. Set up your ChatWindowView Event listener, check ChatWindowEventsListener
  2. Add following permissions to you app AndroidManifest.xml file
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.CAMERA" />
  1. Override void onRequestAudioPermissions(String[] permissions, int requestCode) to ask user for permissions, like so:
@Override
public void onRequestAudioPermissions(String[] permissions, int requestCode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        this.requestPermissions(permissions, requestCode);
    }
}
  1. Override your activity void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) to pass result to ChatWindowView
if (!chatWindow.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

For reference, check FullScreenWindowActivityExample.java

chat-window-android's People

Contributors

jercik avatar nomyzs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chat-window-android's Issues

chat session state?

Is there a way to check if the chat session is currently minimized or ended?

Notification Sound

There is no notification sound even the sound is unmute in chat widget in Android App Integration, (We also enable sound on the Chat Widgets in Customization Section) we tested on Android 8.0 & 9.0

Pass our own argument in when chat opens

Hi,

I want to pass addition data to agent app with pre chat server data. So I create a local json file same as http://cdn.livechatinc.com/app/mobile/urls.json. I just appended my data as below.

https://secure.livechatinc.com/licence/8445821/open_chat.cgi?name=JohnDoe&[email protected]&params=visitor%3Duit

I build the jar again after this change and use it in my android app. But I can't see that additional field "visitor" anywhere in agent's app.

Can you tell me where is the problem here?

set groupid 3,but it goto group1

I set group 1-5 in livechat web.l but it goto gourp 1,
this is test code ,
String licenceNumber = "XXXX";
String groupId = "3";
String userName = "Tester";
String email = "[email protected]";
HashMap<String,String> customVariables = new HashMap<String, String>();
final ChatWindowConfiguration config = new ChatWindowConfiguration(licenceNumber, groupId, userName, email, customVariables);
Intent intent = new Intent(MainActivity.this, ChatWindowActivity.class);
intent.putExtras(config.asBundle());
startActivityForResult (intent,3333);

Passing KEY_VISITOR_NAME and KEY_VISITOR_EMAIL doesn't work

Hi, I'm trying to initialize chat window with autologin params ( user and email) to avoid use the "Pre-chat survey" but ever the login is with default user name "Client". I disabled the Pre-chat survey. I checked the params are passing well between LiveChat library activities but at the console I'm receiving "Client" like user name without email.

Paste of my initialization code, in Kotlin, following the guide (https://docs.livechatinc.com/android-widget/#sample-usage)

val intent = Intent(this, ChatWindowActivity::class.java) intent.putExtra(com.livechatinc.inappchat.ChatWindowActivity.KEY_VISITOR_NAME, "Ramón") intent.putExtra(com.livechatinc.inappchat.ChatWindowActivity.KEY_VISITOR_EMAIL, "[email protected]") intent.putExtra(com.livechatinc.inappchat.ChatWindowActivity.KEY_LICENCE_NUMBER, BuildConfig.LIVECHAT_LICENSE_NUMBER) startActivity(intent)

NOT SUPPORTED FOR 5+ VERSIONS

I have downloaded your code.It is working in 4.4 but not in 5+ version android.It is giving below log error.
07-05 14:53:02.841 3965-3965/com.livechatinc.livechatwidgetexample D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
07-05 14:53:02.926 3965-3965/com.livechatinc.livechatwidgetexample I/Timeline: Timeline: Activity_launch_request id:com.livechatinc.livechatwidgetexample time:36463497
07-05 14:53:02.966 3965-3965/com.livechatinc.livechatwidgetexample D/Activity: performCreate Call secproduct feature valuefalse
07-05 14:53:02.971 3965-3965/com.livechatinc.livechatwidgetexample D/Activity: performCreate Call debug elastic valuetrue
07-05 14:53:03.001 3965-5667/com.livechatinc.livechatwidgetexample I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
07-05 14:53:03.151 3965-3965/com.livechatinc.livechatwidgetexample I/cr_Ime: ImeThread is enabled.
07-05 14:53:03.151 3965-4575/com.livechatinc.livechatwidgetexample E/IMGSRV: :0: ComputeFrameBufferCompleteness: Switching psTex 0x9e6be480 to XBGR
07-05 14:53:03.156 3965-4575/com.livechatinc.livechatwidgetexample E/IMGSRV: :0: ComputeFrameBufferCompleteness: Switching psLevel 0xaf153400 to XBGR
07-05 14:53:03.156 3965-4575/com.livechatinc.livechatwidgetexample E/IMGSRV: :0: ComputeFrameBufferCompleteness: Switching psTex 0xaf185c00 to XBGR
07-05 14:53:03.161 3965-4575/com.livechatinc.livechatwidgetexample E/IMGSRV: :0: ComputeFrameBufferCompleteness: Switching psLevel 0xaf153c00 to XBGR
07-05 14:53:03.211 3965-4037/com.livechatinc.livechatwidgetexample D/OpenGLRenderer: endAllStagingAnimators on 0xb4cdf800 (RippleDrawable) with handle 0x9e3e30a0
07-05 14:53:03.266 3965-3965/com.livechatinc.livechatwidgetexample I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2f60b2d2 time:36463836
07-05 14:53:03.476 3965-3965/com.livechatinc.livechatwidgetexample W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3965
07-05 14:53:03.581 3965-3965/com.livechatinc.livechatwidgetexample V/ActivityThread: updateVisibility : ActivityRecord{368e14a4 token=android.os.BinderProxy@f3bf74c {com.livechatinc.livechatwidgetexample/com.livechatinc.livechatwidgetexample.MainActivity}} show : false

Issue Loading Chat

I am trying to integrate the android chat widget in my android app. I keep getting the error below on my debug console.

I/ChatWindowView(19296): onConsoleMessageERROR Uncaught TypeError: undefined is not a function
I/chromium(19296): [INFO:CONSOLE(1)] "Uncaught TypeError: undefined is not a function", source: https://cdn.livechatinc.com/widget/static/js/iframe.eecfb93e.chunk.js (1)

Attached below are screenshots of the chat window initialized, error when I try to type and send a message, debug console showing the error in that order.

Screenshot_1598438099
Screenshot_1598438109
Screenshot (514)

Connection lost on chat window initiation

Hi, I have integrated Livechat SDK with my android application. After integrating when I try to initiate chat 8/10 times it shows "Connection lost. Please check your internet connection and try again". But my internet strength is very strong but it keeps saying above issue. I am using trial version account and we are creating demo of LiveChat and chat bot integration in our product.

If such issue keeps on repeating we wont be able to integrate as it would be bad user experience. Please can the team look into it.

I have attached the video recording of issue
20190322-122041-720x1280.zip

Back navigation in ChatWindowView

Hi. I have a problem regarding the navigation through chat. I am using ChatWindowView and the back navigation doesn't work properly when the user opens some other window in the chat. For example, by opening an image in the conversation there is no way to go back to the conversation. It seems that chat WebView doesn't handle back navigation.

api 15 needed

After adding livechat dependency to our build.gradle (complie 'com.github.livechat:chat-window-android:v2.0.3')
:processDebugManifest/:processReleaseManifest started to fail with
Error: uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.github.livechat:chat-window-android:v2.0.3] ~/.gradle/caches/transforms-1/files-1.1/chat-window-android-v2.0.3.aar/3b80e858f133c212ad12e862783ecfc4/AndroidManifest.xml as the library might be using APIs not available in 15

Our android app still supports minSdkVersion 15
While livechat's app/build.gradle declares minSdkVersion 16

  1. Actually we can override minSdk while merging your AndroidManifest.xml with:
<uses-sdk android:minSdkVersion="15"
        tools:overrideLibrary="com.livechatinc.inappchat"
        />

and show livechat button only for "Build.VERSION.SDK_INT>=16" devices

or
2) Decrease your minSdkVersion to 15 (if api 16's features are not so important for you)

Error using ChatWindowView with mobile Wi-Fi hotspot

LiveChat SDK for android works well as on Android Oreo and above but not sure why it is not working on Android M device that having its connection from a mobile Hotspot of another device. The error log seems to do with a connection issue. Here is the complete log.

E/LiveChat Widget: failed to connect to cdn.livechatinc.com/127.0.0.1 (port 443) after 15000ms: isConnected failed: ECONNREFUSED (Connection refused) W/System.err: java.net.ConnectException: failed to connect to cdn.livechatinc.com/127.0.0.1 (port 443) after 15000ms: isConnected failed: ECONNREFUSED (Connection refused) at libcore.io.IoBridge.isConnected(IoBridge.java:234) at libcore.io.IoBridge.connectErrno(IoBridge.java:171) W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452) at java.net.Socket.connect(Socket.java:888) at com.android.okhttp.internal.Platform.connectSocket(Platform.java:117) at com.android.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:160) at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:79) at com.android.okhttp.Connection.connect(Connection.java:143) at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185) at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128) W/System.err: at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java) at com.winbig88.bola.inappchat.k.a(LoadWebViewContentTask.java:64) at com.winbig88.bola.inappchat.k.doInBackground(LoadWebViewContentTask.java:30) at android.os.AsyncTask$2.call(AsyncTask.java:295) W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused) W/System.err: at libcore.io.IoBridge.isConnected(IoBridge.java:223)

how to show live chat inside ChatWindowView ?

Hello,
I don’t know is a bug or my mistake. Maybe same one can help me.
I add

maven { url 'https://jitpack.io' }
...
implementation 'com.github.livechat:chat-window-android:v2.0.3'
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

To my project .
In main xml

<com.livechatinc.inappchat.ChatWindowView
    android:id="@+id/embedded_chat_window"
    android:layout_width="match_parent"
    android:layout_height="400dp"/>

In main acitivity

@BindView(R.id.embedded_chat_window)
ChatWindowView leChatWindowView;
...
configuration = new ChatWindowConfiguration("MY-ID",null,null,null, null);
...
public void startEmmbeddedChat() {
    if (!leChatWindowView.isInitialized()) {
        leChatWindowView.setUpWindow(configuration);
        leChatWindowView.setUpListener(this);
        leChatWindowView.initialize();
    }
    leChatWindowView.showChatWindow();
}

on click call startEmmbeddedChat, and this code opens browser, but I need that all be in WebView (ChatWindowView component).

Maybe same one knows how to do that?

Chat EditText Hiding behind the Keyboard

I am facing a problem in which the users can see the edit text once the soft keyboard appears,

the same as here : #31

I am using this method to implement the live chat: Full screen ChatWindow added to the root of your Activity

I tested this problem in most in devices on android and the same problem, S10+ for example

ChatWindowConfiguration methods not recognized

In ChatWindowConfiguration class, setLicenceNumber() and setGroupId() is not public in com.livechatinc.inappchat.ChatWindowConfiguration.Builder.

asBundle() is not recognized as well

Intent intent = new Intent(this, ChatWindowActivity.class);
        Bundle config = new ChatWindowConfiguration.Builder()
                .setLicenceNumber("XXXXXXX")
                .setGroupId("X")
                .build()
                .asBundle();

        intent.putExtras(config);

https://github.com/livechat/chat-window-android#using-activity

A progress Dialog Is loading no chat window is showing

java code

public class MainActivity extends AppCompatActivity implements ChatWindowView.ChatWindowEventsListener {
ChatWindowView emmbeddedChatWindow;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

emmbeddedChatWindow = findViewById(R.id.embedded_chat_window);

    startEmmbeddedChat();
}

public void startEmmbeddedChat() {
    if (!emmbeddedChatWindow.isInitialized()) {
        ChatWindowConfiguration configuration = new ChatWindowConfiguration(
                "10111697",
                "0",
                "Ajay",
                "[email protected]",
               null
        );
        emmbeddedChatWindow.setUpWindow(configuration);
        emmbeddedChatWindow.setUpListener(this);
        emmbeddedChatWindow.initialize();
    }
    emmbeddedChatWindow.showChatWindow();
}

@Override
public void onChatWindowVisibilityChanged(boolean b) {

}

@Override
public void onNewMessage(NewMessageModel newMessageModel, boolean b) {

}

@Override
public void onStartFilePickerActivity(Intent intent, int i) {

}

@Override
public boolean handleUri(Uri uri) {
    return false;
}

xml

<com.livechatinc.inappchat.ChatWindowView
android:id="@+id/embedded_chat_window"
android:layout_width="match_parent"
android:layout_height="400dp"/>

Chat session

I have 2 scenarios,

  1. Logged in chat
  2. Not logged in chat

I have set my logged-in into auto fill-up the form(email,name) for livechat and for not logged in I leave it blank I didn't set it (email,name) so the not logged in can fill-up their email and name.

But when I use it, the not logged in still uses the email and name from logged in.

flutter

hi everyone, i want to use livechat for flutter, how to do it?

Allow open external link

I tried to take a local copy of this project and one thing that our team noticed is that links within the chats can't be automatically open via another browser. We know that it has something to do with shouldOverrideUrlLoading in ChatWindowView.class but there is also a method handleUri(). What changes do we need to perform to allow link/uri intents so we can open a link via browser app. We do not want to break the existing logic of the handleUri() methods thus we ask for your guidance on this. This also could probably a feature request. We tried to change the code to adding an Intent and returning true on shouldOverrideUrlLoading but after returning in the app, the LiveChat windows become empty.

  `private boolean handleUri(WebView webView, final Uri uri) {
        String uriString = uri.toString();
        boolean facebookLogin = uriString.matches("https://.+facebook.+(/dialog/oauth\\?|/login\\.php\\?|/dialog/return/arbiter\\?).+");

        if (facebookLogin) {
            return false;
        } else {
            if (webViewPopup != null) {
                webViewPopup.setVisibility(GONE);
                removeView(webViewPopup);
                webViewPopup = null;
            }

            String originalUrl = webView.getOriginalUrl();

            if (uriString.equals(originalUrl) || isSecureLivechatIncDoamin(uri.getHost())){//uri.getHost().contains("secure-lc.livechatinc.com")) {
                return false;
            } else {
                if (chatWindowListener != null/* && chatWindowListener.handleUri(uri)*/) {
                    return true;
                }
                else {
                    try {
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        getContext().startActivity(intent);
                    }
                    catch (Exception e){
                        Toast.makeText(getContext(), "Error : " + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                }

                return true;
            }
        }
    }`

Didn't find class "com.livechatinc.inappchat.R$layout"

Hi there,
Following the guide, but have a crash:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.latoken.wallet, PID: 29257
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/livechatinc/inappchat/R$layout;
        at com.livechatinc.inappchat.ChatWindowFragment.onCreateView(ChatWindowFragment.java:81)

My code:

 Intent intent = new Intent(this, com.livechatinc.inappchat.ChatWindowActivity.class);
        Bundle config = new ChatWindowConfiguration.Builder()
                .setLicenceNumber("LICENCE_NUMBER")
                .setVisitorEmail("EMAIL")
                .setVisitorName("NAME")
                .setCustomParams(customParamsMap)
                .build()
                .asBundle();
        intent.putExtras(config);
        startActivity(intent);

Unread messages

Hi, for now I'm using onNewMessage() callback to count number of unread messaged, but is it possible to receive this count from API?

Blank Screen with loading in the middle never ends

I added the chat on my android and tried the simplest way to make it work

Created a button that followed this code:
Intent intent = new Intent(this, com.livechatinc.inappchat.ChatWindowActivity.class);
intent.putExtra(com.livechatinc.inappchat.ChatWindowActivity.KEY_GROUP_ID, "group1");
intent.putExtra(ChatWindowActivity.KEY_LICENCE_NUMBER, "MYKEY");
this.startActivity(intent);

I followed this link to do this: https://www.chat.io/docs/android-widget/

After clicking the button It opens a blank screen with loading in the middle. I have internet enabled and I cant seem to find the reason why this Behaviour happens.

Can anyone help me?

Progress loader continues loading even after window is initialized

When you load the chat window via mChatWindow.showChatWindow(); there is a progress loader that seems to keep spinning endlessly even though the screen appears to have already been initialized. This appears to be controlled by com.github.livechat/chat-window-android/2.0.4/dceb8c5bda50618aa18702a9a32ad6a14d3a5889/chat-window-android-2.0.4-sources.jar!/com/livechatinc/inappchat/ChatWindowView.java

How to logout/clear session?

Is there a way to reset the chat by logging out or clearing session? On your ios version there is a mehod clearSession but on Android there is nothing to do so. please help

Chat ID

What's the equivalent of (javascript) "LC_API.get_chat_id()" in android SDK. Thank you

Security Issue

When livechat sdk connect to livechat server,there is a TLS_RSA_WITH_3DES_EDE_CBC_SHA method need to remove from server,It's not safe.

image
image

memory leak in chat-window-android:v2.0.0

We integrated livechat SDK in our App ,and tested our app by monkey runner,we found some memory leak issues
Here is some information

livechat SDK version :v2.0.0
leak log:
image

Cannot add attachment when chat is shown in WebView

Hi, I have used ChatWindowView by putting it in an XML view. When I receive chat uri, I am redirecting it to WebView in my application using handleUri(uri: Uri?) method.

Here is my WebView configuration:

with(chatWebView.settings) {
    setAppCachePath(cacheDir.path)
    setAppCacheEnabled(true)
    cacheMode = WebSettings.LOAD_DEFAULT
    domStorageEnabled = true
    javaScriptEnabled = true
}
chatWebView.webChromeClient = WebChromeClient()

I have implemented also onStartFilePickerActivity method for the chat listener:

override fun onStartFilePickerActivity(intent: Intent?, requestCode: Int) {
        startActivityForResult(intent, requestCode)
}

Chat works correctly, but the attachment button is grayed out, and there is no action after I click on it.

Chat doesn't persist across application's activities after timeout

I have a floating button on all of my activities to launch the chat, if I open it in one activity it will continue in others. However, if the chat times out and I switch activities, the original will have the option to restart and the new one will just show a fresh chat. Is there maybe some way to persist the timed out chat in new activities in order to keep the chat window consistent and keep history?

Error 'custom_mobile_settings'

Client's chat window halted frozen?

Hello!

Your chat-support directed us here to GitHub.

We are developing an app
https://play.google.com/store/apps/details?id=com.ntpayments.wallet
(currently closed testing)

LiveChat is used for customer support.

We met an unexpected feature
Screenshot-NT-Wallet-20190121-152523
The chat is halted frozen, after back-end side employee closes this chat.

Client can restart the chat only after intentionally closing chat window.

How can we make it easier for client?

  1. Don't block the chat window
  2. Don't force a client to exit chat to re-enter

Thank you!
screenshot_nt wallet_20190121-152523

'we could not load' issue upon turning off then on the wifi/mobile data

Hello, I am facing an issue with the android sdk
Below is the scenario to reproduce it

1- initialize the chat window and open it
2- fill all the required fields and start a new chat
3- minimize and open it several times(no problem)
4- turn off the wifi then instantly turn it on and the live chat window is always going to show we could not load
no matter how much I try to close and open the chat window
I have to initialize it again
and all the chat history is gone
We tried the same scenario on the iOS SDK and it is not happening

Losing session when minimize the live chat window

Hi, I'm using ChatWindowActivity to present chat window. When press minimize button on Chat window, and back to ChatWindowActivity, it will lose the conversation at last time.
Could you please share the knowledge that how live chat maintain the session, and bring it back from last time in sdk code?

Cannot add attachment

If i push button for sending attachment, dialog for select atachment is opened, but atachment is not sent after push button for sending.
If we try push button several times and repaet his operation, dialog is not opened. I have to chat close and open once more.

Code in main activity:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

    Object contentCurrent = App.screen.contentGetCurrent();
    if (contentCurrent instanceof HelpOnLineFragment) {
        HelpOnLineFragment fragment = (HelpOnLineFragment)contentCurrent;
        fragment.chatWindow.onActivityResult(requestCode, resultCode, data);
    }

}

Code in my fragment:
public class HelpOnLineFragment extends AppFragment implements ChatWindowView.ChatWindowEventsListener {

public ChatWindowView chatWindow;
private ChatWindowConfiguration configuration;

@Override public void onCreateView() {
	chatWindow = findView(R.id.chatWindow);
	chatRun();
}

private void chatRun() {
	String licenceNumber = Const.ONLINE_HELP_LICENSE_ID;
	String groupId = "5"; 
	String visitorName = App.server.getClientName();
	String visitorEmail = App.data.clientInfo.email;

	configuration = new ChatWindowConfiguration(licenceNumber, groupId, visitorName, visitorEmail, null);

	chatWindow.setUpWindow(configuration);
	chatWindow.setUpListener(this);
	chatWindow.initialize();
	chatWindow.showChatWindow();
}

@Override public void onChatWindowVisibilityChanged(boolean visible) {
	if (!visible) {
		getActivity().onBackPressed();
	}
}

@Override public void onNewMessage(NewMessageModel message, boolean windowVisible) {
}

@Override public void onStartFilePickerActivity(Intent intent, int requestCode) {
	startActivityForResult(intent, requestCode);
}

@Override public boolean onError(ChatWindowErrorType errorType, int errorCode, String errorDescription) {
	return false;
}

@Override public boolean handleUri(Uri uri) {
	return false;
}

}

Chat history not retained when launching from a new Activity using same/new ChatWindowConfiguration instance.

I've chat icon on 3 different (Activity) screens in my app. If I have started a chat on one of these screens, and then go to another screen and launch chat there, it starts a fresh chat again and doesn't show my ongoing chat from the previous screen.
Unable to figure out how to retain chat history from one (Activity)screen to another.
I have tried reusing same ChatWindowConfiguration instance each time but no luck.

I am using full screen window as mentioned in https://developers.livechatinc.com/docs/android-widget/#full-screen-window

SAMPLE CODE:

ChatWindowView initializeFullScreenChat(Activity activity, ChatWindowView.ChatWindowEventsListener chatListener) {
        final ChatWindowConfiguration configuration = new ChatWindowConfiguration("licenseNumber", "random_group_id", null, null, null);

        ChatWindowView fullScreenChatWindow = ChatWindowView.createAndAttachChatWindowInstance(activity);
        fullScreenChatWindow.setUpWindow(configuration);
        fullScreenChatWindow.setUpListener(chatListener);
        fullScreenChatWindow.initialize();

        return fullScreenChatWindow;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.