Intercom.js - 始终显示对讲按钮
Intercom.js - Always Show the Intercom Button
我正在尝试将 Intercom 实现到 ReactJS 应用程序中。我已经按照他们的单页应用程序说明进行操作。我遇到了一个问题(也许是设计使然?),除非向用户发送消息,否则不会显示右下角的小对讲按钮。我想让按钮 always 对用户可见。当我第一次集成时,我能够让按钮显示出来,并且能够以用户身份发送消息没问题,但是在修改代码之后,我似乎把它弄坏了。我到目前为止是:
store.js
import createStore from 'redux';
export default createStore( ... );
intercom.js
import store from './store';
const APP_ID = /* app id */;
/* the intercom JS library */
const updated = false;
window.onload = () => {
Intercom('boot', { app_id: APP_ID };
store.subscribe(() => {
if (typeof document === 'undefined') return;
const state = store.getState();
const currentUser = currentUserSelector(state);
if (currentUser && !updated) {
updated = true;
Intercom('update', {
email: currentUser.email,
user_id: currentUser.id,
name: `${ currentUser.firstName } ${ currentUser.lastName }`
});
}
});
}
我在应用程序加载时 运行 的其中一个文件中有 require('intercom.js')
。
控制台中没有错误,Intercom websocket 显示在 Chrome 的开发中。控制台,客户端在收到消息时打开,但我无法在页面加载时显示它。
提前致谢。
(我将其标记为 React,因为它是一个 React 应用程序 - 我不认为这与 React 有任何关系,但也许有一些我不知道的副作用)。
啊好的 - 简单的错误。原来我订阅的计划不支持非访客聊天。我必须 "upgrade" 到 "Resolve Lite" 计划 - 此时,我可以更改 Messenger 行为以在 Messenger 设置视图中显示 button/messenger 到 "Users"。
我正在尝试将 Intercom 实现到 ReactJS 应用程序中。我已经按照他们的单页应用程序说明进行操作。我遇到了一个问题(也许是设计使然?),除非向用户发送消息,否则不会显示右下角的小对讲按钮。我想让按钮 always 对用户可见。当我第一次集成时,我能够让按钮显示出来,并且能够以用户身份发送消息没问题,但是在修改代码之后,我似乎把它弄坏了。我到目前为止是:
store.js
import createStore from 'redux';
export default createStore( ... );
intercom.js
import store from './store';
const APP_ID = /* app id */;
/* the intercom JS library */
const updated = false;
window.onload = () => {
Intercom('boot', { app_id: APP_ID };
store.subscribe(() => {
if (typeof document === 'undefined') return;
const state = store.getState();
const currentUser = currentUserSelector(state);
if (currentUser && !updated) {
updated = true;
Intercom('update', {
email: currentUser.email,
user_id: currentUser.id,
name: `${ currentUser.firstName } ${ currentUser.lastName }`
});
}
});
}
我在应用程序加载时 运行 的其中一个文件中有 require('intercom.js')
。
控制台中没有错误,Intercom websocket 显示在 Chrome 的开发中。控制台,客户端在收到消息时打开,但我无法在页面加载时显示它。
提前致谢。
(我将其标记为 React,因为它是一个 React 应用程序 - 我不认为这与 React 有任何关系,但也许有一些我不知道的副作用)。
啊好的 - 简单的错误。原来我订阅的计划不支持非访客聊天。我必须 "upgrade" 到 "Resolve Lite" 计划 - 此时,我可以更改 Messenger 行为以在 Messenger 设置视图中显示 button/messenger 到 "Users"。