MaximBelov / cordova-plugin-restart

1 stars 2 forks source link

Android: No errors, but no restart either #2

Open RolfDohrmann opened 1 year ago

RolfDohrmann commented 1 year ago

Hello,

Expected behaviour: The app closes and will be restarted again. Actual behaviour: The app closes.

Context:

I need to restart my app programatically and found your plugin, which seems to do exactly what I need.

My app is based on Angular / Ionic / Capacitor. My test device is a Samsung A50, Android 11

I installed the plugin

npm install cordova-plugin-restart

and the ionic wrapper

npm install ionic-native-restart

In a simple home.page.ts I have this code:

import { Restart } from "ionic-native-restart";

and

Restart.enableDebug().then( res => {
    console.log('restart debug: ', res);
});

Restart.restart(true);

The build in Android Studio works fine, the app starts without errors.

When running the above code the app disappears from the screen. It seems it wont restart. At least it is not shown on the display again.

This is what the logcat says:

2023-02-03 10:36:26.690 23264-26609/io.ionic.starter I/RestartPlugin: Cold restarting application
2023-02-03 10:36:26.705 23264-23264/io.ionic.starter I/Capacitor/Console: File:  - Line 1 - Msg: RestartPlugin[native]: Debug enabled
2023-02-03 10:36:26.709 23264-26609/io.ionic.starter I/RestartPlugin: Killing application for cold restart
2023-02-03 10:36:26.712 23264-26609/io.ionic.starter I/o.ionic.starte: System.exit called, status: 0

Am I doing something wrong?

MaximBelov commented 1 year ago

Hi

I don't use this plugin anymore. It doesn't have ios support(no solution). Codepush plugin as example:

Android https://github.com/microsoft/cordova-plugin-code-push/blob/05958131e9c50630cc8591c74d7d0c34d5ffa3dd/src/android/CodePush.java#L364

Ios

https://github.com/microsoft/cordova-plugin-code-push/blob/05958131e9c50630cc8591c74d7d0c34d5ffa3dd/src/ios/CodePush.m#L236

I propose a simple solution for restart

window.location.href = '/';