Skip to content

Add <CodePushProvider> - #107

Merged
ofalvai merged 1 commit into
masterfrom
add-code-push-provider
Nov 6, 2026
Merged

ofalvai merged 1 commit into
masterfrom
add-code-push-provider

Conversation

@ofalvai

@ofalvai ofalvai commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Background

Today an app integrates CodePush by wrapping its root in the codePush() HOC, or by calling sync() from a useEffect. Both leave the user to get things right on its own:

  • notifyAppReady() has to run for every launch of a new bundle. If it doesn't, native code rolls the update back on the next start.
  • Failures of the update work have to be caught. Today they surface as unhandled promise rejections.

Change

Adds <CodePushProvider>, a component that owns both for the app. On mount, it runs sync() with its props, or only notifyAppReady() with checkFrequency={MANUAL}. It can check again each time the app resumes, and it hands every failure to an onError prop instead of rejecting.

Example use:

export default function App() {
  return (
    <CodePushProvider
      installMode={codePush.InstallMode.ON_NEXT_RESUME}
      onError={(error) => Sentry.captureException(error)}
    >
      <RootNavigator />
    </CodePushProvider>
  );
}

The logic is a React-free controller in src/app-lifecycle with unit tests. The component itself is a thin wrapper.

Decisions

Smaller changes pulled in

  • Adds react as a peer dependency (should have been done already)
  • logging.js moves to src/logging.ts, so the acquisition SDK can use the shared logger instead of console.
  • sync() ignores options set to undefined, so <CodePushProvider installMode={undefined}> doesn't override the defaults.
  • notifyAppReady() logs its failure before rethrowing.
  • The updateNotifyApplicationReady E2E scenario keeps its update through the new component instead of a direct notifyAppReady() call.

🤖 Generated with Claude Code

@ofalvai ofalvai self-assigned this Nov 4, 2026
Base automatically changed from retry-notify-application-ready to master November 5, 2026 09:31
A component for the app root that starts CodePush on mount: it runs sync()
with its props, or only notifyAppReady() with checkFrequency MANUAL. It can
check again on each resume, and reports every failure to onError.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ofalvai
ofalvai force-pushed the add-code-push-provider branch from ab1a3fd to e893f23 Compare November 6, 2026 07:33
Copilot AI balanced review requested due to automatic review settings November 6, 2026 07:33

Copilot AI 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.

🟡 Changes recommended

A failed status-report fetch can cause native acknowledgement to be retried, clearing a not-yet-running update’s pending marker and rollback protection.

2 open issues
What changed in this PR

Adds CodePushProvider as the recommended app-root integration for CodePush, building on #106’s retryable readiness notification to manage startup, resume checks, and error reporting.

Changes:

  • Adds a typed React provider backed by a React-free lifecycle controller and unit tests.
  • Integrates provider exports, preserves sync defaults for undefined options, and moves logging into TypeScript.
  • Documents provider usage and updates the readiness E2E scenario to use it.
File Description
typings/​react-native-code-push.d.ts Declares the provider and its public props.
tsconfig.json Enables TSX compilation and JSX typing.
test/​template/​scenarios/​updateNotifyApplicationReady.js Uses the provider to acknowledge updates.
test/​template/​index.js Allows scenarios to wrap the test app.
src/​react/​code-push-provider.tsx Implements the thin React lifecycle wrapper.
src/​logging.ts Moves shared logging utilities into TypeScript.
src/​app-lifecycle/​app-lifecycle.ts Controls startup, resume checks, and error callbacks.
src/​app-lifecycle/​__tests__/​app-lifecycle.test.ts Tests lifecycle modes, retries, cleanup, and prop changes.
src/​acquisition-sdk/​acquisition-sdk.ts Adopts the shared logger.
package.json Adds React dependencies and TSX lint coverage.
package-lock.json Records dependency changes.
eslint.config.mjs Includes TSX source files in linting.
docs/​api-js.md Documents the provider as the recommended integration.
CodePush.js Exports the provider, preserves option defaults, and logs readiness failures.

Review effort: Balanced

Comment thread CodePush.js Resolved
Comment thread src/app-lifecycle/app-lifecycle.ts Resolved
@ofalvai
ofalvai merged commit 1c28105 into master Nov 6, 2026
7 checks passed
@ofalvai
ofalvai deleted the add-code-push-provider branch November 6, 2026 09:55
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.

3 participants