我现有的java web应用程序正在运行生产(maven java项目)。现在我想在屏幕右下方的应用程序中嵌入聊天。我该怎么办呢?有没有简单的方法,示例或API我可以添加聊天应用程序?我的Web应用程序只能用于登录用户,因此我希望让所有登录我的应用程序的用户以1对1或聊天组的形式互相聊天。
答案 0 :(得分:1)
以下是javascript中使用https://www.applozic.com聊天库的示例聊天代码:
https://jsfiddle.net/devashishmamgain/amjvszpp/
使用Javascript:
(function(d, m){var s, h;
s = document.createElement("script");
s.type = "text/javascript";
s.async=true;
s.src="https://apps.applozic.com/sidebox.app";
h=document.getElementsByTagName('head')[0];
h.appendChild(s);
window.applozic=m;
m.init=function(t){m._globals=t;}})(document, window.applozic || {});
window.applozic.init({
appId: 'applozic-sample-app', //Get your application key from https://www.applozic.com
userId: 'jsfiddle', //Logged in user's id, a unique identifier for user
userName: 'JSFiddler', //User's display name
imageLink : '', //User's profile picture url
email : '',
contactNumber: '',
desktopNotification: true,
notificationIconLink: 'https://www.applozic.com/favicon.ico', //Icon to show in desktop notification
onInit : function(response) {
if (response === "success") {
// login successful, perform your actions if any, for example: load contacts, getting unread message count, etc
} else {
// error in user login/register (you can hide chat button or refresh page)
}
},
contactDisplayName: function(otherUserId) {
//return the display name of the user from your application code based on userId.
return "";
},
contactDisplayImage: function(otherUserId) {
//return the display image url of the user from your application code based on userId.
return "";
}
});
HTML:
Open this fiddle in another tab and put userId: "jsfiddle2" in javascritp section and data-mck-id="jsfiddle1" in html a hyperlink below
<br><br>
<a href="#" class="applozic-launcher" data-mck-id="jsfiddle2" data-mck-name="JSFiddler 2">Click to CHAT</a>
<br>
<a href="#" class="applozic-launcher" data-mck-id="applozic" data-mck-name="Applozic">Chat with Applozic</a>
<br>
Applozic Chat and Messaging SDK to bring real time chat to your mobile apps and websites in just few lines of code.
<br>
Visit <a href="https://www.applozic.com">Applozic</a> to know more.
更多示例代码位于:https://github.com/AppLozic/Applozic-Web-Plugin/
免责声明:我是联合创始人@Applozic