Skip to content

[Android] Update with InstallMode.IMMEDIATE not applied until manual app restart #31

Closed

Description

@Abhishek-Appstn

on update it doesnot reflect the change code in the immediate boot, if i rebooot it manually it works, this issue is seen only in android
Environment
@code-push-next/react-native-code-push version: 1.2.0

react-native version: 0.81.1

code
useEffect(() => {
codePush.notifyAppReady();
}, []);

useEffect(() => {

    try {
        codePush.sync(
            {
                installMode: codePush.InstallMode.IMMEDIATE,
                deploymentKey: codePushKey
            },
            codePushStatusDidChange,
            codePushDownloadDidProgress
        );
    } catch (error) {
        console.warn('error', error);
    }

}, []);
const codePushStatusDidChange = (syncStatus: codePush.SyncStatus) => {

    switch (syncStatus) {
        case codePush.SyncStatus.CHECKING_FOR_UPDATE:
            setStatus('Checking for Updates');
            break;
        case codePush.SyncStatus.DOWNLOADING_PACKAGE:
            setStatus('Downloading Updates');
            break;
        case codePush.SyncStatus.INSTALLING_UPDATE:
            setStatus('Installing Updates');
            break;
        case codePush.SyncStatus.UP_TO_DATE:
            setStatus('Up to Date');
            setVisible(false);
            setTimeout(() => {
                dispatch(commonAction.showCodePush(true))
            }, 500);
            break;
        case codePush.SyncStatus.UPDATE_INSTALLED:
            setStatus('Update Installed');
               codePush.restartApp();
            break;
        case codePush.SyncStatus.UNKNOWN_ERROR:
        default:
            setStatus('');
            setVisible(false);
            dispatch(commonAction.showCodePush(true))
    }
};

const codePushDownloadDidProgress = (progress) => {
    setDownloadProgress(progress)
};

Activity

  1. Abhishek-Appstn commented on Sep 24, 2025

    @Abhishek-Appstn
    Author

    Android issue gets fixed when we use another package like react native restart, to force restart after update, codepush.restart() doesnt restart the android app

  2. CHOIMINSEOK commented on Oct 26, 2025

    @CHOIMINSEOK
    Collaborator

    Hi @Abhishek-Appstn sorry for late response

    We are working on adding support for rn 0.81, 0.82 :

    #32
    #33

    It will be fixed on next version!

  3. CHOIMINSEOK commented on Nov 1, 2025

    @CHOIMINSEOK
    Collaborator

    resolved at 10.3.0

  4. codeRa1n commented on Dec 8, 2025

    @codeRa1n

    I can confirm that even with 10.3.0 version this issue is not resolved on react native 0.80.2.

    here is the patch that i applied on CodePushNativeModule.java.

    replace getReactHostDelegate method at bottom of the file with below

    public ReactHostDelegate getReactHostDelegate(ReactHostImpl reactHostImpl) {
    Class<?> currentClass = reactHostImpl.getClass();

        // Traverse up the class hierarchy in case it's defined in a parent class
        while (currentClass != null) {
            // Get ALL fields in this class (public, private, protected)
            Field[] fields = currentClass.getDeclaredFields();
    
            for (Field field : fields) {
                try {
                    field.setAccessible(true);
                    Object value = field.get(reactHostImpl);
    
                    // Check if this field holds the object we are looking for
                    if (value instanceof ReactHostDelegate) {
                        return (ReactHostDelegate) value;
                    }
                } catch (Exception e) {
                    // Ignore access errors and keep looking
                }
            }
    
            // Move to the parent class
            currentClass = currentClass.getSuperclass();
        }
    
        CodePushUtils.log("Reflection failed: Could not find any field of type ReactHostDelegate in ReactHostImpl.");
        return null;
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions