【发布时间】:2019-11-06 22:55:21
【问题描述】:
我正在创建我的科尔多瓦应用程序,点击移动应用程序中的默认后退按钮时,它应该显示一个烤面包机通知“再次点击以退出应用程序”,然后再次点击后退按钮它应该退出应用程序。
我尝试了一些代码,但似乎没有一个代码在应用程序中起作用。
window.plugins.toast.showWithOptions(
{
message: "Tap again to exit the app",
duration: 1500, // ms
position: "bottom",
addPixelsY: -40, // (optional) added a negative value to move it up a bit (default 0)
data: {'foo':'bar'} // (optional) pass in a JSON object here (it will be sent back in the success callback below)
},
// implement the success callback
function(result) {
if (result && result.event) {
console.log("The toast was tapped or got hidden, see the value of result.event");
console.log("Event: " + result.event); // "touch" when the toast was touched by the user or "hide" when the toast geot hidden
console.log("Message: " + result.message); // will be equal to the message you passed in
console.log("data.foo: " + result.data.foo); // .. retrieve passed in data here
if (result.event === 'hide') {
console.log("The toast has been shown");
}
}
}
);
预期结果:单击移动应用程序中的默认返回按钮时,应显示“Tap again to exit the app”的烤面包机通知,然后再次单击返回按钮应退出应用程序。
实际结果:没有显示任何 toast 通知消息。
【问题讨论】:
标签: android jquery cordova toast back-button