Worklight/Cordova が Android アプリで初期化されるたびに cordovaInitCallback が呼び出されることに気付きました。具体的には、Cordova の「clearHistory」を呼び出して、WebView の履歴を消去します。ページからページへの初期化中に履歴が常にリセットされるため、複数ページのアプリで window.history を使用しようとすると、これが問題になります。
コメントは、この clearHistory 呼び出しの目的は、直接更新シナリオで古いページに戻るのを防ぐことであると示唆しているため、直接更新が行われた場合にのみ呼び出されるように、Android 環境チェックで条件を強化できますか? ? たとえば、私が考えることができる 1 つのケースは、connectOnStartup=false の場合で、直接更新は行われません。
wlclient.js:
var cordovaInitCallback = function(returnedData) {
onEnvInit(options);
if (WL.Client.getEnvironment() == WL.Env.ANDROID) {
if (returnedData !== null && returnedData !== "") {
WL.StaticAppProps.APP_VERSION = returnedData;
}
// In development mode, the application has a settings
// widget in which the user may alter
// the application's root url
// and here the application reads this url, and replaces the
// static prop
// WL.StaticAppProps.WORKLIGHT_ROOT_URL
// __setWLServerAddress for iOS is called within
// wlgap.ios.js's wlCheckReachability
// function because it is an asynchronous call.
// Only in Android we should clear the history of the
// WebView, otherwise when user will
// press the back button after upgrade he will return to the
// html page before the upgrade
if (**WL.Env.ANDROID == getEnv()**) {
cordova.exec(null, null, 'Utils', 'clearHistory', []);
}
}
私は現在 Worklight 5.0.5 を使用しており、これと同じ状態が 5.0.5.1 にも存在することを確認しました。
ありがとう!