cometchat-react-native-push
Push notifications for CometChat in React Native — FCM on Android, APNs on iOS, registering the device token with CometChatNotifications, and why none of it can be verified without a real device. Triggers: CometChat push notifications React Native, FCM CometChat RN, APNs chat notifications, notifications not arriving React Native, VoIP call push RN.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- cometchat-react-native-push
- license
- MIT
- metadata
- { "tags": "chat cometchat react-native push notifications fcm apns voip token", "author": "CometChat", "version": "1.0.0" }
- description
- Push notifications for CometChat in React Native — FCM on Android, APNs on iOS, registering the device token with CometChatNotifications, and why none of it can be verified without a real device. Triggers: CometChat push notifications React Native, FCM CometChat RN, APNs chat notifications, notifications not arriving React Native, VoIP call push RN.
- compatibility
- React Native >=0.77; @cometchat/chat-sdk-react-native ^4.0.28; @react-native-firebase/messaging
03 SKILL.md 正文
Ground truth:
@cometchat/chat-sdk-react-native@4+ catalogrn-sdk-v4.json+features.rn-v5.json→push-notifications. Docs:/notifications/react-native-push-notifications-android·...-ios. This skill is docs-first — fetch the current setup steps; do not bake a Firebase tutorial.
Companion skills (read first)
cometchat-react-native-core— install, provider chain, init→login→render. Assumed, not repeated here.
Use this skill when
- "add push notifications" · "notifications aren't arriving" · "VoIP call push" · "register the FCM token"
Prerequisites & install
Push is not web push. There is no service worker. React Native uses the OS transports:
| Platform | Transport | Needs |
|---|---|---|
| Android | FCM | google-services.json in android/app/ |
| iOS | FCM (via Firebase → APNs) | GoogleService-Info.plist, an APNs key uploaded to the dashboard, Push capability in Xcode |
Enable Push Notifications in the CometChat dashboard first and add the provider for the right
platform. With @react-native-firebase/messaging, both Android and iOS use the FCM provider —
Firebase relays to APNs on iOS and hands your app an FCM token, so you register it with CometChat as an
FCM platform (see below). A raw-APNs (APNS_REACT_NATIVE_*) provider is only for a hand-rolled PushKit /
native-APNs setup that skips Firebase.
The wiring — three steps, in this order
init()→login()must have completed. A token registered before login belongs to nobody.- Get the device token from your messaging library (typically
@react-native-firebase/messaging). - Register it with CometChat:
CometChatNotifications.registerPushToken(token, CometChatNotifications.PushPlatforms.FCM_REACT_NATIVE_ANDROID, providerId)
Platform constants match the token you actually hold. Because the Firebase library above yields an
FCM token on both platforms, use PushPlatforms.FCM_REACT_NATIVE_ANDROID on Android and
PushPlatforms.FCM_REACT_NATIVE_IOS on iOS (verified in @cometchat/chat-sdk-react-native CometChat.d.ts).
The APNS_REACT_NATIVE_DEVICE / APNS_REACT_NATIVE_VOIP constants are ONLY for a raw APNs device/VoIP
token from a hand-rolled PushKit setup — do not use them with a Firebase FCM token. Fetch the exact
argument order from the docs page for that platform. CometChatNotifications, registerPushToken,
unregisterPushToken and PushPlatforms are all verified present in catalogs/rn-sdk-v4.json.
- Unregister on logout —
unregisterPushToken(). Skipping this is why a shared or re-used device keeps delivering the previous user's notifications.
Token refresh is not optional
Device tokens rotate. Subscribe to your messaging library's token-refresh event and re-register, or push silently stops working days later for a subset of users — the hardest push bug to diagnose because nothing fails at the time.
VoIP / call notifications
Calls need a data-only push plus a native dialer integration (CallKeep) so the device rings while
the app is killed. That is a materially bigger build than message push, with its own iOS entitlements.
Fetch /notifications/react-native-push-notifications-android and ...-ios and follow them — do not
improvise it.
Why this cannot be smoke-tested
Push requires a real device (or an emulator image with Play services for FCM), real credentials,
and the app in background or killed. It cannot be verified headlessly, in CI, or on an iOS simulator.
features.rn-v5.json marks it accordingly — treat a "works" claim without device evidence as unproven.
Common pitfalls
- Registering before login — the token is attached to no user.
- Not unregistering on logout — the next user gets the previous user's pushes.
- Ignoring token refresh — push dies quietly, later.
- Wrong platform constant — registration succeeds, delivery never happens.
- Missing
google-services.json/GoogleService-Info.plist— build or registration failure. - Testing on an iOS simulator — APNs does not work there.
- Expecting message-push setup to cover calls — VoIP needs data-only push + CallKeep.
Verify it works
- Every emitted symbol is in
catalogs/rn-sdk-v4.json. - Dashboard: push enabled, correct provider added for the platform.
- On a real device: notification arrives with the app backgrounded and killed; tapping it opens the right conversation; after logout the device stops receiving that user's notifications.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.