NTP-47546 | Code Push Changes | Yash (#1121)
Co-authored-by: Aman Singh <aman.singh@navi.com>
This commit is contained in:
@@ -437,4 +437,27 @@ public class DeviceUtilsModule extends ReactContextBaseJavaModule {
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void restartApp(Promise promise) {
|
||||
try {
|
||||
Activity activity = getCurrentActivity();
|
||||
if (activity != null) {
|
||||
triggerRestart(activity);
|
||||
promise.resolve(true);
|
||||
} else {
|
||||
promise.reject("RESTART_ERROR", "Activity is null.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
promise.reject("RESTART_ERROR", "An unexpected error occurred: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerRestart(Activity context) {
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivity(intent);
|
||||
context.finish();
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.anrwatchdog.ANRWatchDog;
|
||||
import com.microsoft.codepush.react.CodePush;
|
||||
import com.navi.alfred.AlfredConfig;
|
||||
import com.navi.alfred.AlfredManager;
|
||||
import com.navi.alfred.network.AlfredApiLogsManager;
|
||||
@@ -45,6 +44,8 @@ import com.navi.pulse.PulseSDKConfig;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.otahotupdate.OtaHotUpdate;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class MainApplication extends Application implements ReactApplication, Ap
|
||||
|
||||
@Override
|
||||
protected String getJSBundleFile() {
|
||||
return CodePush.getJSBundleFile();
|
||||
return OtaHotUpdate.Companion.getBundleJS();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user