ios - 手机间隙 : Calling an action when an app is opened after clicking the home button (iOS)

标签 ios events cordova onresume

我有一个正在调用我的服务器的应用程序。

当我按下主页按钮然后重新打开应用程序时,我希望它再次检查服务器。

我试过下面的代码,但 onResume 似乎甚至没有运行。

// Wait for device API libraries to load
//
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

// device APIs are available
//
function onDeviceReady() {
    document.addEventListener("resume", onResume, false);
}

// Handle the resume event
//
function onResume() {
    // Call to the server
}

最佳答案

我最终通过使用找到了成功

document.addEventListener("resume", function() {
    // Action when resumed
});

而且效果很好!

关于ios - 手机间隙 : Calling an action when an app is opened after clicking the home button (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27883937/

相关文章:

ios - 安装失败 'phonegap-plugin-push' : undefined CordovaError

ios - 是否可以从我的应用程序中删除 HealthKit 条目?

ios - 在手势识别器操作方法中更改 `SKNode` 是否安全?

ios - 在自定义键盘上键入时播放自定义声音

当 <option> 从 <select> 中添加或删除时的 jquery 事件

javascript - jquery如何使用<ul data-role ="listview">显示listview?

ios - 当应用程序被终止或屏幕被锁定时,UNTextInputNotificationAction不会被调用 swift 3

c# - 在页面加载时停止触发事件

javascript - 如何在 Firebug 中监控事件?

javascript - 将变量从 objective-c 返回到 javascript