@appwin/react-native

中文文档
1.3.0发布于 2026/11/05SEE LICENSE IN LICENSETypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 1813

Appwin React Native SDK - Support, Community, Notifications, Analytics and Attribution, bridged to the native iOS and Android SDKs.

原始使用文档
文档目录9 节
  1. Install
  2. Products
  3. Quickstart
  4. Push (owns its stack)
  5. Crashes
  6. Session replay
  7. New Architecture
  8. Support
  9. Licence

@appwin/react-native

React Native bridge to the native Appwin SDKs. The community feed and the messenger are rendered natively (SwiftUI on iOS, Compose on Android); this layer carries identity, sessions and the entry points.

Full guide, per-product APIs and dashboard setup: https://appwin.io/docs/sdk/installation

Install

npm install @appwin/react-native
cd ios && pod install

Then rebuild: the native modules only exist in a recompiled binary.

Requirements: React Native 0.75 or later, iOS 16.0, Android API 24 (minSdk 24).

On iOS the bridge takes the native SDK from Swift Package Manager (https://github.com/appwin-dev/appwin-ios) through React Native's spm_dependency, not from CocoaPods trunk: pod install adds the package to the Pods project, nothing to add to your Podfile beyond the template's react_native_post_install. Its « static linking, this might cause linker errors » warning is expected and harmless for this package. Remove any pod 'AppwinCore' (or other Appwin… pod) from your Podfile: the two copies would collide.

Expo: Expo Go loads no third-party native module, so use a development build (npx expo run:ios / npx expo run:android, or EAS). The package ships no config plugin: the iOS AppDelegate line and the Android manifest change below go into the native projects that npx expo prebuild generates.

Products

AppwinCore carries identity and sessions for every product; the others are opt-in.

ProductExposesDocs
AppwinCoreConfigure, identity, events, consent, push token, availability. Required.appwin-core
AppwinSupportMessenger (embedded view or modal).support
AppwinCommunityFeed (embedded view or modal), profile, unread count, member events.community
AppwinNotificationsPush, in-app messages (AppwinPush routes the taps).notifications
AppwinAnalyticsSessions, screens, crashes, session replay.analytics
AppwinAttributionAcquisition attribution, ad consent.attribution

Quickstart

import { AppwinCore, AppwinSupport } from '@appwin/react-native'

await AppwinCore.configure({ projectAppId: 'your-app-id' })

const support = await AppwinSupport.initialize()
if (support.status === 'ready') {
  await AppwinSupport.presentMessenger()
}

configure covers every enabled product: they share the identity carried by Core. initialize() asks the server whether a product may open for this app and resolves rather than rejecting (ready | unavailable | notConfigured | unknown), so gate your own entry point on the answer. Identify before setting a community profile, otherwise it lands on the anonymous profile:

await AppwinCore.identify(user.id, { email: user.email, name: user.name })
await AppwinCore.updateUser({ plan: 'pro' })
await AppwinCommunity.setUser({ nickname: user.nickname })
await AppwinCore.logout()

identify and updateUser reject on failure. Every other call degrades to a neutral value instead (only a blank projectAppId or push token throws), so it needs no try/catch. Events go through Core, whatever the product:

await AppwinCore.track('purchase', { value: 9.99, currency: 'EUR' })

Screens can be embedded or presented modally:

import { AppwinCommunity, AppwinCommunityView } from '@appwin/react-native'

<AppwinCommunityView style={{ flex: 1 }} />       // embedded, no close button
await AppwinCommunity.presentCommunity()           // modal

See the Quickstart.

Push (owns its stack)

The SDK routes taps on Appwin pushes for you (cold start included). Call AppwinNotifications.start() once at startup, after configure. On iOS, add one line to your Swift AppDelegate so the launch tap is not missed before JavaScript runs:

import AppwinNotifications

func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
  AppwinNotifications.ensurePushNotificationDelegate()
  // ... React Native setup
}

On Android, push goes through Firebase: add your google-services.json, the com.google.gms.google-services Gradle plugin and com.google.firebase:firebase-messaging to your app (the SDK compiles against Firebase Messaging but does not bring it).

If your app owns its push stack (Firebase Messaging), forward each callback to AppwinPush and handle the message yourself only when the call resolves false:

import messaging from '@react-native-firebase/messaging'
import { AppwinNotifications, AppwinPush } from '@appwin/react-native'

// index.js, outside any component: runs headless on Android.
messaging().setBackgroundMessageHandler(async (message) => {
  await AppwinPush.handleMessage(message.data ?? {})
})

// At startup, after AppwinCore.configure().
await AppwinNotifications.start(true, { installsNotificationDelegate: false })

const initial = await messaging().getInitialNotification()
if (initial) await AppwinPush.handleTap(initial.data ?? {})
messaging().onNotificationOpenedApp((message) => {
  void AppwinPush.handleTap(message.data ?? {})
})

messaging().onMessage(async (message) => {
  const data = message.data ?? {}
  if (await AppwinPush.handleMessage(data)) return
  if (await AppwinPush.handleForeground(data, message.notification)) return
  // not Appwin's, or Appwin let you show it
})

On Android, remove the SDK's messaging service so Firebase delivers to yours, and forward each token rotation with messaging().onTokenRefresh((token) => AppwinCore.registerPushToken(token, 'android')):

<!-- android/app/src/main/AndroidManifest.xml, with xmlns:tools declared -->
<service
  android:name="io.appwin.notifications.AppwinFirebaseMessagingService"
  tools:node="remove" />

Crashes

AppwinAnalytics.initialize() also captures native crashes and uncaught JavaScript errors, with their stack, sent on the next launch. Handlers already installed (Sentry, Crashlytics, the red box) keep running: Appwin chains them.

await AppwinAnalytics.initialize()                          // crash reporting on
await AppwinAnalytics.initialize({ crashReporting: false }) // opt out

try {
  await checkout()
} catch (error) {
  AppwinAnalytics.recordError(error) // non-fatal issue
}

Unhandled promise rejections are captured on Hermes, in release builds only (in development React Native keeps them for its own warnings). Release stacks stay minified until sourcemap upload ships.

Session replay

When session replay is switched on in the dashboard, AppwinAnalytics.initialize() records a share of the sessions as video, natively, one frame per second, under the same consent as the events. Masking happens on the device, before encoding: text inputs always, texts and images unless the project settings say otherwise.

import { AppwinMask, AppwinUnmask } from '@appwin/react-native'

await AppwinAnalytics.initialize({ sessionReplay: false }) // never record this app

<AppwinMask>
  <Text>{user.iban}</Text>        {/* hidden, whatever the settings */}
</AppwinMask>
<AppwinUnmask>
  <Text>{product.title}</Text>    {/* shown even when all text is masked */}
</AppwinUnmask>

Both render as a plain View. Text inputs inside <AppwinUnmask> stay masked.

New Architecture

Modules and views work as-is on both architectures, through React Native's interop layer. The views are legacy view managers: from React Native 0.74 the interop layer picks them up on its own. Only on 0.73 with the New Architecture enabled, list AppwinCommunityView, AppwinSupportMessengerView, AppwinMaskView and AppwinUnmaskView under unstable_reactLegacyComponentNames (for ios and android) in your app's react-native.config.js.

Support

Bugs and questions: the issues of this repository. Anything tied to your account, billing or data goes through the support widget in your Appwin dashboard.

Licence

Proprietary, see LICENSE. This source is public for auditability and studio-side debugging, not for reuse.

版本与发布记录

@appwin/react-native 共发布 29 个版本,首次发布于 2026/08/31;过去 12 个月发布了 29 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.0latest2026/11/053 天前
1.2.02026/11/043 天前
1.1.02026/10/309 天前
1.0.02026/10/2613 天前
0.16.02026/10/2118 天前
0.15.02026/10/1920 天前

关于 @appwin/react-native 的常见问题

@appwin/react-native 是什么?

Appwin React Native SDK - Support, Community, Notifications, Analytics and Attribution, bridged to the native iOS and Android SDKs.

如何安装 @appwin/react-native?

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

@appwin/react-native 支持 TypeScript 吗?

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

@appwin/react-native 支持 ESM 还是 CommonJS?

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

@appwin/react-native 可以商用吗?

@appwin/react-native 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@appwin/react-native 的下载量有多少?

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

@appwin/react-native 还在维护吗?

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