私は自分のアプリでIonicを使用しましたが、物理バックボタンを押すと、最後の状態に戻るのではなく、アプリケーションを終了する必要があります。
私は$ionicPlatform.registerBackButtonAction
イベントを聞いて実行しません。
app.js
app.run(function ($rootScope, $cordovaToast, $ionicPlatform, $state, $cordovaKeyboard) {
var deregister;
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
console.info('天啦噜,你终于执行了')
if ($state.current.name == "tab.discover") {
console.info('哈哈,要退出了')
navigator.app.exitApp();
}
else {
console.info('哈哈,要返回了')
navigator.app.backHistory();
}
}, 101);
})。そのそれは、より正確にするために代わり==
の3 ===
を使用すべきかどうかを確認するには
「ionic serve」ではこれが機能しますか?つまり、問題は本当にアンドロイド特有ですか? –