Skip to content

feat: expose native configuration and check-and-update APIs on all platforms - #641

Merged
sunnylqm merged 24 commits into
masterfrom
feat/native-host-update-api
Sep 19, 2026
Merged

sunnylqm merged 24 commits into
masterfrom
feat/native-host-update-api

Conversation

@sunnylqm

@sunnylqm sunnylqm commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Expose a complete native-host entry path on Android, iOS and HarmonyOS: configure without JS → normal launch bundle resolution → check and download. Native configuration no longer depends on a successful previous JS startup.

Companion user documentation: reactnativecn/pushy-site#38

Public APIs

  • Android: PushyNativeUpdate.configure(Context, JSONObject, ConfigurationCallback) and checkAndUpdate(Context, Callback). Both callbacks are delivered on the main thread; configuration returns a nullable error.
  • iOS: +[RCTPushy configure:completion:] and +[RCTPushy checkAndUpdateWithCompletion:]; Swift names are configure(_:completion:) and checkAndUpdate(completion:). Completions use the main queue.
  • Harmony: PushyFileJSBundleProvider.configure(NativeUpdateConfig): Promise<void> and checkAndUpdate(): Promise<NativeUpdateResult>; config/result types are exported from the HAR.

Configuration contract

  • appKey is required. Support optional endpoints, discovery URLs, afterDownload, disabled, packageVersion, and RN/SDK diagnostic version strings.
  • Omitted endpoints use Pushy's existing preset. Custom endpoints do not inherit public discovery URLs. Default afterDownload is none; choose setNeedUpdate to select normal downloads for the next launch.
  • Full replacement, not a partial merge. Validate and snapshot options before touching persisted state. Invalid options leave the previous configuration unchanged.
  • Configuration does not resolve bundles, perform network IO, show UI, or reload React Native. It can run before the bridge exists. Checks still require the application's real launch bundle resolution.
  • Create a stable installation UUID when native-first provisioning has no existing UUID, and preserve it on reconfiguration.
  • JS/native configuration use the same store. JS remains the compatible default owner; nativeConfigSource: 'native' from initial JS construction stops constructor/setOptions synchronization from overwriting the host's configuration. It does not automatically mirror config into JS or disable JS checks.
  • Configuration replacement invalidates native response cache and old in-flight/late-rescue commits under the existing state synchronization. Generations also catch A→B→A replacement. Config IO runs separately from the potentially long update worker.
  • Missing/disabled configuration before the delayed automatic check no longer consumes the process's only real round; later native provisioning can still start it.

Check contract

Start the native round now, share an in-flight round, or reuse its settled result. Preserve at most one real round per process, including failed rounds. Reconfiguration does not create another round after one has already run.

Results distinguish skipped/noUpdate/downloaded/failed/cancelled. activated means selected for the next launch, not an immediate reload. Reuse existing C++ decisions, download fallback/integrity checks, rollback guards and crash rescue. Public waiters do not consume the crash-rescue semaphore signal.

Verification

At commit 11de3d4499539a471018e381c85006ed591ee69e:

Temporary source-preparation helpers and workflows have been removed from the final diff. No package has been published and no physical-device validation is claimed. Consumers must rebuild the native app and, for source-based Harmony integration, the HAR.

Summary by CodeRabbit

  • New Features

    • Added native host APIs to configure and check for updates on Android, iOS, and HarmonyOS.
    • Update checks now return clear outcomes, including no update, download success, failure, cancellation, and activation status.
    • Added validated native configuration with endpoint customization and sensible defaults.
    • Added nativeConfigSource to choose whether JavaScript or native hosts manage configuration.
    • Concurrent update requests now share a single update operation.
  • Bug Fixes

    • Configuration changes invalidate stale update results and cached responses.
    • Invalid configurations are rejected before being saved.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3da3b31b-8b4a-4a8e-bdcf-31cafa09c473

📥 Commits

Reviewing files that changed from the base of the PR and between 97815ec and 11de3d4.

📒 Files selected for processing (23)
  • android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java
  • android/src/main/java/cn/reactnative/modules/update/NativeUpdateConfig.java
  • android/src/main/java/cn/reactnative/modules/update/NativeUpdateResult.java
  • android/src/main/java/cn/reactnative/modules/update/PushyNativeUpdate.java
  • android/src/main/java/cn/reactnative/modules/update/UpdateContext.java
  • android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java
  • harmony/pushy/index.ets
  • harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts
  • harmony/pushy/src/main/ets/NativeUpdateConfig.ts
  • harmony/pushy/src/main/ets/NativeUpdateResult.ts
  • harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets
  • harmony/pushy/src/main/ets/PushyTurboModule.ts
  • harmony/pushy/src/main/ets/UpdateContext.ts
  • ios/RCTPushy/RCTPushy.h
  • ios/RCTPushy/RCTPushy.mm
  • ios/RCTPushy/RCTPushyNativeConfig.h
  • ios/RCTPushy/RCTPushyNativeConfig.mm
  • src/NativePushy.ts
  • src/__tests__/nativeConfiguration.test.ts
  • src/__tests__/nativeHostApi.test.ts
  • src/__tests__/nativeUpdateRound.test.ts
  • src/client.ts
  • src/type.ts
 _____________________________________________________________________________________
< All idioms must be learned. Good idioms only need to be learned once. - Alan Cooper >
 -------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sunnylqm sunnylqm changed the title feat: expose native host check-and-update APIs on Android, iOS and Harmony feat: expose native configuration and check-and-update APIs on all platforms Sep 19, 2026
@sunnylqm
sunnylqm merged commit edf1588 into master Sep 19, 2026
11 of 12 checks passed

Copy link
Copy Markdown
Contributor Author

已合并并发布 react-native-update v10.57.0

使用原生新接口仍需重新构建并分发原生安装包,不能仅靠 JS 热更新启用。

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.

1 participant