@freshworks/react-native-freshdesk-sdk

中文文档
2.1.0发布于 2026/10/01MITTypeScriptESM + CJS零依赖近 30 天下载 2385

React Native wrapper for Freshdesk Android and iOS SDKs

原始使用文档
文档目录24 节
  1. Features
  2. Requirements
  3. Installation
  4. iOS
  5. Android
  6. Documentation
  7. Initialization
  8. Launch the support experience
  9. Unread count
  10. User and ticket properties
  11. JWT authentication
  12. Reset user
  13. Tracking user events
  14. Content configuration / localisation
  15. Custom link handler
  16. Events and cleanup
  17. Push notifications
  18. SDK information
  19. Diagnostics
  20. AI Integration Kit
  21. Error handling
  22. Full documentation
  23. License
  24. Support

Freshdesk React Native SDK

"Modern ticketing software that your sales and customer engagement teams will love." React Native wrapper for the native Freshdesk iOS and Android SDKs — customer support, live chat, and knowledge base for your React Native app.

Features

  • Live chat and support home
  • Knowledge base / FAQ
  • Open a specific topic
  • Unread message count (one-shot and real-time)
  • User and ticket properties
  • JWT user authentication
  • User event tracking
  • Content configuration / localisation
  • Custom link handling
  • Push notifications (configured natively in the host app)

Requirements

  • React Native >= 0.75 (peerDependencies.react-native is >=0.75.0). On RN < 0.75, stay on ~1.4.3 — that is where 1.4.x already sat in practice.
  • New Architecture supported. The module is backward-compatible: a TurboModule when the New Architecture is enabled, the classic bridge module otherwise. No JavaScript API or code changes are required either way.
  • iOS 15.0+ — the native SDK ships as a vendored FreshdeskSDK.xcframework (no Swift Package Manager / use_frameworks! requirement).
  • Android API 26+ (minSdkVersion 26, compileSdkVersion 35, Android Gradle Plugin 8.6+)
  • CocoaPods 1.12+ (iOS)

Upgrading from 1.4.x? See MIGRATION.md — the iOS Podfile / Gemfile changes are the main step.

A handful of methods (resetUser, enableDebugLogs, getUnreadCount) behave slightly differently on Android vs iOS because the two native SDKs don't expose the same capability — see PLATFORM_DIFFERENCES.md before relying on their exact runtime behavior.

Installation

npm install @freshworks/react-native-freshdesk-sdk
# or
yarn add @freshworks/react-native-freshdesk-sdk

The library uses autolinking — no manual linking is required for React Native 0.60+.

iOS

Set the deployment target in your Podfile and install pods — no use_frameworks! is required (the native SDK ships as a vendored xcframework and the podspec builds it as a static framework):

platform :ios, '15.0'
cd ios && pod install

Keep use_frameworks! only if your other dependencies need it — prefer :linkage => :static. Upgrading from 1.4.x? The 1.4.x Podfile / Gemfile needs the SPM lines removed first — see MIGRATION.md.

The full guide (deployment-target pinning, embedding the framework in your app bundle, push notification setup, and troubleshooting) ships with the package — see docs/integration/installation.md (i.e. node_modules/@freshworks/react-native-freshdesk-sdk/docs/integration/installation.md once installed), or browse it without installing at unpkg.com/browse/@freshworks/react-native-freshdesk-sdk/docs/integration/installation.md.

Android

Ensure mavenCentral() is in your repositories and minSdkVersion is 26+. The native dependency (com.freshworks.sdk:freshdesk) is included automatically.

allprojects {
  repositories {
    google()
    mavenCentral()
  }
}

Documentation

You get your credentials from the Freshdesk portal: Admin Settings → Mobile Chat SDK → your SDK (token, host, sdkId). For JWT-enforced SDKs you also need a per-user jwt.

Initialization

Initialize once, as early as possible in your app lifecycle. All other methods require initialization first.

Required: token, host, and sdkId from the Freshdesk portal. Optional: locale, jwt (JWT-enforced widgets only), debugMode (Android). Push notification setup (Firebase, APNs, portal push keys) is not part of initialization — the SDK works for in-app support without push; configure push separately when you need tray notifications.

The wrapper sets hostPlatform to reactnative internally for SDK telemetry headers (x-fd-mobile-sdk); apps do not pass or configure this.

import FreshdeskSDK from '@freshworks/react-native-freshdesk-sdk';

await FreshdeskSDK.initialize({
  token: 'your-account-token',
  host: 'your-host.freshdesk.com',
  sdkId: 'your-sdk-id',
  locale: 'en',        // optional, default 'en' (applied at init only)
  jwt: 'your-jwt',     // required only for JWT-enforced SDKs
  debugMode: false,    // optional, Android only
});

Push notifications are optional. For push, the SDK must also be initialized natively at app startup because the device token arrives before the JS layer runs. See Push notifications. In-app support works without push wiring.

Launch the support experience

// Support home
await FreshdeskSDK.openSupport();

// Knowledge base / FAQ
await FreshdeskSDK.openKnowledgeBase();

// A specific topic (topicId is optional)
await FreshdeskSDK.openTopic({ topicName: 'Orders', topicId: '12345' });

// Dismiss any open Freshdesk view
await FreshdeskSDK.dismiss();

Unread count

// One-shot value
const count = await FreshdeskSDK.getUnreadCount();

// Real-time updates
const sub = FreshdeskSDK.addUnreadCountListener((event) => {
  console.log('Unread count:', event.count);
});

// Clean up when done
sub?.remove();

User and ticket properties

For non-JWT-enforced SDKs, set user properties after initialization. (Properties must be whitelisted under the linked widget's Contact/Ticket fields.)

await FreshdeskSDK.setUserProperties({
  name: 'Jane Doe',
  email: '[email protected]',
  phone: '+1234567890',
});

await FreshdeskSDK.setTicketProperties({
  subject: 'Product Enquiry',
  priority: 3,
});

// Read current user
const user = await FreshdeskSDK.getUser();

For JWT-enforced SDKs, user properties are updated through the JWT payload — see below.

JWT authentication

Freshdesk uses JSON Web Tokens to allow only authenticated users to start a conversation.

  1. Pass the jwt during initialize() (mandatory for JWT-enforced SDKs).
  2. Listen for user state changes.
  3. Update/refresh the token with authenticateAndUpdate.
const sub = FreshdeskSDK.addUserStateListener((event) => {
  // States: 'authenticated', 'authExpired', 'notAuthenticated',
  //         'identifierUpdated', 'jwtNotPresent', 'undefined'
  console.log('User state:', event.state);
});

// Refresh or update the user with a new JWT (also updates user/ticket properties from payload)
await FreshdeskSDK.authenticateAndUpdate('new-jwt-token');

Reset user

Call on logout (or before switching accounts) to clear the user's session and data.

const result = await FreshdeskSDK.resetUser();
// { success: boolean; message?: string; error?: string }

Tracking user events

Track events to use as engagement context, triggered messages, or segmentation.

await FreshdeskSDK.trackEvent('add_to_cart', { productId: '12345', quantity: 2 });

Content configuration / localisation

Override static widget text (headers, placeholders, ticket form, privacy policy, response-time copy). Any field you omit keeps the widget default; pass {} to reset to defaults. Changes persist and take effect immediately.

await FreshdeskSDK.setContentConfiguration({
  headers: {
    chat: 'Talk to our team',
    faq: 'Help Centre',
    ticketForm: { title: 'Raise a ticket', submitBtnTitle: 'Submit' },
  },
  placeholders: {
    replyField: 'Type your reply...',
    searchField: 'Search articles...',
  },
  privacyPolicySetting: {
    privacyPolicyMessage: 'We respect your privacy',
    privacyPolicyLinkText: 'Privacy Policy',
    privacyPolicyLink: 'https://example.com/privacy',
  },
});

Take control of links pressed inside the SDK (e.g. deep links).

import { Linking } from 'react-native';

const sub = FreshdeskSDK.setLinkHandler((event) => {
  if (event.url.startsWith('myapp://')) {
    // handle deep link
    return;
  }
  Linking.openURL(event.url);
});

sub?.remove();

Events and cleanup

import FreshdeskSDK, { FreshdeskEvents } from '@freshworks/react-native-freshdesk-sdk';

FreshdeskSDK.addUnreadCountListener(/* ... */);
FreshdeskSDK.addUserStateListener(/* ... */);
FreshdeskSDK.addUserCreatedListener(/* ... */); // iOS only

// Remove every listener (e.g. on unmount)
FreshdeskSDK.removeAllListeners();

// Event name constants
FreshdeskEvents.UNREAD_COUNT_CHANGED; // 'unreadCountChanged'
FreshdeskEvents.USER_STATE_CHANGED;   // 'userStateChanged'
FreshdeskEvents.USER_CREATED;         // 'userCreated'
FreshdeskEvents.ON_LINK_PRESSED;      // 'onLinkPressed'

Push notifications

Push is handled natively — there is no JavaScript push API. The host app must initialize the SDK natively at startup and forward the device token / incoming messages:

  • iOS — APNs .p8 auth key, Push Notifications + Background Modes capabilities, and native init in AppDelegate.
  • Android — Firebase (google-services.json), the Google Services plugin, and native init in MainApplication.onCreate() plus a FirebaseMessagingService.

The sample app in the SDK's source repository is the reference wiring (Freshworks GitHub access required: sample_app). Full steps ship with the package — see docs/integration/installation.md#push-notifications, or browse it at unpkg.com/browse/@freshworks/react-native-freshdesk-sdk/docs/integration/installation.md.

SDK information

const version = await FreshdeskSDK.getSDKVersion();

Diagnostics

Verify or debug your integration:

await FreshdeskSDK.enableDebugLogs(true);
const report = await FreshdeskSDK.runDiagnostics();
console.log(report.prettyPrinted);

On iOS this runs native structured diagnostics (FreshdeskSDK 1.3+). On Android the wrapper returns integration checks until native diagnostics parity lands — use debugMode: true and Logcat for deeper signal.

AI Integration Kit

The npm package ships an AI Integration Kit that teaches coding agents (Cursor, Claude, Copilot, Codex, Kiro) how to integrate and debug the SDK in your React Native app.

After install:

cp -R node_modules/@freshworks/react-native-freshdesk-sdk/ai-integration-kit/. /path/to/your-app/

Then ask your AI tool: "Use the freshdesk-react-native-integration skill and wire up Freshdesk support."

Canonical skill (for SDK maintainers): ai-integration-kit/ai/skills/freshdesk-react-native-integration/SKILL.md. Regenerate tool copies with npm run sync:ai-kit.

The full tool mapping and usage guide ships with the package — see ai-integration-kit/README.md (i.e. node_modules/@freshworks/react-native-freshdesk-sdk/ai-integration-kit/README.md once installed), or browse it without installing at unpkg.com/browse/@freshworks/react-native-freshdesk-sdk/ai-integration-kit/README.md.

Error handling

All methods return promises. Common error codes:

CodeMeaning
FRESHDESK_INVALID_CONFIGMissing token / host / sdkId
FRESHDESK_NOT_INITIALIZEDA method was called before initialize()
FRESHDESK_INIT_ERRORInitialization failed (credentials/network)
FRESHDESK_NO_ACTIVITY / FRESHDESK_NO_VIEW_CONTROLLERApp not foregrounded
FRESHDESK_AUTH_ERRORJWT authentication failed

Full documentation

These guides ship with the package under docs/integration/ (i.e. node_modules/@freshworks/react-native-freshdesk-sdk/docs/integration/ once installed). You can also browse them without installing, via unpkg:

License

MIT

Support

版本与发布记录

@freshworks/react-native-freshdesk-sdk 共发布 13 个版本,首次发布于 2026/07/04;过去 12 个月发布了 13 个版本。

版本发布日期距今
2.1.0latest2026/10/011 个月前
2.0.12026/09/082 个月前
2.0.02026/09/052 个月前
1.4.32026/08/262 个月前
1.4.22026/08/262 个月前
1.3.02026/08/093 个月前

关于 @freshworks/react-native-freshdesk-sdk 的常见问题

@freshworks/react-native-freshdesk-sdk 是什么?

React Native wrapper for Freshdesk Android and iOS SDKs

如何安装 @freshworks/react-native-freshdesk-sdk?

在项目目录运行 npm install @freshworks/react-native-freshdesk-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(>=0.75.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@freshworks/react-native-freshdesk-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@freshworks/react-native-freshdesk-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@freshworks/react-native-freshdesk-sdk 可以商用吗?

@freshworks/react-native-freshdesk-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@freshworks/react-native-freshdesk-sdk 的下载量有多少?

根据 npm 官方下载统计,@freshworks/react-native-freshdesk-sdk 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,385 次,日均约 80 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@freshworks/react-native-freshdesk-sdk 还在维护吗?

最新版本 2.1.0 发布于 2026/10/01(1 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/07/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。