Skip to content

feat(MBL-2666): hand Customer.io silent pushes to a JavaScript handler - #698

Merged
Shahroz16 merged 5 commits into
mainfrom
claude/silent-push-7f4c1d
Nov 11, 2026
Merged

Shahroz16 merged 5 commits into
mainfrom
claude/silent-push-7f4c1d

Conversation

@Shahroz16

@Shahroz16 Shahroz16 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Apps can now handle Customer.io silent pushes in JavaScript (MBL-2666). CustomerIO.pushMessaging.setBackgroundPushHandler takes a handler at startup in index.js, and the handler gets { deliveryId, data, deliveryToken } for each silent push while the app is in the foreground, in the background, or after the push starts an app that wasn't running. The native SDKs record Delivered themselves, so the handler only deals with the app's data, and an app that never calls it keeps today's behavior.

On Android, a ContentProvider sets the native fallback callback from customerio/customerio-android#975 at process start, so a push that starts a killed app reaches the wrapper before JavaScript runs. Each push runs in a WorkManager job that starts React Native if needed, waits for JavaScript to register, and runs the handler as a Headless JS task, which also keeps JavaScript timers running in the background. The job is there because Android won't let a background app start a service for a normal-priority message, which is what React Native Firebase relies on. On iOS, the wrapper sets the wrapperBackgroundPushHandler hook from customerio/customerio-ios#1388 at process start, so CioAppDelegateWrapper hands it each silent push after saving Delivered. The push reaches JavaScript through a TurboModule event like our other native events, and the completion handler runs when the handler settles (.newData) or after 25 seconds (.noData). App delegates without the wrapper can call NativeMessagingPush.handleBackgroundPush, which Expo's template will use.

Both platforms take a push only after JavaScript has set a handler. That opt-in is saved, so it also covers a push that starts the app after an update, and it turns off when JavaScript calls remove() or when a push finds no handler within 25 seconds. Pushes a React instance didn't finish before a reload go to the next instance. docs/silent-push.md covers both setups (the Customer.io SDK owning push, and React Native Firebase), and the example app sets a handler that logs.

Jest (42 tests, 7 for the handler), TypeScript, ESLint and API Extractor pass. I built the example against customerio/customerio-android#975 at bf8ab8db from mavenLocal and customerio/customerio-ios#1388 at 74f25694 as local pods. On an API 35 emulator with fake FCM broadcasts through Firebase's receiver, a push with no saved opt-in recorded Delivered without starting React Native. Once the app had set the handler, foreground, idle background and killed pushes all ran it, including two back-to-back pushes into a killed app and a push right after an app update, before the app was opened. A setTimeout in the handler fired each time and nothing was shown. After installing a version without the handler, the first push started React Native, ended at 25 seconds and turned the opt-in off, and the next one only recorded Delivered. On an iOS 26.5 simulator, calling the app delegate the way UIKit does, a fresh install passed the push to the app delegate as before. Once JavaScript had set the handler, pushes at launch before React Native started, in the foreground and in the background reached it and completed .newData, and the helper returned false for a payload without the delivery ID. I couldn't test real FCM or APNs delivery, a real APNs background launch, the iOS timeout and reload paths, or the Android reload path.

This pins iOS = 5.2.1 and Android 5.1.1, the latest native releases. Silent push shipped in iOS 5.2.0 (customerio/customerio-ios#1388) and Android 5.1.0 (customerio/customerio-android#975), but CocoaPods never got the CustomerIO 5.2.0 pod, and the patch releases only change the push_enabled refresh in DataPipelines.

🤖 Generated with Claude Code

Shahroz16 and others added 3 commits November 9, 2026 19:57
`CustomerIO.pushMessaging.setBackgroundPushHandler` receives each silent
push as `{ deliveryId, data, deliveryToken }`, and the SDK waits up to
25 seconds for it.

Android: a ContentProvider sets the native fallback callback at process
start. A push runs in a WorkManager job that starts React Native if
needed, waits for JavaScript to register, and runs the handler as a
Headless JS task. iOS: a hook that CioAppDelegateWrapper calls hands the
push to JavaScript through a TurboModule event, and
`NativeMessagingPush.handleBackgroundPush` does the same for app
delegates without the wrapper.

Both platforms take a push only after JavaScript has set a handler, so
other apps see no change. That opt-in lasts across app updates until
JavaScript removes the handler or a push finds none within 25 seconds.
Pushes a React instance didn't finish before a reload go to the next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Shahroz16
Shahroz16 requested a review from a team as a code owner November 10, 2026 04:23
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


Builds are in progress. This comment will be updated when they finish.

  • Android APN: 698.5.0 (29906986)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 359cfd4. Configure here.

CocoaPods never published the CustomerIO 5.2.0 umbrella pod (trunk timed out
mid-release), so iOS = 5.2.0 can never resolve. 5.2.1 and 5.1.1 are the
latest releases and only change push_enabled refresh in DataPipelines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
case .unsupported:
completionHandler(.noData)
return true
case .received(let push):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes every Customer.io silent push even when JS never set a handler, so the app holds the completion for 25s and its other handlers never see the push. Check CustomerIOReactNativeBackgroundPushRouter.isHandlerExpected first and return false, like the wrapper hook above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in 64b2fe1. The helper still lets the native SDK record Delivered first, then returns false until JavaScript has set a handler, same as the wrapper hook.

Comment thread docs/silent-push.md Outdated

On Android, `onMessageReceived` and `onBackgroundMessageReceived` show nothing for a silent push, track Delivered
and resolve `true`. React Native Firebase runs `setBackgroundMessageHandler` by starting a service, which Android 8
and later refuse for a normal-priority message once the app has been in the background for about a minute; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android's background limits doc gives this window as several minutes, not about a minute. Suggest "for a few minutes".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed to "a few minutes" in 64b2fe1.

…handler

`NativeMessagingPush.handleBackgroundPush` now returns false when
JavaScript has never set a handler, like the CioAppDelegateWrapper hook,
so an app delegate without the wrapper keeps the push and its completion
handler. The native call still runs first, so Delivered is recorded.

Also say React Native Firebase's background service limit applies after
a few minutes in the background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Shahroz16
Shahroz16 merged commit df61523 into main Nov 11, 2026
23 checks passed
@Shahroz16
Shahroz16 deleted the claude/silent-push-7f4c1d branch November 11, 2026 18:04
cio-mobile-release Bot pushed a commit that referenced this pull request Nov 11, 2026
## [7.3.0](7.2.1...7.3.0) (2026-11-11)

### Features

* **MBL-2666:** hand Customer.io silent pushes to a JavaScript handler ([#698](#698)) ([df61523](df61523))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants