@ capgo/ 电容- intercom
在iOS和Android上的原生Intercom SDKs中,将Intercom聊天,帮助中心和内接消息添加到您的Capacitor应用上.
🤖 建筑与AI编码代理? 安装 Capgo 技能 所以克劳德代码,代码,光标,副驾驶,或双子座CLI知道如何安装和使用
@capgo/capacitor-intercom在您的电容应用程序中:npx skills add Cap-go/capgo-skills。然后问你的经纪人: 添加@capgo/capor-intercom到我的Capacitor应用上,并把它接上 代理设置指南 • 妇女 主机磁共振
主要特点
- 设置和用户数字 :
loadWithKeys(), (中文(简体) ),registerIdentifiedUser(), (中文(简体) ),registerUnidentifiedUser(), (中文(简体) ),updateUser()财务报告和审定财务报表logout()。 。 。 . - 通讯员数字 :
displayMessenger(), (中文(简体) ),displayMessageComposer(), (中文(简体) ),hideMessenger()和发射器能见度控制. - 内容数字 :
displayHelpCenter(), (中文(简体) ),displayArticle()财务报告和审定财务报表displayCarousel()。 。 。 . - 活动数字 :
logEvent(),则unreadCountDidChange监听器,加windowDidShow财务报告和审定财务报表windowDidHide(原始内容存档于2018-03-31). On iOS. - 正在应用信件数字 :
displayInAppMessages()财务报告和审定财务报表hideInAppMessages()。 。 。 . - 平台: iOS和Android. 互联网档案馆的存檔,存档日期2013-12-21. 使用官方的Intercom SDK. 在网上不可用.
为什么是Capacitor Intercom?
完全重新执行的 Intercom 插件 电容 8,按照 Capgo 质量标准构建:
- Intercom iOS SDK 19+ - 最新快速API,有适当的自动处理
- Intercom Android SDK 17+ 互联网档案馆的存檔,存档日期2013-12-02 - 现代Intercom客户集成
- 无臭虫 - 社区实施中已知的固定错误(例如:.
hideInAppMessages(Android号) - 跨平台 - 一致的API跨iOS和Android
- 完整特性集 - 信使、帮助中心、文章、木卫一、推、身份验证等等
任何整合Intercom的应用程序对于客户支持、登入或应用中的信息至关重要.
文档
这里有最完整的医生: https://capgo.app/docs/plugins/intercom/ (中文(简体) )
兼容性
| 插件版本 | 电容兼容性 | 维护 |
|---|---|---|
| 联合国 | 联合国 | ✅ |
| 页:1 | 页:1 | 应要求 |
| 页:1 | 页:1 | ❌ |
| 页:1 | 页:1 | ❌ |
说明: 此插件的主要版本沿用了Capacitor的主要版本. 使用匹配您的 Capacitor 安装的版本( 如 Capacitor 8 的插件 v8) 。 只有最新的主要版本得到积极维护.
安装
您可以使用我们的 AI 辅助设置安装插件 。 使用以下命令将 Capgo 技能添加到您的 AI 工具 :
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
然后使用下列提示:
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-intercom` plugin in my project.
如果您更喜欢手动设置,请通过运行以下命令来安装插件,并遵循下面的平台特定指令:
npm install @capgo/capacitor-intercom
npx cap sync
配置
将您的 Intercom 密钥添加到您的 Capacitor 配置 :
{
"plugins": {
"CapgoIntercom": {
"iosApiKey": "ios_sdk-xxx",
"iosAppId": "yyy",
"androidApiKey": "android_sdk-xxx",
"androidAppId": "yyy"
}
}
}
或者,您可以在运行时使用 loadWithKeys()。 。 。 .
iOS系统
Intercom iOS SDK (英语:~> 19.0)通过CocoaPods或Swift包管理器自动包含.
推动通知
- 禁用Intercom的自动驱动集成,将此添加到您的
Info.plist防止与Capacitor的推处理相冲突:
<key>IntercomAutoIntegratePushNotifications</key>
<false/>
- 将设备令牌转发给 Capacitor在您的
AppDelegate.swift数字 :
import UIKit
import Capacitor
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Forward to Capacitor, the plugin's observer picks this up
// and sends the token to Intercom automatically
NotificationCenter.default.post(
name: .capacitorDidRegisterForRemoteNotifications,
object: deviceToken
)
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
NotificationCenter.default.post(
name: .capacitorDidFailToRegisterForRemoteNotifications,
object: error
)
}
}
- 推动和处理通知窃听器的注册在您的应用程序 JavaScript 中:
import { PushNotifications } from '@capacitor/push-notifications';
import { CapgoIntercom as Intercom } from '@capgo/capacitor-intercom';
// Request permission + register
const perm = await PushNotifications.requestPermissions();
if (perm.receive === 'granted') {
await PushNotifications.register();
}
// Auto-forward FCM token to Intercom
PushNotifications.addListener('registration', async (token) => {
await Intercom.sendPushTokenToIntercom({ value: token.value });
});
// When user taps a notification, tell Intercom to open the conversation
PushNotifications.addListener('pushNotificationActionPerformed', async (action) => {
const data = action.notification?.data;
// iOS uses 'intercom_push_type', Android uses 'receiver'
if (data?.intercom_push_type || data?.receiver === 'intercom_sdk') {
await Intercom.receivePush(data);
}
});
说明: 插件在发现时会自动在 Intercom 中注册 APNs 设备令牌
.capacitorDidRegisterForRemoteNotifications。您仍然必须上传您的 APN 认证密钥( S).p8),位于火地台下 项目设置 → 云信息 → APNs 认证密钥。 。 。 .
机器人
Intercom Android SDK (英语:17.4.2)通过Gradle自动包含.
推动通知
由于Android只允许 一个 FirebaseMessagingService,此插件会 没有 自己登记。 相反,它提供 IntercomFcmHelper一个静态的助手 从你的应用服务.
- 创建自己的
FirebaseMessagingService在您的应用程序中( 例如 ).app/src/main/java/.../MyFirebaseMessagingService.java:
package com.your.app;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import app.capgo.capacitor.intercom.IntercomFcmHelper;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (IntercomFcmHelper.isIntercomPush(remoteMessage)) {
IntercomFcmHelper.onMessageReceived(this, remoteMessage);
} else {
// Handle other push SDKs (e.g. @capacitor/push-notifications)
// or your own notification logic here
}
}
@Override
public void onNewToken(String token) {
IntercomFcmHelper.onNewToken(this, token);
// Forward token to other SDKs if needed
}
}
- 在您的应用程序中注册
AndroidManifest.xml数字 :
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
此方法与其他 Firebase 插件兼容, 您可以控制路由 .
API 密码
loadWithKeys(...)registerIdentifiedUser(...)registerUnidentifiedUser()updateUser(...)logout()logEvent(...)displayMessenger()displayMessageComposer(...)displayHelpCenter()hideMessenger()displayLauncher()hideLauncher()displayInAppMessages()hideInAppMessages()displayCarousel(...)displayArticle(...)displaySurvey(...)setUserHash(...)setUserJwt(...)setBottomPadding(...)sendPushTokenToIntercom(...)receivePush(...)getUnreadConversationCount()addListener('windowDidShow', ...)addListener('windowDidHide', ...)addListener('unreadCountDidChange', ...)removeAllListeners()- 接口
装入 Keys (...)
loadWithKeys(options: IntercomLoadOptions) => Promise<void>
在运行时初始化 API 密钥的Intercom . 如果您不愿在 macher.config 中配置密钥, 请使用此选项 .
| 参数 | 类型 |
|---|---|
options | IntercomLoadOptions |
注册识别用户(...)
registerIdentifiedUser(options: IntercomIdentifiedUserOptions) => Promise<void>
向Intercom注册已知用户. 至少必须提供一个用户ID或电子邮件 .
| 参数 | 类型 |
|---|---|
options | IntercomIdentifiedUserOptions |
未识别用户 ()
registerUnidentifiedUser() => Promise<void>
向Intercom注册匿名用户.
更新用户(...)
updateUser(options: IntercomUserUpdateOptions) => Promise<void>
更新Intercom中的用户属性.
| 参数 | 类型 |
|---|---|
options | IntercomUserUpdateOptions |
登录( c)
logout() => Promise<void>
将用户登录出Intercom.
日志事件(...)
logEvent(options: IntercomLogEventOptions) => Promise<void>
登录 Intercom 中的自定义事件 .
| 参数 | 类型 |
|---|---|
options | IntercomLogEventOptions |
显示信使( )
displayMessenger() => Promise<void>
打开Intercom信使.
显示MessageComposer (...)
displayMessageComposer(options: IntercomMessageComposerOptions) => Promise<void>
以预填信件打开信件作曲家.
| 参数 | 类型 |
|---|---|
options | IntercomMessageComposerOptions |
显示帮助中心( C)
displayHelpCenter() => Promise<void>
打开Intercom帮助中心.
隐藏信使( C)
hideMessenger() => Promise<void>
隐藏 Intercom 信使 .
显示 Launcher ()
displayLauncher() => Promise<void>
显示 Intercom 启动按钮 .
隐藏 Launcher ()
hideLauncher() => Promise<void>
隐藏 Intercom 启动按钮 .
显示 ImpMessages ()
displayInAppMessages() => Promise<void>
启用 Intercom 的应用信件 .
隐藏 InAppMessages ()
hideInAppMessages() => Promise<void>
禁用 Intercom 的应用信件 .
显示 Carousel (...)
displayCarousel(options: IntercomCarouselOptions) => Promise<void>
显示特定的Intercom旋转木马.
| 参数 | 类型 |
|---|---|
options | IntercomCarouselOptions |
显示文章(...)
displayArticle(options: IntercomArticleOptions) => Promise<void>
显示特定的Intercom文章 .
| 参数 | 类型 |
|---|---|
options | IntercomArticleOptions |
显示调查(...)
displaySurvey(options: IntercomSurveyOptions) => Promise<void>
显示一个特定的Intercom调查.
| 参数 | 类型 |
|---|---|
options | IntercomSurveyOptions |
设置 UserHash (...)
setUserHash(options: IntercomUserHashOptions) => Promise<void>
设定用于身份验证的 HMAC .
| 参数 | 类型 |
|---|---|
options | IntercomUserHashOptions |
设置用户Jwt(...)
setUserJwt(options: IntercomUserJwtOptions) => Promise<void>
设置 JWT 安全信使认证 .
| 参数 | 类型 |
|---|---|
options | IntercomUserJwtOptions |
设置 BottomPadding(...)
setBottomPadding(options: IntercomBottomPaddingOptions) => Promise<void>
为 Intercom 信使 UI 设置底板 .
| 参数 | 类型 |
|---|---|
options | IntercomBottomPaddingOptions |
发送 PushTokenTo Intercom (...)
sendPushTokenToIntercom(options: IntercomPushTokenOptions) => Promise<void>
向Intercom发送一个按键通知符.
| 参数 | 类型 |
|---|---|
options | IntercomPushTokenOptions |
接收 Push (...)
receivePush(notification: IntercomPushNotificationData) => Promise<void>
处理收到的Intercom推送通知.
| 参数 | 类型 |
|---|---|
notification | IntercomPushNotificationData |
获取 Unread Conversation Count ()
getUnreadConversationCount() => Promise<IntercomUnreadCountResult>
为当前用户获取未读对讲次数 .
回返情况: Promise<IntercomUnreadCountResult>
添加倾听器( '窗口显示',...)
addListener(eventName: 'windowDidShow', listenerFunc: () => void) => Promise<PluginListenerHandle>
显示 Intercom 窗口时请听 .
| 参数 | 类型 |
|---|---|
eventName | 'windowDidShow' |
listenerFunc | () => void |
回返情况: Promise<PluginListenerHandle>
添加倾听器( '窗口隐藏',...)
addListener(eventName: 'windowDidHide', listenerFunc: () => void) => Promise<PluginListenerHandle>
听当Intercom窗口被隐藏时.
| 参数 | 类型 |
|---|---|
eventName | 'windowDidHide' |
listenerFunc | () => void |
回返情况: Promise<PluginListenerHandle>
添加倾听器( “ 未读的变换” ,...)
addListener(eventName: 'unreadCountDidChange', listenerFunc: (data: IntercomUnreadCountResult) => void) => Promise<PluginListenerHandle>
听听未读对讲数的变化.
| 参数 | 类型 |
|---|---|
eventName | 'unreadCountDidChange' |
listenerFunc | (data: IntercomUnreadCountResult) => void |
回返情况: Promise<PluginListenerHandle>
删除所有收听器( )
removeAllListeners() => Promise<void>
删除全部事件听众 .
接口
Intercom 路由选项
| Prop | 类型 |
|---|---|
appId | string |
apiKeyIOS | string |
apiKeyAndroid | string |
互通用户选项
| Prop | 类型 |
|---|---|
userId | string |
email | string |
用户间更新选项
| Prop | 类型 |
|---|---|
userId | string |
email | string |
name | string |
phone | string |
languageOverride | string |
customAttributes | { [key: string]: any; } |
companies | IntercomCompany[] |
公司间
| Prop | 类型 |
|---|---|
companyId | string |
name | string |
plan | string |
monthlySpend | number |
createdAt | number |
customAttributes | { [key: string]: any; } |
IntercomLogEvent 选项
| Prop | 类型 |
|---|---|
name | string |
data | { [key: string]: any; } |
互通计算机
| Prop | 类型 |
|---|---|
message | string |
互联互通选项
| Prop | 类型 |
|---|---|
carouselId | string |
互通条款选项
| Prop | 类型 |
|---|---|
articleId | string |
Intercom 调查选项
| Prop | 类型 |
|---|---|
surveyId | string |
互通用户Hash 选项
| Prop | 类型 |
|---|---|
hmac | string |
互通用户 Jwt 选项
| Prop | 类型 |
|---|---|
jwt | string |
互联
| Prop | 类型 |
|---|---|
value | number |
Intercom PushToken 选项
| Prop | 类型 |
|---|---|
value | string |
互通通知数据
互联互通
| Prop | 类型 |
|---|---|
count | number |
插件听筒
| Prop | 类型 |
|---|---|
remove | () => Promise<void> |